Bot class

Constructors

Bot({required String token, int timeout = 10, FutureOr onReady(Bot)?, FutureOr onStartFailed(Bot, Object, StackTrace)?, List<UpdateType>? allowedUpdates})
Create a new bot with the given token. As soon as bot is created, a getMe is called to validate the given token.

Properties

allowedUpdates List<UpdateType>?
List of alloed updates to be received
Can be changed while the bot is running
getter/setter pair
connectionErrorHandler ↔ (Future Function(Bot, Object, StackTrace)?)
getter/setter pair
errorHandler ↔ (Future Function(Bot, Update, Object, StackTrace)?)
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id int?
Returns current bot id, may be null if onReady has not been called already
no setter
isRunning bool
Returns true if the bot is currently getting updates, false otherwise
no setter
name String?
Returns current bot name, may be null if onReady has not been called already
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
token String
Setup token to be used for API calls
no getterinherited
username String?
Returns current bot username, may be null if onReady has not been called already
no setter

Methods

addStickerToSet(String userId, String name, HttpFile pngSticker, String emojis, {MaskPosition? maskPosition}) Future<bool>
inherited
answerCallbackQuery(String callbackQueryId, {String? text, bool? showAlert, String? url, int? cacheTime}) Future<bool>
inherited
answerInlineQuery(String inlineQueryId, List<InlineQueryResult> results, {int? cacheTime, bool? isPersonal, String? nextOffset, String? switchPmText, String? switchPmParameter}) Future<bool>
inherited
banChatMember(ChatID chatId, int userId, {int? untilDate, bool? revokeMessages}) Future<bool>
Use this method to ban a user in a group, a supergroup or a channel.
inherited
close() Future<bool>
inherited
closeClient() → void
Close the http client
inherited
copyMessage(ChatID chatId, ChatID fromChatId, int messageId, {String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<MessageId>
Use this method to copy messages of any kind.
inherited
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
inherited
createNewStickerSet(String userId, String name, String title, HttpFile pngSticker, String emojis, {bool? containsMasks, MaskPosition? maskPosition}) Future<bool>
inherited
deleteChatPhoto(ChatID chatId) Future<bool>
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
inherited
deleteChatStickerSet(ChatID chatId) Future<bool>
inherited
deleteMessage(ChatID chatId, int messageId) Future<bool>
inherited
deleteMyCommands({BotCommandScope? scope, String? languageCode}) Future<bool>
inherited
deleteStickerFromSet(String sticker) Future<bool>
inherited
deleteWebhook({bool? dropPendingUpdates}) Future<bool>
inherited
download(String path) Future<Uint8List>
inherited
Use this method to edit a non-primary invite link created by the bot.
inherited
editMessageCaption({ChatID? chatId, int? messageId, String? inlineMessageId, String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, ReplyMarkup? replyMarkup}) Future<Message>
inherited
editMessageLiveLocation(double latitude, double longitude, {ChatID? chatId, int? messageId, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to edit live location messages.
inherited
editMessageLiveLocationInline(double latitude, double longitude, {String? inlineMessageId, ReplyMarkup? replyMarkup}) Future<bool>
Use this method to edit live location messages.
inherited
editMessageText(String text, {ChatID? chatId, int? messageId, String? inlineMessageId, ParseMode? parseMode, List<MessageEntity>? entities, bool? disableWebPagePreview, ReplyMarkup? replyMarkup}) Future<Message>
inherited
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked.
inherited
getChat(ChatID chatId) Future<Chat>
inherited
getChatAdministrators(ChatID chatId) Future<List<ChatMember>>
inherited
getChatMember(ChatID chatId, int userId) Future<ChatMember>
inherited
getChatMemberCount(ChatID chatId) Future<int>
inherited
getChatMembersCount(ChatID chatId) Future<int>
inherited
getFile(String fileId) Future<File>
Use this method to get basic info about a file and prepare it for downloading.
inherited
getMe() Future<User>
A simple method for testing your bot's auth token.
inherited
getMyCommands({BotCommandScope? scope, String? languageCode}) Future<List<BotCommand>>
inherited
getStickerSet(String name) Future<StickerSet>
inherited
getUpdates({int? timeout, int? offset, int? limit, List<UpdateType>? allowedUpdates}) Future<List<Update>>
Use this method to receive incoming updates using long polling.
inherited
getUserProfilePhotos(ChatID chatId, {int? offset, int? limit}) Future<UserProfilePhotos>
Use this method to get a list of profile pictures for a user.
inherited
kickChatMember(ChatID chatId, int userId, {int? untilDate, bool? revokeMessages}) Future<bool>
inherited
leaveChat(ChatID chatId) Future<bool>
inherited
logOut() Future<bool>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCommand(String command, Future callback(Bot, Update)) → void
Adds a new command callback which will be executed when the given command is received
onReady(Bot bot) Future
Override this method when extending this class
onStartFailed(Bot bot, Object err, StackTrace st) Future
Override this method when extending this class
onUpdate(Future callback(Bot, Update)) → void
Adds a new update handler which is executed on each update
If an handler throws an error, errorHandler is called and the next handler/update is elaborated
pinChatMessage(ChatID chatId, int messageId, {bool? disableNotification}) Future<bool>
Use this method to add a message to the list of pinned messages in a chat.
inherited
promoteChatMember(ChatID chatId, int userId, {bool? isAnonymous, bool? canChangeInfo, bool? canPostMessages, bool? canEditMessages, bool? canDeleteMessages, bool? canInviteUsers, bool? canRestrictMembers, bool? canPinMessages, bool? canPromoteMembers, bool? canManageVoiceChats, bool? canManageChat}) Future<bool>
Use this method to promote or demote a user in a supergroup or a channel.
inherited
restrictChatMember(ChatID chatId, int userId, ChatPermissions permissions, {int? untilDate}) Future<bool>
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights.
inherited
Use this method to revoke an invite link created by the bot.
inherited
sendAnimation(ChatID chatId, HttpFile animation, {int? duration, int? width, int? height, HttpFile? thumb, String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
inherited
sendAudio(ChatID chatId, HttpFile audio, {String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, int? duration, String? performer, String? title, HttpFile? thumb, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send audio files, if you want Telegram clients to display them in the music player.
inherited
sendChatAction(ChatID chatId, ChatAction action) Future<bool>
Use this method when you need to tell the user that something is happening on the bot's side.
inherited
sendContact(ChatID chatId, String phoneNumber, String? firstName, {String? lastName, String? vcard, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send phone contacts.
inherited
sendDice(ChatID chatId, {Emoji? emoji, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send an animated emoji that will display a random value.
inherited
sendDocument(ChatID chatId, HttpFile document, {HttpFile? thumb, String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup, bool? disableContentTypeDetection}) Future<Message>
Use this method to send general files.
inherited
sendGame(ChatID chatId, String gameShortName, {bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, InlineKeyboardMarkup? replyMarkup}) Future<Message>
inherited
sendInvoice(ChatID chatId, String title, String description, String payload, String providerToken, String startParameter, String currency, List<LabeledPrice> prices, {String? providerData, String? photoUrl, int? photoSize, int? photoWidth, int? photoHeight, bool? needName, bool? needPhoneNumber, bool? needEmail, bool? needShippingAddress, bool? sendPhoneNumberToProvider, bool? sendEmailToProvider, bool? isFlexible, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, InlineKeyboardMarkup? replyMarkup}) Future<Message>
inherited
sendLocation(ChatID chatId, double latitude, double longitude, {int? livePeriod, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send point on the map.
inherited
sendMediaGroup(ChatID chatId, List<InputMedia> media, {bool? disableNotification, bool? allowSendingWithoutReply, int? replyToMessageId}) Future<List<Message>>
Use this method to send a group of photos, videos,documents or audios as an album.
inherited
sendMessage(ChatID chatId, String text, {ParseMode? parseMode, List<MessageEntity>? entities, bool? disableWebPagePreview, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send text messages.
inherited
sendPhoto(ChatID chatId, HttpFile photo, {String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send photos.
inherited
sendPoll(ChatID chatId, String question, List<String> options, {bool? isAnonymous, String? type, bool? allowsMultipleAnswers, int? correctOptionId, bool? isClosed, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send a native poll.
inherited
sendSticker(ChatID chatId, HttpFile sticker, {bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
inherited
sendVenue(ChatID chatId, double latitude, double longitude, String title, String address, {String? foursquareId, String? foursquareType, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send information about a venue.
inherited
sendVideo(ChatID chatId, HttpFile video, {int? duration, int? width, int? height, HttpFile? thumb, String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, bool? supportsStreaming, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
inherited
sendVideoNote(ChatID chatId, HttpFile videoNote, {int? duration, int? length, HttpFile? thumb, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send video messages.
inherited
sendVoice(ChatID chatId, HttpFile voice, {String? caption, ParseMode? parseMode, List<MessageEntity>? captionEntities, int? duration, bool? disableNotification, int? replyToMessageId, bool? allowSendingWithoutReply, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
inherited
setChatAdministratorCustomTitle(ChatID chatId, int userId, String customTitle) Future<bool>
Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
inherited
setChatDescription(ChatID chatId, String description) Future<bool>
Use this method to change the description of a group, a supergroup or a channel.
inherited
setChatPermissions(ChatID chatId, ChatPermissions permissions) Future<bool>
Use this method to set default chat permissions for all members.
inherited
setChatPhoto(ChatID chatId, HttpFile photo) Future<bool>
Use this method to set a new profile photo for the chat.
inherited
setChatStickerSet(ChatID chatId, String stickerSetName) Future<bool>
inherited
setChatTitle(ChatID chatId, String title) Future<bool>
Use this method to change the title of a chat. Titles can't be changed for private chats.
inherited
setMyCommands(List<BotCommand> botCommands, {BotCommandScope? scope, String? languageCode}) Future<bool>
inherited
setStickerPositionInSet(String sticker, int position) Future<bool>
inherited
start({bool clean = false}) Future
Start getting updates, if clean is true, previous updates will be dropped
stop() → void
Stops bot if it's running, only closes the http client if not
stopMessageLiveLocation({String? inlineMessageId, ChatID? chatId, int? messageId, ReplyMarkup? replyMarkup}) Future<Message>
Use this method to stop updating a live location message before live_period expires.
inherited
stopPoll(ChatID chatId, int messageId, {ReplyMarkup? replyMarkup}) Future<Poll>
inherited
toString() String
A string representation of this object.
inherited
unbanChatMember(ChatID chatId, int userId, {bool? onlyIfBanned}) Future<bool>
Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc.
inherited
unpinAllChatMessages(ChatID chatId) Future<bool>
inherited
unpinChatMessage(ChatID chatId, {int? messageId}) Future<bool>
Use this method to remove a message from the list of pinned messages in a chat.
inherited
updateMe() Future
Update bot info, useful if bot info are changed from BotFather while the bot is running
uploadStickerFile(String userId, HttpFile pngSticker) Future<File>
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited