Merge branch 'dev-3.x' into docs-cleanup

This commit is contained in:
Alex Root Junior 2023-07-28 22:26:37 +03:00
commit 48c4884877
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
676 changed files with 6762 additions and 2014 deletions

View file

@ -1 +1 @@
6.6
6.7

View file

@ -0,0 +1,10 @@
name: EncryptedPassportElement
description: |
This object represents type of encrypted passport element.
Source: https://core.telegram.org/bots/api#encryptedpassportelement
parse:
entity: EncryptedPassportElement
category: types
attribute: type
regexp: "'([a-z_]+)'"

View file

@ -5,7 +5,7 @@ description: |
Source: https://core.telegram.org/bots/api#inlinequeryresult
multi_parse:
attribute: type
regexp: "must be ([a-z_]+)"
regexp: "must be ([a-z_0-9]+)"
entities:
- InlineQueryResultCachedAudio
- InlineQueryResultCachedDocument

View file

@ -0,0 +1,18 @@
name: PassportElementErrorType
description: |
This object represents a passport element error type.
Source: https://core.telegram.org/bots/api#passportelementerror
multi_parse:
attribute: source
regexp: 'must be ([a-z_]+)'
entities:
- PassportElementErrorDataField
- PassportElementErrorFrontSide
- PassportElementErrorReverseSide
- PassportElementErrorSelfie
- PassportElementErrorFile
- PassportElementErrorFiles
- PassportElementErrorTranslationFile
- PassportElementErrorTranslationFiles
- PassportElementErrorUnspecified

View file

@ -38,9 +38,9 @@
{
"type": "Boolean",
"required": false,
"description": "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",
"html_description": "<td>Pass <em>True</em> 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</td>",
"rst_description": "Pass :code:`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\n",
"description": "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.",
"html_description": "<td>Pass <em>True</em> 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.</td>",
"rst_description": "Pass :code:`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.\n",
"name": "is_personal"
},
{
@ -52,12 +52,12 @@
"name": "next_offset"
},
{
"type": "String",
"type": "InlineQueryResultsButton",
"required": false,
"description": "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",
"html_description": "<td>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 <em>switch_pm_parameter</em></td>",
"rst_description": "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*\n",
"name": "switch_pm_text"
"description": "A JSON-serialized object describing a button to be shown above inline query results",
"html_description": "<td>A JSON-serialized object describing a button to be shown above inline query results</td>",
"rst_description": "A JSON-serialized object describing a button to be shown above inline query results\n",
"name": "button"
},
{
"type": "String",
@ -65,7 +65,23 @@
"description": "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.\n\nExample: 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.",
"html_description": "<td><a href=\"/bots/features#deep-linking\">Deep-linking</a> parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed.<br/>\n<br/>\n<em>Example:</em> 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 <a href=\"#inlinekeyboardmarkup\"><em>switch_inline</em></a> button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.</td>",
"rst_description": "`Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.\n\n\n\n*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 `https://core.telegram.org/bots/api#inlinekeyboardmarkup <https://core.telegram.org/bots/api#inlinekeyboardmarkup>`_ *switch_inline* button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.\n",
"name": "switch_pm_parameter"
"name": "switch_pm_parameter",
"deprecated": {
"version": "6.7",
"release_date": "2023-04-21"
}
},
{
"type": "String",
"required": false,
"description": "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",
"html_description": "<td>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 <em>switch_pm_parameter</em></td>",
"rst_description": "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*\n",
"name": "switch_pm_text",
"deprecated": {
"version": "6.7",
"release_date": "2023-04-21"
}
}
],
"category": "methods"

View file

@ -0,0 +1,25 @@
{
"meta": {},
"group": {
"title": "Available methods",
"anchor": "available-methods"
},
"object": {
"anchor": "getmyname",
"name": "getMyName",
"description": "Use this method to get the current bot name for the given user language. Returns BotName on success.",
"html_description": "<p>Use this method to get the current bot name for the given user language. Returns <a href=\"#botname\">BotName</a> on success.</p>",
"rst_description": "Use this method to get the current bot name for the given user language. Returns :class:`aiogram.types.bot_name.BotName` on success.",
"annotations": [
{
"type": "String",
"required": false,
"description": "A two-letter ISO 639-1 language code or an empty string",
"html_description": "<td>A two-letter ISO 639-1 language code or an empty string</td>",
"rst_description": "A two-letter ISO 639-1 language code or an empty string\n",
"name": "language_code"
}
],
"category": "methods"
}
}

View file

