-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot_echo.nim
More file actions
30 lines (22 loc) · 789 Bytes
/
bot_echo.nim
File metadata and controls
30 lines (22 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# run with `./build/bot_echo`
import chronicles
import chronos
import chat
import content_types
proc main() {.async.} =
let waku = initWakuClient(DefaultConfig())
var chatClient = newClient(waku).get()
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()