import { Bot } from "https://dotland.deno.dev/x/grammy@v1.31.0/mod.ts";
Starts your bot using long polling.
This method returns a
Promise
that will never resolve except if your bot is stopped. You don't need toawait
the call tobot.start
, but remember to catch potential errors by callingbot.catch
. Otherwise your bot will crash (and stop) if something goes wrong in your code.
This method effectively enters a loop that will repeatedly call
getUpdates
and run your middleware for every received update, allowing
your bot to respond to messages.
If your bot is already running, this method does nothing.
Note that this starts your bot using a very simple long polling
implementation. bot.start
should only be used for small bots. While
the rest of grammY was built to perform well even under extreme loads,
simple long polling is not capable of scaling up in a similar fashion.
You should switch over to using @grammyjs/runner
if you are running a
bot with high load.
What exactly high load means differs from bot to bot, but as a rule of
thumb, simple long polling should not be processing more than ~5K
messages every hour. Also, if your bot has long-running operations such
as large file transfers that block the middleware from completing, this
will impact the responsiveness negatively, so it makes sense to use the
@grammyjs/runner
package even if you receive much fewer messages. If
you worry about how much load your bot can handle, check out the grammY
documentation about scaling
up.