#71 Have some async mechanism for reaction to IRC messages

باز‌کردن
7 سال پیش باز شده توسط fr33domlover · 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.
برای پیوستن به گفتگو، وارد شودید.
بدون نقطه عطف
بدون مسئول رسیدگی
1 مشارکت کننده
درحال بارگذاری...
لغو
ذخيره
هنوز محتوایی ایجاد نشده.