#71 Have some async mechanism for reaction to IRC messages

開啟中
fr33domlover7 年之前創建 · 0 條評論

Suppose the bot asks a user some question and should react to the answer. Since the message queue is async already, there should be some way to wait for a reply and act on it. Ideas:

  1. Make it feature specific. For example, if I want to use it for nickserv ident, then in BotState have a map of nicknames waiting for ident and some enum of whatever operation should follow, and whenever a message from NickServ indeed comes, look at that bot state and react. The strength of this approach is that it doesn't involve storing closures in a hashmap etc. idk if that would really be a memory problem or anything, maybe not. The weakness is that the code that asks and the code that reacts to the reply are in different places.
  2. Make a generic async system where code that asks a question in BotSession can insert a Message -> BotSession () action into the async action map and have it run when the reply Message comes. This means saving closures in a map, which idk could maybe make memory usage high? The strength is that the question and answer reaction are in the same place in the code, so it's real async programming.
Suppose the bot asks a user some question and should react to the answer. Since the message queue is async already, there should be some way to wait for a reply and act on it. Ideas: 1. Make it feature specific. For example, if I want to use it for nickserv ident, then in `BotState` have a map of nicknames waiting for ident and some enum of whatever operation should follow, and whenever a message from NickServ indeed comes, look at that bot state and react. The strength of this approach is that it doesn't involve storing closures in a hashmap etc. idk if that would really be a memory problem or anything, maybe not. The weakness is that the code that asks and the code that reacts to the reply are in different places. 2. Make a generic async system where code that asks a question in `BotSession` can insert a `Message -> BotSession ()` action into the async action map and have it run when the reply `Message` comes. This means saving closures in a map, which idk could maybe make memory usage high? The strength is that the question and answer reaction are in the same place in the code, so it's real async programming.
Sign in to join this conversation.
未選擇里程碑
未指派成員
1 參與者
正在加載...
取消
保存
尚未有任何內容