Core & Session
Part of the API Reference.
call
Future<dynamic> call(String method, [Json? params, Map<String, InputFile>? files]) =>
Low-level escape hatch: calls any Telegram Bot API method by name.
Use this for brand-new API methods that don’t have a typed wrapper yet.
[method] is the raw Bot API method name (e.g. 'sendMessage'), [params]
is the JSON body, and [files] are any [InputFile]s that should be
uploaded as multipart attachments.
getMe
Future<Json> getMe() async => _o(await call('getMe'));
Returns basic information about the bot itself as a [User] object (in raw JSON form).
Handy as a quick way to verify that [token] is valid.
logOut
Future<bool> logOut() async => _b(await call('logOut'));
Logs the bot out from the Bot API server before moving it to a local server instance. You generally never need this unless you’re running your own Bot API server.
close
Future<bool> close() async => _b(await call('close'));
Closes the bot instance before moving it from one local server to another. Not related to [dispose] — this is a Telegram API call, not local cleanup.
getManagedBotToken
Future<String> getManagedBotToken(int botId) async =>
Returns the current access token of a bot managed by this bot ([botId] is the managed bot's user ID). Only available to managing bots — see https://core.telegram.org/bots/features#secretary-bots.
replaceManagedBotToken
Future<String> replaceManagedBotToken(int botId) async =>
Generates a new access token for a bot managed by this bot ([botId] is the managed bot's user ID), invalidating the previous one. Use this to rotate a managed bot's token, e.g. after a suspected compromise.