Closed KnorpelSenf closed 1 year ago
Would this be a good API?
// bot.ts
const bot = new Bot("token");
bot.use(sequentialize((ctx) => ctx.chat?.id.toString()));
runDistributed(bot, "./worker.ts");
// worker.ts
const worker = new BotWorker();
worker.on("message", (ctx) => ctx.reply("brrr"));
Running multiple instances of a bot is currently possible by composing low-level objects such as sources and sinks, and connecting them manually via a runner.
It would be cool to just do
runDistributed(bot)
and get all of that for free.sequentialize
. It may be necessary to perform parsing in the central node. In that case, repeated parsing cannot necessarily be avoided that easily.