@ -14,9 +14,9 @@
{
"type": "Integer",
"required": false,
"description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.",
"html_description": "<td>Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as <a href=\"#getupdates\">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will forgotten.</td>",
"rst_description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will forgotten.\n",
"description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.",
"html_description": "<td>Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as <a href=\"#getupdates\">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will be forgotten.</td>",
"rst_description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will be forgotten.\n",
"name": "offset"
},
{

View file

@ -0,0 +1,33 @@
{
"meta": {},
"group": {
"title": "Available methods",
"anchor": "available-methods"
},
"object": {
"anchor": "setmyname",
"name": "setMyName",
"description": "Use this method to change the bot's name. Returns True on success.",
"html_description": "<p>Use this method to change the bot's name. Returns <em>True</em> on success.</p>",
"rst_description": "Use this method to change the bot's name. Returns :code:`True` on success.",
"annotations": [
{
"type": "String",
"required": false,
"description": "New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.",
"html_description": "<td>New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.</td>",
"rst_description": "New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.\n",
"name": "name"
},
{
"type": "String",
"required": false,
"description": "A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.",
"html_description": "<td>A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.</td>",
"rst_description": "A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.\n",
"name": "language_code"
}
],
"category": "methods"
}
}

View file

@ -1,7 +1,7 @@
{
"api": {
"version": "6.6",
"release_date": "2023-03-09"
"version": "6.7",
"release_date": "2023-04-21"
},
"items": [
{
@ -148,9 +148,9 @@
{
"type": "Integer",
"required": false,
"description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.",
"html_description": "<td>Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as <a href=\"#getupdates\">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will forgotten.</td>",
"rst_description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will forgotten.\n",
"description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.",
"html_description": "<td>Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as <a href=\"#getupdates\">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will be forgotten.</td>",
"rst_description": "Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will be forgotten.\n",
"name": "offset"
},
{
@ -2421,10 +2421,19 @@
{
"anchor": "writeaccessallowed",
"name": "WriteAccessAllowed",
"description": "This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.",
"html_description": "<p>This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.</p>",
"rst_description": "This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.",
"annotations": [],
"description": "This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.",
"html_description": "<p>This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.</p>",
"rst_description": "This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.",
"annotations": [
{
"type": "String",
"description": "Name of the Web App which was launched from a link",
"html_description": "<td><em>Optional</em>. Name of the Web App which was launched from a link</td>",
"rst_description": "*Optional*. Name of the Web App which was launched from a link\n",
"name": "web_app_name",
"required": false
}
],
"category": "types"
},
{
@ -2704,8 +2713,8 @@
"anchor": "keyboardbuttonrequestuser",
"name": "KeyboardButtonRequestUser",
"description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.</p>",
"rst_description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. <a href=\"/bots/features#chat-and-user-selection\">More about requesting users &#187;</a></p>",
"rst_description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. `More about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_",
"annotations": [
{
"type": "Integer",
@ -2738,8 +2747,8 @@
"anchor": "keyboardbuttonrequestchat",
"name": "KeyboardButtonRequestChat",
"description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.</p>",
"rst_description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. <a href=\"/bots/features#chat-and-user-selection\">More about requesting chats &#187;</a></p>",
"rst_description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. `More about requesting chats » <https://core.telegram.org/bots/features#chat-and-user-selection>`_",
"annotations": [
{
"type": "Integer",
@ -2919,9 +2928,9 @@
},
{
"type": "String",
"description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.<br/>\n<br/>\n<strong>Note:</strong> This offers an easy way for users to start using your bot in <a href=\"/bots/inline\">inline mode</a> when they are currently in a private chat with it. Especially useful when combined with <a href=\"#answerinlinequery\"><em>switch_pm&#8230;</em></a> actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\n\n\n**Note:** This offers an easy way for users to start using your bot in `inline mode <https://core.telegram.org/bots/inline>`_ when they are currently in a private chat with it. Especially useful when combined with `https://core.telegram.org/bots/api#answerinlinequery <https://core.telegram.org/bots/api#answerinlinequery>`_ *switch_pm…* actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.\n",
"description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n",
"name": "switch_inline_query",
"required": false
},
@ -2933,6 +2942,14 @@
"name": "switch_inline_query_current_chat",
"required": false
},
{
"type": "SwitchInlineQueryChosenChat",
"description": "If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field\n",
"name": "switch_inline_query_chosen_chat",
"required": false
},
{
"type": "CallbackGame",
"description": "Description of the game that will be launched when the user presses the button.\n\nNOTE: This type of button must always be the first button in the first row.",
@ -2994,6 +3011,56 @@
],
"category": "types"
},
{
"anchor": "switchinlinequerychosenchat",
"name": "SwitchInlineQueryChosenChat",
"description": "This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.",
"html_description": "<p>This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.</p>",
"rst_description": "This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.",
"annotations": [
{
"type": "String",
"description": "The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted",
"html_description": "<td><em>Optional</em>. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted</td>",
"rst_description": "*Optional*. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted\n",
"name": "query",
"required": false
},
{
"type": "Boolean",
"description": "True, if private chats with users can be chosen",
"html_description": "<td><em>Optional</em>. True, if private chats with users can be chosen</td>",
"rst_description": "*Optional*. True, if private chats with users can be chosen\n",
"name": "allow_user_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if private chats with bots can be chosen",
"html_description": "<td><em>Optional</em>. True, if private chats with bots can be chosen</td>",
"rst_description": "*Optional*. True, if private chats with bots can be chosen\n",
"name": "allow_bot_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if group and supergroup chats can be chosen",
"html_description": "<td><em>Optional</em>. True, if group and supergroup chats can be chosen</td>",
"rst_description": "*Optional*. True, if group and supergroup chats can be chosen\n",
"name": "allow_group_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if channel chats can be chosen",
"html_description": "<td><em>Optional</em>. True, if channel chats can be chosen</td>",
"rst_description": "*Optional*. True, if channel chats can be chosen\n",
"name": "allow_channel_chats",
"required": false
}
],
"category": "types"
},
{
"anchor": "callbackquery",
"name": "CallbackQuery",
@ -3807,6 +3874,14 @@
"rst_description": "*Optional*. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.\n",
"name": "invite_link",
"required": false
},
{
"type": "Boolean",
"description": "True, if the user joined the chat via a chat folder invite link",
"html_description": "<td><em>Optional</em>. True, if the user joined the chat via a chat folder invite link</td>",
"rst_description": "*Optional*. True, if the user joined the chat via a chat folder invite link\n",
"name": "via_chat_folder_invite_link",
"required": false
}
],
"category": "types"
@ -4252,6 +4327,24 @@
],
"category": "types"
},
{
"anchor": "botname",
"name": "BotName",
"description": "This object represents the bot's name.",
"html_description": "<p>This object represents the bot's name.</p>",
"rst_description": "This object represents the bot's name.",
"annotations": [
{
"type": "String",
"description": "The bot's name",
"html_description": "<td>The bot's name</td>",
"rst_description": "The bot's name\n",
"name": "name",
"required": true
}
],
"category": "types"
},
{
"anchor": "botdescription",
"name": "BotDescription",
@ -7988,6 +8081,50 @@
],
"category": "methods"
},
{
"anchor": "setmyname",
"name": "setMyName",
"description": "Use this method to change the bot's name. Returns True on success.",
"html_description": "<p>Use this method to change the bot's name. Returns <em>True</em> on success.</p>",
"rst_description": "Use this method to change the bot's name. Returns :code:`True` on success.",
"annotations": [
{
"type": "String",
"required": false,
"description": "New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.",
"html_description": "<td>New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.</td>",
"rst_description": "New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.\n",
"name": "name"
},
{
"type": "String",
"required": false,
"description": "A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.",
"html_description": "<td>A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.</td>",
"rst_description": "A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.\n",
"name": "language_code"
}
],
"category": "methods"
},
{
"anchor": "getmyname",
"name": "getMyName",
"description": "Use this method to get the current bot name for the given user language. Returns BotName on success.",
"html_description": "<p>Use this method to get the current bot name for the given user language. Returns <a href=\"#botname\">BotName</a> on success.</p>",
"rst_description": "Use this method to get the current bot name for the given user language. Returns :class:`aiogram.types.bot_name.BotName` on success.",
"annotations": [
{
"type": "String",
"required": false,
"description": "A two-letter ISO 639-1 language code or an empty string",
"html_description": "<td>A two-letter ISO 639-1 language code or an empty string</td>",
"rst_description": "A two-letter ISO 639-1 language code or an empty string\n",
"name": "language_code"
}
],
"category": "methods"
},
{
"anchor": "setmydescription",
"name": "setMyDescription",
@ -8841,9 +8978,9 @@
"annotations": [
{
"type": "InputFile or String",
"description": "The added sticker. 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. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files",
"html_description": "<td>The added sticker. Pass a <em>file_id</em> 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. Animated and video stickers can't be uploaded via HTTP URL. <a href=\"#sending-files\">More information on Sending Files &#187;</a></td>",
"rst_description": "The added sticker. 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. Animated and video stickers can't be uploaded via HTTP URL. :ref:`More information on Sending Files » <sending-files>`\n",
"description": "The added sticker. 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, upload a new one using multipart/form-data, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files",
"html_description": "<td>The added sticker. Pass a <em>file_id</em> 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, upload a new one using multipart/form-data, or pass &#8220;attach://&lt;file_attach_name&gt;&#8221; to upload a new one using multipart/form-data under &lt;file_attach_name&gt; name. Animated and video stickers can't be uploaded via HTTP URL. <a href=\"#sending-files\">More information on Sending Files &#187;</a></td>",
"rst_description": "The added sticker. 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, upload a new one using multipart/form-data, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. :ref:`More information on Sending Files » <sending-files>`\n",
"name": "sticker",
"required": true
},
@ -9451,9 +9588,9 @@
{
"type": "Boolean",
"required": false,
"description": "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",
"html_description": "<td>Pass <em>True</em> 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</td>",
"rst_description": "Pass :code:`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\n",
"description": "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.",
"html_description": "<td>Pass <em>True</em> 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.</td>",
"rst_description": "Pass :code:`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.\n",
"name": "is_personal"
},
{
@ -9465,24 +9602,50 @@
"name": "next_offset"
},
{
"type": "String",
"type": "InlineQueryResultsButton",
"required": false,
"description": "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",
"html_description": "<td>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 <em>switch_pm_parameter</em></td>",
"rst_description": "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*\n",
"name": "switch_pm_text"
},
{
"type": "String",
"required": false,
"description": "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.\n\nExample: 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.",
"html_description": "<td><a href=\"/bots/features#deep-linking\">Deep-linking</a> parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed.<br/>\n<br/>\n<em>Example:</em> 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 <a href=\"#inlinekeyboardmarkup\"><em>switch_inline</em></a> button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.</td>",
"rst_description": "`Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.\n\n\n\n*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 `https://core.telegram.org/bots/api#inlinekeyboardmarkup <https://core.telegram.org/bots/api#inlinekeyboardmarkup>`_ *switch_inline* button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.\n",
"name": "switch_pm_parameter"
"description": "A JSON-serialized object describing a button to be shown above inline query results",
"html_description": "<td>A JSON-serialized object describing a button to be shown above inline query results</td>",
"rst_description": "A JSON-serialized object describing a button to be shown above inline query results\n",
"name": "button"
}
],
"category": "methods"
},
{
"anchor": "inlinequeryresultsbutton",
"name": "InlineQueryResultsButton",
"description": "This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.",
"html_description": "<p>This object represents a button to be shown above inline query results. You <strong>must</strong> use exactly one of the optional fields.</p>",
"rst_description": "This object represents a button to be shown above inline query results. You **must** use exactly one of the optional fields.",
"annotations": [
{
"type": "String",
"description": "Label text on the button",
"html_description": "<td>Label text on the button</td>",
"rst_description": "Label text on the button\n",
"name": "text",
"required": true
},
{
"type": "WebAppInfo",
"description": "Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery inside the Web App.",
"html_description": "<td><em>Optional</em>. Description of the <a href=\"/bots/webapps\">Web App</a> that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method <a href=\"/bots/webapps#initializing-web-apps\">switchInlineQuery</a> inside the Web App.</td>",
"rst_description": "*Optional*. Description of the `Web App <https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method `switchInlineQuery <https://core.telegram.org/bots/webapps#initializing-web-apps>`_ inside the Web App.\n",
"name": "web_app",
"required": false
},
{
"type": "String",
"description": "Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.\n\nExample: 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.",
"html_description": "<td><em>Optional</em>. <a href=\"/bots/features#deep-linking\">Deep-linking</a> parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed.<br/>\n<br/>\n<em>Example:</em> 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 <a href=\"#inlinekeyboardmarkup\"><em>switch_inline</em></a> button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.</td>",
"rst_description": "*Optional*. `Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.\n\n\n\n*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 `https://core.telegram.org/bots/api#inlinekeyboardmarkup <https://core.telegram.org/bots/api#inlinekeyboardmarkup>`_ *switch_inline* button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.\n",
"name": "start_parameter",
"required": false
}
],
"category": "types"
},
{
"anchor": "inlinequeryresult",
"name": "InlineQueryResult",

View file

@ -8,6 +8,7 @@ Returns: :obj:`{{ object.returning.parsed_type|type }}`
:members:
:member-order: bysource
:undoc-members: True
:exclude-members: model_config,model_fields
Usage

View file

@ -7,3 +7,4 @@
:members:
:member-order: bysource
:undoc-members: True
:exclude-members: model_config,model_fields

View file

@ -0,0 +1 @@
discriminator: "type"

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -1,2 +0,0 @@
bases:
- BotCommandScope

View file

@ -0,0 +1,25 @@
{
"meta": {},
"group": {
"title": "Available types",
"anchor": "available-types"
},
"object": {
"anchor": "botname",
"name": "BotName",
"description": "This object represents the bot's name.",
"html_description": "<p>This object represents the bot's name.</p>",
"rst_description": "This object represents the bot's name.",
"annotations": [
{
"type": "String",
"description": "The bot's name",
"html_description": "<td>The bot's name</td>",
"rst_description": "The bot's name\n",
"name": "name",
"required": true
}
],
"category": "types"
}
}

View file

@ -1,27 +0,0 @@
define:
- type: "String"
description: "The member's status in the chat"
html_description: "<td>The member's status in the chat</td>"
rst_description: "The member's status in the chat"
name: "status"
required: true
clone:
- ChatMemberOwner:
exclude:
- status
- ChatMemberAdministrator:
exclude:
- status
- ChatMemberMember:
exclude:
- status
- ChatMemberRestricted:
exclude:
- status
- ChatMemberLeft:
exclude:
- status
- ChatMemberBanned:
exclude:
- status

View file

@ -0,0 +1 @@
discriminator: "status"

View file

@ -1,2 +0,0 @@
bases:
- ChatMember

View file

@ -1,5 +1,3 @@
bases:
- ChatMember
annotations:
until_date:
parsed_type:

View file

@ -1,2 +0,0 @@
bases:
- ChatMember

View file

@ -1,2 +0,0 @@
bases:
- ChatMember

View file

@ -1,2 +0,0 @@
bases:
- ChatMember

View file

@ -1,5 +1,3 @@
bases:
- ChatMember
annotations:
until_date:
parsed_type:

View file

@ -58,6 +58,14 @@
"rst_description": "*Optional*. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.\n",
"name": "invite_link",
"required": false
},
{
"type": "Boolean",
"description": "True, if the user joined the chat via a chat folder invite link",
"html_description": "<td><em>Optional</em>. True, if the user joined the chat via a chat folder invite link</td>",
"rst_description": "*Optional*. True, if the user joined the chat via a chat folder invite link\n",
"name": "via_chat_folder_invite_link",
"required": false
}
],
"category": "types"

View file

@ -3,32 +3,3 @@ annotations:
parsed_type:
type: std
name: datetime.datetime
old_chat_member: &chat-member-type
parsed_type:
type: union
items:
- type: entity
references:
category: types
name: ChatMemberOwner
- type: entity
references:
category: types
name: ChatMemberAdministrator
- type: entity
references:
category: types
name: ChatMemberMember
- type: entity
references:
category: types
name: ChatMemberRestricted
- type: entity
references:
category: types
name: ChatMemberLeft
- type: entity
references:
category: types
name: ChatMemberBanned
new_chat_member: *chat-member-type

View file

@ -53,9 +53,9 @@
},
{
"type": "String",
"description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\nNote: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.<br/>\n<br/>\n<strong>Note:</strong> This offers an easy way for users to start using your bot in <a href=\"/bots/inline\">inline mode</a> when they are currently in a private chat with it. Especially useful when combined with <a href=\"#answerinlinequery\"><em>switch_pm&#8230;</em></a> actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n\n\n\n**Note:** This offers an easy way for users to start using your bot in `inline mode <https://core.telegram.org/bots/inline>`_ when they are currently in a private chat with it. Especially useful when combined with `https://core.telegram.org/bots/api#answerinlinequery <https://core.telegram.org/bots/api#answerinlinequery>`_ *switch_pm…* actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.\n",
"description": "If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.\n",
"name": "switch_inline_query",
"required": false
},
@ -67,6 +67,14 @@
"name": "switch_inline_query_current_chat",
"required": false
},
{
"type": "SwitchInlineQueryChosenChat",
"description": "If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field",
"html_description": "<td><em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field</td>",
"rst_description": "*Optional*. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field\n",
"name": "switch_inline_query_chosen_chat",
"required": false
},
{
"type": "CallbackGame",
"description": "Description of the game that will be launched when the user presses the button.\n\nNOTE: This type of button must always be the first button in the first row.",

View file

@ -0,0 +1 @@
discriminator: "type"

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InlineQueryResult

View file

@ -1,6 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,5 +1,3 @@
bases:
- InlineQueryResult
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -0,0 +1,41 @@
{
"meta": {},
"group": {
"title": "Inline mode",
"anchor": "inline-mode"
},
"object": {
"anchor": "inlinequeryresultsbutton",
"name": "InlineQueryResultsButton",
"description": "This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.",
"html_description": "<p>This object represents a button to be shown above inline query results. You <strong>must</strong> use exactly one of the optional fields.</p>",
"rst_description": "This object represents a button to be shown above inline query results. You **must** use exactly one of the optional fields.",
"annotations": [
{
"type": "String",
"description": "Label text on the button",
"html_description": "<td>Label text on the button</td>",
"rst_description": "Label text on the button\n",
"name": "text",
"required": true
},
{
"type": "WebAppInfo",
"description": "Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery inside the Web App.",
"html_description": "<td><em>Optional</em>. Description of the <a href=\"/bots/webapps\">Web App</a> that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method <a href=\"/bots/webapps#initializing-web-apps\">switchInlineQuery</a> inside the Web App.</td>",
"rst_description": "*Optional*. Description of the `Web App <https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method `switchInlineQuery <https://core.telegram.org/bots/webapps#initializing-web-apps>`_ inside the Web App.\n",
"name": "web_app",
"required": false
},
{
"type": "String",
"description": "Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.\n\nExample: 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.",
"html_description": "<td><em>Optional</em>. <a href=\"/bots/features#deep-linking\">Deep-linking</a> parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed.<br/>\n<br/>\n<em>Example:</em> 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 <a href=\"#inlinekeyboardmarkup\"><em>switch_inline</em></a> button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.</td>",
"rst_description": "*Optional*. `Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.\n\n\n\n*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 `https://core.telegram.org/bots/api#inlinekeyboardmarkup <https://core.telegram.org/bots/api#inlinekeyboardmarkup>`_ *switch_inline* button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.\n",
"name": "start_parameter",
"required": false
}
],
"category": "types"
}
}

View file

@ -1,2 +0,0 @@
bases:
- InputMessageContent

View file

@ -1,2 +0,0 @@
bases:
- InputMessageContent

View file

@ -1,2 +0,0 @@
bases:
- InputMessageContent

View file

@ -0,0 +1 @@
discriminator: "type"

View file

@ -1,5 +1,3 @@
bases:
- InputMedia
annotations:
media:
parsed_type:

View file

@ -1,5 +1,3 @@
bases:
- InputMedia
annotations:
media:
parsed_type:

View file

@ -1,5 +1,3 @@
bases:
- InputMedia
annotations:
media:
parsed_type:

View file

@ -1,5 +1,3 @@
bases:
- InputMedia
annotations:
media:
parsed_type:

View file

@ -1,5 +1,3 @@
bases:
- InputMedia
annotations:
media:
parsed_type:

View file

@ -0,0 +1 @@
{ }

View file

@ -13,9 +13,9 @@
"annotations": [
{
"type": "InputFile or String",
"description": "The added sticker. 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. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files",
"html_description": "<td>The added sticker. Pass a <em>file_id</em> 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. Animated and video stickers can't be uploaded via HTTP URL. <a href=\"#sending-files\">More information on Sending Files &#187;</a></td>",
"rst_description": "The added sticker. 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. Animated and video stickers can't be uploaded via HTTP URL. :ref:`More information on Sending Files » <sending-files>`\n",
"description": "The added sticker. 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, upload a new one using multipart/form-data, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files",
"html_description": "<td>The added sticker. Pass a <em>file_id</em> 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, upload a new one using multipart/form-data, or pass &#8220;attach://&lt;file_attach_name&gt;&#8221; to upload a new one using multipart/form-data under &lt;file_attach_name&gt; name. Animated and video stickers can't be uploaded via HTTP URL. <a href=\"#sending-files\">More information on Sending Files &#187;</a></td>",
"rst_description": "The added sticker. 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, upload a new one using multipart/form-data, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. :ref:`More information on Sending Files » <sending-files>`\n",
"name": "sticker",
"required": true
},

View file

@ -1,6 +1,3 @@
bases:
- InputMessageContent
annotations:
parse_mode:
value: UNSET_PARSE_MODE

View file

@ -1,2 +0,0 @@
bases:
- InputMessageContent

View file

@ -8,8 +8,8 @@
"anchor": "keyboardbuttonrequestchat",
"name": "KeyboardButtonRequestChat",
"description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.</p>",
"rst_description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. <a href=\"/bots/features#chat-and-user-selection\">More about requesting chats &#187;</a></p>",
"rst_description": "This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. `More about requesting chats » <https://core.telegram.org/bots/features#chat-and-user-selection>`_",
"annotations": [
{
"type": "Integer",

View file

@ -8,8 +8,8 @@
"anchor": "keyboardbuttonrequestuser",
"name": "KeyboardButtonRequestUser",
"description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.</p>",
"rst_description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.",
"html_description": "<p>This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. <a href=\"/bots/features#chat-and-user-selection\">More about requesting users &#187;</a></p>",
"rst_description": "This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. `More about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_",
"annotations": [
{
"type": "Integer",

View file

@ -0,0 +1 @@
discriminator: "type"

View file

@ -1,2 +0,0 @@
bases:
- MenuButton

View file

@ -1,2 +0,0 @@
bases:
- MenuButton

View file

@ -1,2 +0,0 @@
bases:
- MenuButton

View file

@ -0,0 +1 @@
discriminator: "source"

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -1,2 +0,0 @@
bases:
- PassportElementError

View file

@ -0,0 +1,57 @@
{
"meta": {},
"group": {
"title": "Available types",
"anchor": "available-types"
},
"object": {
"anchor": "switchinlinequerychosenchat",
"name": "SwitchInlineQueryChosenChat",
"description": "This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.",
"html_description": "<p>This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.</p>",
"rst_description": "This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.",
"annotations": [
{
"type": "String",
"description": "The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted",
"html_description": "<td><em>Optional</em>. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted</td>",
"rst_description": "*Optional*. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted\n",
"name": "query",
"required": false
},
{
"type": "Boolean",
"description": "True, if private chats with users can be chosen",
"html_description": "<td><em>Optional</em>. True, if private chats with users can be chosen</td>",
"rst_description": "*Optional*. True, if private chats with users can be chosen\n",
"name": "allow_user_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if private chats with bots can be chosen",
"html_description": "<td><em>Optional</em>. True, if private chats with bots can be chosen</td>",
"rst_description": "*Optional*. True, if private chats with bots can be chosen\n",
"name": "allow_bot_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if group and supergroup chats can be chosen",
"html_description": "<td><em>Optional</em>. True, if group and supergroup chats can be chosen</td>",
"rst_description": "*Optional*. True, if group and supergroup chats can be chosen\n",
"name": "allow_group_chats",
"required": false
},
{
"type": "Boolean",
"description": "True, if channel chats can be chosen",
"html_description": "<td><em>Optional</em>. True, if channel chats can be chosen</td>",
"rst_description": "*Optional*. True, if channel chats can be chosen\n",
"name": "allow_channel_chats",
"required": false
}
],
"category": "types"
}
}

View file

@ -7,10 +7,19 @@
"object": {
"anchor": "writeaccessallowed",
"name": "WriteAccessAllowed",
"description": "This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.",
"html_description": "<p>This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.</p>",
"rst_description": "This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.",
"annotations": [],
"description": "This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.",
"html_description": "<p>This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.</p>",
"rst_description": "This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.",
"annotations": [
{
"type": "String",
"description": "Name of the Web App which was launched from a link",
"html_description": "<td><em>Optional</em>. Name of the Web App which was launched from a link</td>",
"rst_description": "*Optional*. Name of the Web App which was launched from a link\n",
"name": "web_app_name",
"required": false
}
],
"category": "types"
}
}

2
.github/FUNDING.yml vendored
View file

@ -1,2 +1,2 @@
open_collective: aiogram
patreon: aiogram

View file

@ -12,14 +12,21 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Install build dependencies
run: python -m pip install --upgrade build
- name: Resolve version
id: package-version
run: echo "value=$(echo ${{ github.ref }} | sed -e 's/refs\/tags\/v//')" >> $GITHUB_OUTPUT
# - name: Bump version
# run: hatch version ${{ steps.package-version.outputs.value }}
- name: Build source distribution
run: python -m build .
@ -40,8 +47,12 @@ jobs:
publish:
name: Publish
needs: build
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/aiogram/${{ steps.package-version.outputs.value }}/
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v1
@ -49,17 +60,5 @@ jobs:
name: dist
path: dist
# - name: Publish a Python distribution to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
## if: github.event.action != 'published'
# with:
# user: __token__
# password: ${{ secrets.PYPI_TEST_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
# if: github.event.action == 'published'
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1

View file

@ -16,6 +16,136 @@ Changelog
.. towncrier release notes start
3.0.0b8 (2023-07-17)
=====================
Features
--------
- Added possibility to use custom events in routers (If router does not support custom event it does not break and passes it to included routers).
`#1147 <https://github.com/aiogram/aiogram/issues/1147>`_
- Added support for FSM in Forum topics.
The strategy can be changed in dispatcher:
.. code-block:: python
from aiogram.fsm.strategy import FSMStrategy
...
dispatcher = Dispatcher(
fsm_strategy=FSMStrategy.USER_IN_TOPIC,
storage=..., # Any persistent storage
)
.. note::
If you have implemented you own storages you should extend record key generation
with new one attribute - :code:`thread_id`
`#1161 <https://github.com/aiogram/aiogram/issues/1161>`_
- Improved CallbackData serialization.
- Minimized UUID (hex without dashes)
- Replaced bool values with int (true=1, false=0)
`#1163 <https://github.com/aiogram/aiogram/issues/1163>`_
- Added a tool to make text formatting flexible and easy.
More details on the :ref:`corresponding documentation page <formatting-tool>`
`#1172 <https://github.com/aiogram/aiogram/issues/1172>`_
- Added :code:`X-Telegram-Bot-Api-Secret-Token` header check
`#1173 <https://github.com/aiogram/aiogram/issues/1173>`_
- Made :code:`allowed_updates` list to revolve automatically in start_polling method if not set explicitly.
`#1178 <https://github.com/aiogram/aiogram/issues/1178>`_
- Added possibility to pass custom headers to :class:`URLInputFile` object
`#1191 <https://github.com/aiogram/aiogram/issues/1191>`_
Bugfixes
--------
- Change type of result in InlineQueryResult enum for :code:`InlineQueryResultCachedMpeg4Gif`
and :code:`InlineQueryResultMpeg4Gif` to more correct according to documentation.
Change regexp for entities parsing to more correct (:code:`InlineQueryResultType.yml`).
`#1146 <https://github.com/aiogram/aiogram/issues/1146>`_
- Fixed signature of startup/shutdown events to include the :code:`**dispatcher.workflow_data` as the handler arguments.
`#1155 <https://github.com/aiogram/aiogram/issues/1155>`_
- Added missing :code:`FORUM_TOPIC_EDITED` value to content_type property
`#1160 <https://github.com/aiogram/aiogram/issues/1160>`_
- Fixed compatibility with Python 3.8-3.9 (from previous release)
`#1162 <https://github.com/aiogram/aiogram/issues/1162>`_
- Fixed the markdown spoiler parser.
`#1176 <https://github.com/aiogram/aiogram/issues/1176>`_
- Fixed workflow data propagation
`#1196 <https://github.com/aiogram/aiogram/issues/1196>`_
- Fixed the serialization error associated with nested subtypes
like InputMedia, ChatMember, etc.
The previously generated code resulted in an invalid schema under pydantic v2,
which has stricter type parsing.
Hence, subtypes without the specification of all subtype unions were generating
an empty object. This has been rectified now.
`#1213 <https://github.com/aiogram/aiogram/issues/1213>`_
Improved Documentation
----------------------
- Changed small grammar typos for :code:`upload_file`
`#1133 <https://github.com/aiogram/aiogram/issues/1133>`_
Deprecations and Removals
-------------------------
- Removed text filter in due to is planned to remove this filter few versions ago.
Use :code:`F.text` instead
`#1170 <https://github.com/aiogram/aiogram/issues/1170>`_
Misc
----
- Added full support of `Bot API 6.6 <https://core.telegram.org/bots/api-changelog#march-9-2023>`_
.. danger::
Note that this issue has breaking changes described in in the Bot API changelog,
this changes is not breaking in the API but breaking inside aiogram because
Beta stage is not finished.
`#1139 <https://github.com/aiogram/aiogram/issues/1139>`_
- Added full support of `Bot API 6.7 <https://core.telegram.org/bots/api-changelog#april-21-2023>`_
.. warning::
Note that arguments *switch_pm_parameter* and *switch_pm_text* was deprecated
and should be changed to *button* argument as described in API docs.
`#1168 <https://github.com/aiogram/aiogram/issues/1168>`_
- Updated `Pydantic to V2 <https://docs.pydantic.dev/2.0/migration/>`_
.. warning::
Be careful, not all libraries is already updated to using V2
`#1202 <https://github.com/aiogram/aiogram/issues/1202>`_
- Added global defaults :code:`disable_web_page_preview` and :code:`protect_content` in addition to :code:`parse_mode` to the Bot instance,
reworked internal request builder mechanism.
`#1142 <https://github.com/aiogram/aiogram/issues/1142>`_
- Removed bot parameters from storages
`#1144 <https://github.com/aiogram/aiogram/issues/1144>`_
- Replaced ContextVar's with a new feature called `Validation Context <https://docs.pydantic.dev/latest/usage/validators/#validation-context>`_
in Pydantic to improve the clarity, usability, and versatility of handling the Bot instance within method shortcuts.
.. danger::
**Breaking**: The 'bot' argument now is required in `URLInputFile`
`#1210 <https://github.com/aiogram/aiogram/issues/1210>`_
- Updated magic-filter with new features
- Added hint for :code:`len(F)` error
- Added not in operation
`#1221 <https://github.com/aiogram/aiogram/issues/1221>`_
3.0.0b7 (2023-02-18)
=====================

View file

@ -1 +0,0 @@
Changed small grammar typos for `upload_file`

View file

@ -1,7 +0,0 @@
Added full support of `Bot API 6.6 <https://core.telegram.org/bots/api-changelog#march-9-2023>`_
.. danger::
Note that this issue has breaking changes described in in the Bot API changelog,
this changes is not breaking in the API but breaking inside aiogram because
Beta stage is not finished.

View file

@ -1,2 +0,0 @@
Added global defaults `disable_web_page_preview` and `protect_content` in addition to `parse_mode` to the Bot instance,
reworked internal request builder mechanism.

2
CHANGES/1230.removal.rst Normal file
View file

@ -0,0 +1,2 @@
Removed the use of the context instance (Bot.get_current) from all placements that were used previously.
This is to avoid the use of the context instance in the wrong place.

View file

@ -1 +1 @@
Please read the [Contributing](https://docs.aiogram.dev/en/dev-3.x/contributing/) guidelines in the documentation site.
Please read the [Contributing](https://docs.aiogram.dev/en/dev-3.x/contributing.html) guidelines in the documentation site.

View file

@ -63,7 +63,7 @@ Features
- Asynchronous (`asyncio docs <https://docs.python.org/3/library/asyncio.html>`_, :pep:`492`)
- Has type hints (:pep:`484`) and can be used with `mypy <http://mypy-lang.org/>`_
- Supports `PyPy <https://www.pypy.org/>`_
- Supports `Telegram Bot API 6.6 <https://core.telegram.org/bots/api>`_ and gets fast updates to the latest versions of the Bot API
- Supports `Telegram Bot API 6.7 <https://core.telegram.org/bots/api>`_ and gets fast updates to the latest versions of the Bot API
- Telegram Bot API integration code was `autogenerated <https://github.com/aiogram/tg-codegen>`_ and can be easily re-generated when API gets updated
- Updates router (Blueprints)
- Has Finite State Machine

View file

@ -3,6 +3,7 @@ from contextlib import suppress
from aiogram.dispatcher.flags import FlagGenerator
from . import enums, methods, types
from .__meta__ import __api_version__, __version__
from .client import session
from .client.bot import Bot
from .dispatcher.dispatcher import Dispatcher
@ -36,6 +37,3 @@ __all__ = (
"md",
"flags",
)
__version__ = "3.0.0b8"
__api_version__ = "6.6"

2
aiogram/__meta__.py Normal file
View file

@ -0,0 +1,2 @@
__version__ = "3.0.0b9"
__api_version__ = "6.7"

View file

@ -71,6 +71,7 @@ from ..methods import (
GetMyCommands,
GetMyDefaultAdministratorRights,
GetMyDescription,
GetMyName,
GetMyShortDescription,
GetStickerSet,
GetUpdates,
@ -115,6 +116,7 @@ from ..methods import (
SetMyCommands,
SetMyDefaultAdministratorRights,
SetMyDescription,
SetMyName,
SetMyShortDescription,
SetPassportDataErrors,
SetStickerEmojiList,
@ -138,8 +140,15 @@ from ..methods import (
from ..types import (
UNSET_PARSE_MODE,
BotCommand,
BotCommandScope,
BotCommandScopeAllChatAdministrators,
BotCommandScopeAllGroupChats,
BotCommandScopeAllPrivateChats,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
BotCommandScopeDefault,
BotDescription,
BotName,
BotShortDescription,
Chat,
ChatAdministratorRights,
@ -157,9 +166,29 @@ from ..types import (
ForumTopic,
GameHighScore,
InlineKeyboardMarkup,
InlineQueryResult,
InlineQueryResultArticle,
InlineQueryResultAudio,
InlineQueryResultCachedAudio,
InlineQueryResultCachedDocument,
InlineQueryResultCachedGif,
InlineQueryResultCachedMpeg4Gif,
InlineQueryResultCachedPhoto,
InlineQueryResultCachedSticker,
InlineQueryResultCachedVideo,
InlineQueryResultCachedVoice,
InlineQueryResultContact,
InlineQueryResultDocument,
InlineQueryResultGame,
InlineQueryResultGif,
InlineQueryResultLocation,
InlineQueryResultMpeg4Gif,
InlineQueryResultPhoto,
InlineQueryResultsButton,
InlineQueryResultVenue,
InlineQueryResultVideo,
InlineQueryResultVoice,
InputFile,
InputMedia,
InputMediaAnimation,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
@ -173,7 +202,15 @@ from ..types import (
Message,
MessageEntity,
MessageId,
PassportElementError,
PassportElementErrorDataField,
PassportElementErrorFile,
PassportElementErrorFiles,
PassportElementErrorFrontSide,
PassportElementErrorReverseSide,
PassportElementErrorSelfie,
PassportElementErrorTranslationFile,
PassportElementErrorTranslationFiles,
PassportElementErrorUnspecified,
Poll,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
@ -193,7 +230,7 @@ from .session.base import BaseSession
T = TypeVar("T")
class Bot(ContextInstanceMixin["Bot"]):
class Bot:
def __init__(
self,
token: str,
@ -247,16 +284,14 @@ class Bot(ContextInstanceMixin["Bot"]):
"""
Generate bot context
:param auto_close:
:param auto_close: close session on exit
:return:
"""
token = self.set_current(self)
try:
yield self
finally:
if auto_close:
await self.session.close()
self.reset_current(token)
async def me(self) -> User:
"""
@ -477,12 +512,36 @@ class Bot(ContextInstanceMixin["Bot"]):
async def answer_inline_query(
self,
inline_query_id: str,
results: List[InlineQueryResult],
results: List[
Union[
InlineQueryResultCachedAudio,
InlineQueryResultCachedDocument,
InlineQueryResultCachedGif,
InlineQueryResultCachedMpeg4Gif,
InlineQueryResultCachedPhoto,
InlineQueryResultCachedSticker,
InlineQueryResultCachedVideo,
InlineQueryResultCachedVoice,
InlineQueryResultArticle,
InlineQueryResultAudio,
InlineQueryResultContact,
InlineQueryResultGame,
InlineQueryResultDocument,
InlineQueryResultGif,
InlineQueryResultLocation,
InlineQueryResultMpeg4Gif,
InlineQueryResultPhoto,
InlineQueryResultVenue,
InlineQueryResultVideo,
InlineQueryResultVoice,
]
],
cache_time: Optional[int] = None,
is_personal: Optional[bool] = None,
next_offset: Optional[str] = None,
switch_pm_text: Optional[str] = None,
button: Optional[InlineQueryResultsButton] = None,
switch_pm_parameter: Optional[str] = None,
switch_pm_text: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
@ -495,10 +554,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param inline_query_id: Unique identifier for the answered query
:param results: A JSON-serialized array of results for the inline query
:param cache_time: The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
:param is_personal: Pass :code:`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
:param is_personal: Pass :code:`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.
:param next_offset: 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.
:param switch_pm_text: 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*
:param button: A JSON-serialized object describing a button to be shown above inline query results
:param switch_pm_parameter: `Deep-linking <https://core.telegram.org/bots/features#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.
:param switch_pm_text: 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*
:param request_timeout: Request timeout
:return: On success, :code:`True` is returned.
"""
@ -509,8 +569,9 @@ class Bot(ContextInstanceMixin["Bot"]):
cache_time=cache_time,
is_personal=is_personal,
next_offset=next_offset,
switch_pm_text=switch_pm_text,
button=button,
switch_pm_parameter=switch_pm_parameter,
switch_pm_text=switch_pm_text,
)
return await self(call, request_timeout=request_timeout)
@ -572,7 +633,28 @@ class Bot(ContextInstanceMixin["Bot"]):
async def answer_web_app_query(
self,
web_app_query_id: str,
result: InlineQueryResult,
result: Union[
InlineQueryResultCachedAudio,
InlineQueryResultCachedDocument,
InlineQueryResultCachedGif,
InlineQueryResultCachedMpeg4Gif,
InlineQueryResultCachedPhoto,
InlineQueryResultCachedSticker,
InlineQueryResultCachedVideo,
InlineQueryResultCachedVoice,
InlineQueryResultArticle,
InlineQueryResultAudio,
InlineQueryResultContact,
InlineQueryResultGame,
InlineQueryResultDocument,
InlineQueryResultGif,
InlineQueryResultLocation,
InlineQueryResultMpeg4Gif,
InlineQueryResultPhoto,
InlineQueryResultVenue,
InlineQueryResultVideo,
InlineQueryResultVoice,
],
request_timeout: Optional[int] = None,
) -> SentWebAppMessage:
"""
@ -1066,7 +1148,17 @@ class Bot(ContextInstanceMixin["Bot"]):
async def delete_my_commands(
self,
scope: Optional[BotCommandScope] = None,
scope: Optional[
Union[
BotCommandScopeDefault,
BotCommandScopeAllPrivateChats,
BotCommandScopeAllGroupChats,
BotCommandScopeAllChatAdministrators,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
]
] = None,
language_code: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
@ -1275,7 +1367,13 @@ class Bot(ContextInstanceMixin["Bot"]):
async def edit_message_media(
self,
media: InputMedia,
media: Union[
InputMediaAnimation,
InputMediaDocument,
InputMediaAudio,
InputMediaPhoto,
InputMediaVideo,
],
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
@ -1657,7 +1755,17 @@ class Bot(ContextInstanceMixin["Bot"]):
async def get_my_commands(
self,
scope: Optional[BotCommandScope] = None,
scope: Optional[
Union[
BotCommandScopeDefault,
BotCommandScopeAllPrivateChats,
BotCommandScopeAllGroupChats,
BotCommandScopeAllChatAdministrators,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
]
] = None,
language_code: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> List[BotCommand]:
@ -1737,7 +1845,7 @@ class Bot(ContextInstanceMixin["Bot"]):
Source: https://core.telegram.org/bots/api#getupdates
:param offset: Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will forgotten.
:param offset: Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as :class:`aiogram.methods.get_updates.GetUpdates` is called with an *offset* higher than its *update_id*. The negative offset can be specified to retrieve updates starting from *-offset* update from the end of the updates queue. All previous updates will be forgotten.
:param limit: Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
:param timeout: Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
:param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify ['message', 'edited_channel_post', 'callback_query'] to only receive updates of these types. See :class:`aiogram.types.update.Update` for a complete list of available update types. Specify an empty list to receive all update types except *chat_member* (default). If not specified, the previous setting will be used.
@ -3070,7 +3178,7 @@ class Bot(ContextInstanceMixin["Bot"]):
self,
chat_id: Optional[int] = None,
menu_button: Optional[
Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]
Union[MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault]
] = None,
request_timeout: Optional[int] = None,
) -> bool:
@ -3227,7 +3335,17 @@ class Bot(ContextInstanceMixin["Bot"]):
async def set_my_commands(
self,
commands: List[BotCommand],
scope: Optional[BotCommandScope] = None,
scope: Optional[
Union[
BotCommandScopeDefault,
BotCommandScopeAllPrivateChats,
BotCommandScopeAllGroupChats,
BotCommandScopeAllChatAdministrators,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
]
] = None,
language_code: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
@ -3276,7 +3394,19 @@ class Bot(ContextInstanceMixin["Bot"]):
async def set_passport_data_errors(
self,
user_id: int,
errors: List[PassportElementError],
errors: List[
Union[
PassportElementErrorDataField,
PassportElementErrorFrontSide,
PassportElementErrorReverseSide,
PassportElementErrorSelfie,
PassportElementErrorFile,
PassportElementErrorFiles,
PassportElementErrorTranslationFile,
PassportElementErrorTranslationFiles,
PassportElementErrorUnspecified,
]
],
request_timeout: Optional[int] = None,
) -> bool:
"""
@ -3913,3 +4043,46 @@ class Bot(ContextInstanceMixin["Bot"]):
title=title,
)
return await self(call, request_timeout=request_timeout)
async def get_my_name(
self,
language_code: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> BotName:
"""
Use this method to get the current bot name for the given user language. Returns :class:`aiogram.types.bot_name.BotName` on success.
Source: https://core.telegram.org/bots/api#getmyname
:param language_code: A two-letter ISO 639-1 language code or an empty string
:param request_timeout: Request timeout
:return: Returns :class:`aiogram.types.bot_name.BotName` on success.
"""
call = GetMyName(
language_code=language_code,
)
return await self(call, request_timeout=request_timeout)
async def set_my_name(
self,
name: Optional[str] = None,
language_code: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to change the bot's name. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setmyname
:param name: New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
:param language_code: A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetMyName(
name=name,
language_code=language_code,
)
return await self(call, request_timeout=request_timeout)

View file

@ -0,0 +1,33 @@
from typing import TYPE_CHECKING, Any, Optional
from pydantic import BaseModel, PrivateAttr
from typing_extensions import Self
if TYPE_CHECKING:
from aiogram.client.bot import Bot
class BotContextController(BaseModel):
_bot: Optional["Bot"] = PrivateAttr()
def model_post_init(self, __context: Any) -> None:
self._bot = __context.get("bot") if __context else None
def as_(self, bot: Optional["Bot"]) -> Self:
"""
Bind object to a bot instance.
:param bot: Bot instance
:return: self
"""
self._bot = bot
return self
@property
def bot(self) -> Optional["Bot"]:
"""
Get bot instance.
:return: Bot instance
"""
return self._bot

View file

@ -18,7 +18,10 @@ from typing import (
import certifi
from aiohttp import BasicAuth, ClientError, ClientSession, FormData, TCPConnector
from aiohttp.hdrs import USER_AGENT
from aiohttp.http import SERVER_SOFTWARE
from aiogram.__meta__ import __version__
from aiogram.methods import TelegramMethod
from ...exceptions import TelegramNetworkError
@ -121,7 +124,12 @@ class AiohttpSession(BaseSession):
await self.close()
if self._session is None or self._session.closed:
self._session = ClientSession(connector=self._connector_type(**self._connector_init))
self._session = ClientSession(
connector=self._connector_type(**self._connector_init),
headers={
USER_AGENT: f"{SERVER_SOFTWARE} aiogram/{__version__}",
},
)
self._should_reset_connector = False
return self._session
@ -133,7 +141,7 @@ class AiohttpSession(BaseSession):
def build_form_data(self, bot: Bot, method: TelegramMethod[TelegramType]) -> FormData:
form = FormData(quote_fields=False)
files: Dict[str, InputFile] = {}
for key, value in method.dict().items():
for key, value in method.model_dump(warnings=False).items():
value = self.prepare_value(value, bot=bot, files=files)
if not value:
continue
@ -159,15 +167,27 @@ class AiohttpSession(BaseSession):
raise TelegramNetworkError(method=method, message="Request timeout error")
except ClientError as e:
raise TelegramNetworkError(method=method, message=f"{type(e).__name__}: {e}")
response = self.check_response(method=method, status_code=resp.status, content=raw_result)
response = self.check_response(
bot=bot, method=method, status_code=resp.status, content=raw_result
)
return cast(TelegramType, response.result)
async def stream_content(
self, url: str, timeout: int, chunk_size: int, raise_for_status: bool
self,
url: str,
headers: Optional[Dict[str, Any]] = None,
timeout: int = 30,
chunk_size: int = 65536,
raise_for_status: bool = True,
) -> AsyncGenerator[bytes, None]:
if headers is None:
headers = {}
session = await self.create_session()
async with session.get(url, timeout=timeout, raise_for_status=raise_for_status) as resp:
async with session.get(
url, timeout=timeout, headers=headers, raise_for_status=raise_for_status
) as resp:
async for chunk in resp.content.iter_chunked(chunk_size):
yield chunk

View file

@ -75,7 +75,7 @@ class BaseSession(abc.ABC):
self.middleware = RequestMiddlewareManager()
def check_response(
self, method: TelegramMethod[TelegramType], status_code: int, content: str
self, bot: Bot, method: TelegramMethod[TelegramType], status_code: int, content: str
) -> Response[TelegramType]:
"""
Check response status
@ -89,7 +89,8 @@ class BaseSession(abc.ABC):
raise ClientDecodeError("Failed to decode object", e, content)
try:
response = method.build_response(json_data)
response_type = Response[method.__returning__] # type: ignore
response = response_type.model_validate(json_data, context={"bot": bot})
except ValidationError as e:
raise ClientDecodeError("Failed to deserialize object", e, json_data)
@ -158,7 +159,12 @@ class BaseSession(abc.ABC):
@abc.abstractmethod
async def stream_content(
self, url: str, timeout: int, chunk_size: int, raise_for_status: bool
self,
url: str,
headers: Optional[Dict[str, Any]] = None,
timeout: int = 30,
chunk_size: int = 65536,
raise_for_status: bool = True,
) -> AsyncGenerator[bytes, None]: # pragma: no cover
"""
Stream reader

View file

@ -1,7 +1,7 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Awaitable, Callable, Union
from typing import TYPE_CHECKING, Protocol
from aiogram.methods import Response, TelegramMethod
from aiogram.methods.base import TelegramType
@ -9,16 +9,24 @@ from aiogram.methods.base import TelegramType
if TYPE_CHECKING:
from ...bot import Bot
NextRequestMiddlewareType = Callable[
["Bot", TelegramMethod[TelegramType]], Awaitable[Response[TelegramType]]
]
RequestMiddlewareType = Union[
"BaseRequestMiddleware",
Callable[
[NextRequestMiddlewareType[TelegramType], "Bot", TelegramMethod[TelegramType]],
Awaitable[Response[TelegramType]],
],
]
class NextRequestMiddlewareType(Protocol[TelegramType]): # pragma: no cover
async def __call__(
self,
bot: "Bot",
method: TelegramMethod[TelegramType],
) -> Response[TelegramType]:
pass
class RequestMiddlewareType(Protocol): # pragma: no cover
async def __call__(
self,
make_request: NextRequestMiddlewareType[TelegramType],
bot: "Bot",
method: TelegramMethod[TelegramType],
) -> Response[TelegramType]:
pass
class BaseRequestMiddleware(ABC):

Some files were not shown because too many files have changed in this diff Show more