Webhook¶
-
class
aiogram.dispatcher.webhook.AddStickerToSet(user_id: Integer, name: String, png_sticker: String, emojis: String, mask_position: typing.Union[aiogram.types.mask_position.MaskPosition, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for add sticker to set on to webhook.
Параметры: - user_id – Integer - User identifier of sticker set owner
- name – String - Sticker set name
- png_sticker – String - Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
- emojis – String - One or more emoji corresponding to the sticker
- mask_position – types.MaskPosition (Optional) - Position where the mask should be placed on faces
-
class
aiogram.dispatcher.webhook.AnswerCallbackQuery(callback_query_id: String, text: typing.Union[~String, NoneType] = None, show_alert: typing.Union[~Boolean, NoneType] = None, url: typing.Union[~String, NoneType] = None, cache_time: typing.Union[~Integer, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for answer callback query on to webhook.
Параметры: - callback_query_id – String - Unique identifier for the query to be answered
- text – String (Optional) - Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
- show_alert – Boolean (Optional) - If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
- url – String (Optional) - URL that will be opened by the user’s client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
- cache_time – Integer (Optional) - The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
-
class
aiogram.dispatcher.webhook.AnswerInlineQuery(inline_query_id: String, results: [<class 'aiogram.types.inline_query_result.InlineQueryResult'>], cache_time: typing.Union[~Integer, NoneType] = None, is_personal: typing.Union[~Boolean, NoneType] = None, next_offset: typing.Union[~String, NoneType] = None, switch_pm_text: typing.Union[~String, NoneType] = None, switch_pm_parameter: typing.Union[~String, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for answer inline query on to webhook.
Параметры: - inline_query_id – String - Unique identifier for the answered query
- results – [types.InlineQueryResult] - A JSON-serialized array of results for the inline query
- cache_time – Integer (Optional) - The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
- is_personal – Boolean (Optional) - Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
- next_offset – String (Optional) - Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
- switch_pm_text – String (Optional) - If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
- switch_pm_parameter – String (Optional) - Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot’s inline capabilities.
-
class
aiogram.dispatcher.webhook.AnswerPreCheckoutQuery(pre_checkout_query_id: String, ok: Boolean, error_message: typing.Union[~String, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for answer pre checkout query on to webhook.
Параметры: - pre_checkout_query_id – String - Unique identifier for the query to be answered
- ok – Boolean - Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
- error_message – String (Optional) - Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. “Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!”). Telegram will display this message to the user.
-
class
aiogram.dispatcher.webhook.AnswerShippingQuery(shipping_query_id: String, ok: Boolean, shipping_options: typing.Union[typing.List[aiogram.types.shipping_option.ShippingOption], NoneType] = None, error_message: typing.Union[~String, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for answer shipping query on to webhook.
Параметры: - shipping_query_id – String - Unique identifier for the query to be answered
- ok – Boolean - Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
- shipping_options – [types.ShippingOption] (Optional) - Required if ok is True. A JSON-serialized array of available shipping options.
- error_message – String (Optional) - Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your desired address is unavailable’). Telegram will display this message to the user.
-
class
aiogram.dispatcher.webhook.BaseResponse[исходный код]¶ - Базовые классы:
objectBase class for webhook responses.
-
cleanup() → typing.Dict[исходный код]¶ Cleanup response after preparing. Remove empty fields.
Результат: response parameters dict
-
execute_response(bot)[исходный код]¶ Use this method if you want to execute response as simple HTTP request.
Параметры: bot – Bot instance. Результат:
-
get_response()[исходный код]¶ Get response object
Результат:
-
get_web_response()[исходный код]¶ Get prepared web response with JSON data.
Результат: aiohttp.web.Response
-
method¶ In all subclasses of that class you need to override this property
Результат: str
-
prepare() → typing.Dict[исходный код]¶ You need to override this method.
Результат: response parameters dict
-
-
class
aiogram.dispatcher.webhook.CreateNewStickerSet(user_id: Integer, name: String, title: String, png_sticker: String, emojis: String, contains_masks: typing.Union[~Boolean, NoneType] = None, mask_position: typing.Union[aiogram.types.mask_position.MaskPosition, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for create new sticker set on to webhook.
Параметры: - user_id – Integer - User identifier of created sticker set owner
- name – String - Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can’t contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
- title – String - Sticker set title, 1-64 characters
- png_sticker – String - Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
- emojis – String - One or more emoji corresponding to the sticker
- contains_masks – Boolean (Optional) - Pass True, if a set of mask stickers should be created
- mask_position – types.MaskPosition (Optional) - Position where the mask should be placed on faces
-
class
aiogram.dispatcher.webhook.DeleteChatPhoto(chat_id: typing.Union[~Integer, ~String])[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for delete chat photo on to webhook.
Параметры: chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
-
class
aiogram.dispatcher.webhook.DeleteMessage(chat_id: typing.Union[~Integer, ~String], message_id: Integer)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for delete message on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- message_id – Integer - Identifier of the message to delete
-
class
aiogram.dispatcher.webhook.DeleteStickerFromSet(sticker: String)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for delete sticker from set on to webhook.
Параметры: sticker – String - File identifier of the sticker
-
class
aiogram.dispatcher.webhook.EditMessageCaption(chat_id: typing.Union[~Integer, ~String, NoneType] = None, message_id: typing.Union[~Integer, NoneType] = None, inline_message_id: typing.Union[~String, NoneType] = None, caption: typing.Union[~String, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for edit message caption on to webhook.
Параметры: - chat_id – Union[Integer, String] (Optional) - Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- message_id – Integer (Optional) - Required if inline_message_id is not specified. Identifier of the sent message
- inline_message_id – String (Optional) - Required if chat_id and message_id are not specified. Identifier of the inline message
- caption – String (Optional) - New caption of the message
- reply_markup – types.InlineKeyboardMarkup (Optional) - A JSON-serialized object for an inline keyboard.
-
class
aiogram.dispatcher.webhook.EditMessageReplyMarkup(chat_id: typing.Union[~Integer, ~String, NoneType] = None, message_id: typing.Union[~Integer, NoneType] = None, inline_message_id: typing.Union[~String, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for edit message reply markup on to webhook.
Параметры: - chat_id – Union[Integer, String] (Optional) - Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- message_id – Integer (Optional) - Required if inline_message_id is not specified. Identifier of the sent message
- inline_message_id – String (Optional) - Required if chat_id and message_id are not specified. Identifier of the inline message
- reply_markup – types.InlineKeyboardMarkup (Optional) - A JSON-serialized object for an inline keyboard.
-
class
aiogram.dispatcher.webhook.EditMessageText(text: String, chat_id: typing.Union[~Integer, ~String, NoneType] = None, message_id: typing.Union[~Integer, NoneType] = None, inline_message_id: typing.Union[~String, NoneType] = None, parse_mode: typing.Union[~String, NoneType] = None, disable_web_page_preview: typing.Union[~Boolean, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for edit message text on to webhook.
Параметры: - chat_id – Union[Integer, String] (Optional) - Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- message_id – Integer (Optional) - Required if inline_message_id is not specified. Identifier of the sent message
- inline_message_id – String (Optional) - Required if chat_id and message_id are not specified. Identifier of the inline message
- text – String - New text of the message
- parse_mode – String (Optional) - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.
- disable_web_page_preview – Boolean (Optional) - Disables link previews for links in this message
- reply_markup – types.InlineKeyboardMarkup (Optional) - A JSON-serialized object for an inline keyboard.
-
class
aiogram.dispatcher.webhook.ForwardMessage(chat_id: typing.Union[~Integer, ~String], from_chat_id: typing.Union[~Integer, ~String], message_id: Integer, disable_notification: typing.Union[~Boolean, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for forward messages of any kind on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- from_chat_id – Union[Integer, String] - Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- message_id – Integer - Message identifier in the chat specified in from_chat_id
-
class
aiogram.dispatcher.webhook.KickChatMember(chat_id: typing.Union[~Integer, ~String], user_id: Integer, until_date: typing.Union[~Integer, datetime.datetime, datetime.timedelta, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for kick chat member on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
- user_id – Integer - Unique identifier of the target user
- until_date – Integer - Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
-
class
aiogram.dispatcher.webhook.LeaveChat(chat_id: typing.Union[~Integer, ~String])[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for leave chat on to webhook.
Параметры: chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
-
class
aiogram.dispatcher.webhook.PinChatMessage(chat_id: typing.Union[~Integer, ~String], message_id: Integer, disable_notification: typing.Union[~Boolean, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for pin chat message on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
- message_id – Integer - Identifier of a message to pin
- disable_notification – Boolean - Pass True, if it is not necessary to send a notification to all group members about the new pinned message
-
class
aiogram.dispatcher.webhook.PromoteChatMember(chat_id: typing.Union[~Integer, ~String], user_id: Integer, can_change_info: typing.Union[~Boolean, NoneType] = None, can_post_messages: typing.Union[~Boolean, NoneType] = None, can_edit_messages: typing.Union[~Boolean, NoneType] = None, can_delete_messages: typing.Union[~Boolean, NoneType] = None, can_invite_users: typing.Union[~Boolean, NoneType] = None, can_restrict_members: typing.Union[~Boolean, NoneType] = None, can_pin_messages: typing.Union[~Boolean, NoneType] = None, can_promote_members: typing.Union[~Boolean, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for promote chat member on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- user_id – Integer - Unique identifier of the target user
- can_change_info – Boolean - Pass True, if the administrator can change chat title, photo and other settings
- can_post_messages – Boolean - Pass True, if the administrator can create channel posts, channels only
- can_edit_messages – Boolean - Pass True, if the administrator can edit messages of other users, channels only
- can_delete_messages – Boolean - Pass True, if the administrator can delete messages of other users
- can_invite_users – Boolean - Pass True, if the administrator can invite new users to the chat
- can_restrict_members – Boolean - Pass True, if the administrator can restrict, ban or unban chat members
- can_pin_messages – Boolean - Pass True, if the administrator can pin messages, supergroups only
- can_promote_members – Boolean - Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
-
class
aiogram.dispatcher.webhook.ReplyToMixin[исходный код]¶ - Базовые классы:
objectMixin for responses where from which can reply to messages.
-
reply(message: typing.Union[int, aiogram.types.message.Message])[исходный код]¶ Reply to message
Параметры: message – intortypes.MessageРезультат: self
-
-
class
aiogram.dispatcher.webhook.RestrictChatMember(chat_id: typing.Union[~Integer, ~String], user_id: Integer, until_date: typing.Union[~Integer, datetime.datetime, datetime.timedelta, NoneType] = None, can_send_messages: typing.Union[~Boolean, NoneType] = None, can_send_media_messages: typing.Union[~Boolean, NoneType] = None, can_send_other_messages: typing.Union[~Boolean, NoneType] = None, can_add_web_page_previews: typing.Union[~Boolean, NoneType] = None)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for restrict chat member on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
- user_id – Integer - Unique identifier of the target user
- until_date – Integer - Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
- can_send_messages – Boolean - Pass True, if the user can send text messages, contacts, locations and venues
- can_send_media_messages – Boolean - Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
- can_send_other_messages – Boolean - Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
- can_add_web_page_previews – Boolean - Pass True, if the user may add web page previews to their messages, implies can_send_media_messages
-
class
aiogram.dispatcher.webhook.SendAudio(chat_id: typing.Union[~Integer, ~String], audio: String, caption: typing.Union[~String, NoneType] = None, duration: typing.Union[~Integer, NoneType] = None, performer: typing.Union[~String, NoneType] = None, title: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send audio on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- audio – String - Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data.
- caption – String (Optional) - Audio caption, 0-200 characters
- duration – Integer (Optional) - Duration of the audio in seconds
- performer – String (Optional) - Performer
- title – String (Optional) - Track name
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendChatAction(chat_id: typing.Union[~Integer, ~String], action: String)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for send chat action on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- action – String - Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes.
-
class
aiogram.dispatcher.webhook.SendContact(chat_id: typing.Union[~Integer, ~String], phone_number: String, first_name: String, last_name: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send contact on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- phone_number – String - Contact’s phone number
- first_name – String - Contact’s first name
- last_name – String (Optional) - Contact’s last name
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendDocument(chat_id: typing.Union[~Integer, ~String], document: String, caption: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send document on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- document – String - File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
- caption – String (Optional) - Document caption (may also be used when resending documents by file_id), 0-200 characters
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendGame(chat_id: Integer, game_short_name: String, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, NoneType] = None)[исходный код]¶ Use that response type for send game on to webhook.
Параметры: - chat_id – Integer - Unique identifier for the target chat
- game_short_name – String - Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – types.InlineKeyboardMarkup (Optional) - A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game.
-
class
aiogram.dispatcher.webhook.SendInvoice(chat_id: Integer, title: String, description: String, payload: String, provider_token: String, start_parameter: String, currency: String, prices: [<class 'aiogram.types.labeled_price.LabeledPrice'>], photo_url: typing.Union[~String, NoneType] = None, photo_size: typing.Union[~Integer, NoneType] = None, photo_width: typing.Union[~Integer, NoneType] = None, photo_height: typing.Union[~Integer, NoneType] = None, need_name: typing.Union[~Boolean, NoneType] = None, need_phone_number: typing.Union[~Boolean, NoneType] = None, need_email: typing.Union[~Boolean, NoneType] = None, need_shipping_address: typing.Union[~Boolean, NoneType] = None, is_flexible: typing.Union[~Boolean, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, NoneType] = None)[исходный код]¶ Use that response type for send invoice on to webhook.
Параметры: - chat_id – Integer - Unique identifier for the target private chat
- title – String - Product name, 1-32 characters
- description – String - Product description, 1-255 characters
- payload – String - Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
- provider_token – String - Payments provider token, obtained via Botfather
- start_parameter – String - Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
- currency – String - Three-letter ISO 4217 currency code, see more on currencies
- prices – [types.LabeledPrice] - Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
- photo_url – String (Optional) - URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
- photo_size – Integer (Optional) - Photo size
- photo_width – Integer (Optional) - Photo width
- photo_height – Integer (Optional) - Photo height
- need_name – Boolean (Optional) - Pass True, if you require the user’s full name to complete the order
- need_phone_number – Boolean (Optional) - Pass True, if you require the user’s phone number to complete the order
- need_email – Boolean (Optional) - Pass True, if you require the user’s email to complete the order
- need_shipping_address – Boolean (Optional) - Pass True, if you require the user’s shipping address to complete the order
- is_flexible – Boolean (Optional) - Pass True, if the final price depends on the shipping method
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – types.InlineKeyboardMarkup (Optional) - A JSON-serialized object for an inline keyboard. If empty, one ‘Pay total price’ button will be shown. If not empty, the first button must be a Pay button.
-
class
aiogram.dispatcher.webhook.SendLocation(chat_id: typing.Union[~Integer, ~String], latitude: Float, longitude: Float, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send location on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- latitude – Float - Latitude of location
- longitude – Float - Longitude of location
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendMessage(chat_id: typing.Union[~Integer, ~String], text: String, parse_mode: typing.Union[~String, NoneType] = None, disable_web_page_preview: typing.Union[~Boolean, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ You can send message with webhook by using this instance of this object. All arguments is equal with Bot.send_message method.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- text – String - Text of the message to be sent
- parse_mode – String (Optional) - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.
- disable_web_page_preview – Boolean (Optional) - Disables link previews for links in this message
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendPhoto(chat_id: typing.Union[~Integer, ~String], photo: String, caption: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send photo on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- photo – String - Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data.
- caption – String (Optional) - Photo caption (may also be used when resending photos by file_id), 0-200 characters
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendSticker(chat_id: typing.Union[~Integer, ~String], sticker: String, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send sticker on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- sticker – String - Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendVenue(chat_id: typing.Union[~Integer, ~String], latitude: Float, longitude: Float, title: String, address: String, foursquare_id: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send venue on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- latitude – Float - Latitude of the venue
- longitude – Float - Longitude of the venue
- title – String - Name of the venue
- address – String - Address of the venue
- foursquare_id – String (Optional) - Foursquare identifier of the venue
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendVideo(chat_id: typing.Union[~Integer, ~String], video: String, duration: typing.Union[~Integer, NoneType] = None, width: typing.Union[~Integer, NoneType] = None, height: typing.Union[~Integer, NoneType] = None, caption: typing.Union[~String, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send video on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- video – String - Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data.
- duration – Integer (Optional) - Duration of sent video in seconds
- width – Integer (Optional) - Video width
- height – Integer (Optional) - Video height
- caption – String (Optional) - Video caption (may also be used when resending videos by file_id), 0-200 characters
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendVideoNote(chat_id: typing.Union[~Integer, ~String], video_note: String, duration: typing.Union[~Integer, NoneType] = None, length: typing.Union[~Integer, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send video note on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- video_note – String - Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported
- duration – Integer (Optional) - Duration of sent video in seconds
- length – Integer (Optional) - Video width and height
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SendVoice(chat_id: typing.Union[~Integer, ~String], voice: String, caption: typing.Union[~String, NoneType] = None, duration: typing.Union[~Integer, NoneType] = None, disable_notification: typing.Union[~Boolean, NoneType] = None, reply_to_message_id: typing.Union[~Integer, NoneType] = None, reply_markup: typing.Union[aiogram.types.inline_keyboard.InlineKeyboardMarkup, aiogram.types.reply_keyboard.ReplyKeyboardMarkup, typing.Dict, ~String, NoneType] = None)[исходный код]¶ Use that response type for send voice on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- voice – String - Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
- caption – String (Optional) - Voice message caption, 0-200 characters
- duration – Integer (Optional) - Duration of the voice message in seconds
- disable_notification – Boolean (Optional) - Sends the message silently. Users will receive a notification with no sound.
- reply_to_message_id – Integer (Optional) - If the message is a reply, ID of the original message
- reply_markup – Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional) - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
-
class
aiogram.dispatcher.webhook.SetChatDescription(chat_id: typing.Union[~Integer, ~String], description: String)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for set chat description on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- description – String - New chat description, 0-255 characters
-
class
aiogram.dispatcher.webhook.SetChatTitle(chat_id: typing.Union[~Integer, ~String], title: String)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for set chat title on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- title – String - New chat title, 1-255 characters
-
class
aiogram.dispatcher.webhook.SetStickerPositionInSet(sticker: String, position: Integer)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for set sticker position in set on to webhook.
Параметры: - sticker – String - File identifier of the sticker
- position – Integer - New sticker position in the set, zero-based
-
class
aiogram.dispatcher.webhook.UnbanChatMember(chat_id: typing.Union[~Integer, ~String], user_id: Integer)[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for unban chat member on to webhook.
Параметры: - chat_id – Union[Integer, String] - Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
- user_id – Integer - Unique identifier of the target user
-
class
aiogram.dispatcher.webhook.UnpinChatMessage(chat_id: typing.Union[~Integer, ~String])[исходный код]¶ - Базовые классы:
aiogram.dispatcher.webhook.BaseResponseUse that response type for unpin chat message on to webhook.
Параметры: chat_id – Union[Integer, String] - Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
-
class
aiogram.dispatcher.webhook.WebhookRequestHandler(request: None) → None[исходный код]¶ - Базовые классы:
aiohttp.web_urldispatcher.ViewSimple Wehhook request handler for aiohttp web server.
You need to register that in app:
app.router.add_route('*', '/your/webhook/path', WebhookRequestHadler, name='webhook_handler')
But first you need to configure application for getting Dispatcher instance from request handler! It must always be with key ‘BOT_DISPATCHER’
bot = Bot(TOKEN, loop) dp = Dispatcher(bot) app['BOT_DISPATCHER'] = dp
-
get_dispatcher()[исходный код]¶ Get Dispatcher instance from environment
Результат: aiogram.Dispatcher
-
get_response(results)[исходный код]¶ Get response object from results.
Параметры: results – list Результат:
-
parse_update(bot)[исходный код]¶ Read update from stream and deserialize it.
Параметры: bot – bot instance. You an get it from Dispatcher Результат: aiogram.types.Update
-
post()[исходный код]¶ Process POST request
if one of handler returns instance of
aiogram.dispatcher.webhook.BaseResponsereturn it to webhook. Otherwise do nothing (return ‘ok’)Результат: aiohttp.web.Response
-
process_update(update)[исходный код]¶ Need respond in less than 60 seconds in to webhook.
So... If you respond greater than 55 seconds webhook automatically respond ‘ok’ and execute callback response via simple HTTP request.
Параметры: update – Результат:
-
respond_via_request(task)[исходный код]¶ Handle response after 55 second.
Параметры: task – Результат:
-
-
aiogram.dispatcher.webhook.configure_app(dispatcher, app: aiohttp.web_app.Application, path='/webhook')[исходный код]¶ You can prepare web.Application for working with webhook handler.
Параметры: - dispatcher – Dispatcher instance
- app –
aiohttp.web.Application - path – Path to your webhook.
Результат:
-
aiogram.dispatcher.webhook.get_new_configured_app(dispatcher, path='/webhook')[исходный код]¶ Create new
aiohttp.web.Applicationand configure it.Параметры: - dispatcher – Dispatcher instance
- path – Path to your webhook.
Результат: