RunnerHandle
This handle gives you control over a runner. It allows you to stop the bot, start it again, and check whether it is running.
Properties
start
start: () => void;
Starts the bot. Note that calling run
will automatically do this for you, so you only have to call start
if you create a runner yourself with create
.
stop
stop: () => Promise<void>;
Stops the bot. The bot will no longer fetch updates from Telegram, and it will interrupt the currently pending get
call.
This method returns a promise that will resolve as soon as all currently running middleware is done executing. This means that you can await handle
to be sure that your bot really stopped completely.
size
size: () => number;
Returns the size of the underlying update sink. This number is equal to the number of updates that are currently being processed. The size does not count updates that have completed, errored, or timed out.
task
task: () => Promise<void> | undefined;
Returns a promise that resolves as soon as the runner stops, either by being stopped or by crashing. If the bot crashes, it means that the error handlers installed on the bot re-threw the error, in which case the bot terminates. A runner handle does not give you access to errors thrown by the bot. Returns undefined
if and only if is
returns false
.
isRunning
isRunning: () => boolean;
Determines whether the bot is currently running or not. Note that this will return false
as soon as you call stop
on the handle, even though the promise returned by stop
may not have resolved yet.