You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New users of Telegraf often mistakenly write listeners within listeners like so:
bot.command("form",asyncctx=>{awaitctx.reply("Send first input");bot.on("message",asyncctx=>{// ^^^ BUG! This attaches a new global listener every time!awaitctx.reply("Send second input");
...
});});
When exploring ideas to resolve this, @trgwii suggested that we log a warning when we detect new listeners added after bot.launch() (perhaps after the first bot.handleUpdate() to account for webhooks?). We don't really need to track all composers, because this problem almost exclusively happens with the base Telegraf instance. The warning can link to a doc page about this specific behaviour with alternatives (Wizard, ...?) and ways to disable the warning if they know what they're doing.
Before implementing this, I'd like to know if any plugins rely on this kind of behaviour at runtime. We may not want to go through with this if any popular plugin attaches listeners on Telegraf at runtime for a valid reason (Is there one? Ready to discuss).
The text was updated successfully, but these errors were encountered:
New users of Telegraf often mistakenly write listeners within listeners like so:
When exploring ideas to resolve this, @trgwii suggested that we log a warning when we detect new listeners added after
bot.launch()
(perhaps after the firstbot.handleUpdate()
to account for webhooks?). We don't really need to track all composers, because this problem almost exclusively happens with the base Telegraf instance. The warning can link to a doc page about this specific behaviour with alternatives (Wizard, ...?) and ways to disable the warning if they know what they're doing.Before implementing this, I'd like to know if any plugins rely on this kind of behaviour at runtime. We may not want to go through with this if any popular plugin attaches listeners on Telegraf at runtime for a valid reason (Is there one? Ready to discuss).
The text was updated successfully, but these errors were encountered: