nim-chat-poc/examples/bot_echo.nim
Jazz Turner-Baggs 702d25a0d8 Libchat library Integration (#55)
* chore: add smoke test and redesign CI workflow (#62)

Add a smoke test that validates the binary links all dependencies
at runtime by instantiating a client without networking. Redesign
CI into separate build and test jobs, with test gated on build.

* Add libchat module

* Add Context

* Add libchat

* Update to latest libchat

* Remove stale files

* Bump to latest Libchat

* Update imports

* Update client

* Update library to work with Libchat

* Fix examples

* Remove Tui Examples - Replace with logos-core

* Add Indentity Todo

* fix: add `build-libchat` as dependency for examples, tests, and library (#59)

The Rust liblogos_chat.so was not being built automatically, causing
runtime failures when loading the shared library.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add Todo for Sender data

* Updated error log

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-16 10:29:40 -08:00

31 lines
830 B
Nim

# run with `./build/bot_echo`
import chronicles
import chronos
import chat
import content_types
proc main() {.async.} =
let waku = initWakuClient(DefaultConfig())
let ident = createIdentity("EchoBot")
var chatClient = newClient(waku, ident)
chatClient.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} =
info "New Message: ", convoId = convo.id(), msg= msg
discard await convo.sendMessage(msg.content)
)
chatClient.onNewConversation(proc(convo: Conversation) {.async.} =
info "New Conversation Initiated: ", convoId = convo.id()
discard await convo.sendMessage(initTextFrame("Hello!").toContentFrame().encode())
)
await chatClient.start()
info "EchoBot started"
info "Invite", link=chatClient.createIntroBundle()
when isMainModule:
waitFor main()
runForever()