grammyjs / runner

Scale bots that use long polling to receive updates.
https://grammy.dev/plugins/runner
MIT License
19 stars 3 forks source link

feat: Simple Distributed Mode #6

Closed KnorpelSenf closed 1 year ago

KnorpelSenf commented 2 years ago

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.

KnorpelSenf commented 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"));