diff --git a/aiogram/_telegram/types.py b/aiogram/_telegram/types.py index 13c7d976..da37d1c7 100644 --- a/aiogram/_telegram/types.py +++ b/aiogram/_telegram/types.py @@ -1,6 +1,6 @@ """ !!! DO NOT EDIT THIS FILE !!! -This file is autogenerated from Docs of Telegram Bot API at 2019-06-30 19:48:06 UTC +This file is autogenerated from Docs of Telegram Bot API at 2019-06-30 20:10:58 UTC """ import typing @@ -127,34 +127,34 @@ class Update(pydantic.BaseModel): update_id: int """The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.""" - message: types.Message = None + message: typing.Optional[types.Message] = None """New incoming message of any kind — text, photo, sticker, etc.""" - edited_message: types.Message = None + edited_message: typing.Optional[types.Message] = None """New version of a message that is known to the bot and was edited""" - channel_post: types.Message = None + channel_post: typing.Optional[types.Message] = None """New incoming channel post of any kind — text, photo, sticker, etc.""" - edited_channel_post: types.Message = None + edited_channel_post: typing.Optional[types.Message] = None """New version of a channel post that is known to the bot and was edited""" - inline_query: types.InlineQuery = None + inline_query: typing.Optional[types.InlineQuery] = None """New incoming inline query""" - chosen_inline_result: types.ChosenInlineResult = None + chosen_inline_result: typing.Optional[types.ChosenInlineResult] = None """The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.""" - callback_query: types.CallbackQuery = None + callback_query: typing.Optional[types.CallbackQuery] = None """New incoming callback query""" - shipping_query: types.ShippingQuery = None + shipping_query: typing.Optional[types.ShippingQuery] = None """New incoming shipping query. Only for invoices with flexible price""" - pre_checkout_query: types.PreCheckoutQuery = None + pre_checkout_query: typing.Optional[types.PreCheckoutQuery] = None """New incoming pre-checkout query. Contains full information about checkout""" - poll: types.Poll = None + poll: typing.Optional[types.Poll] = None """New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot""" @@ -174,16 +174,16 @@ class WebhookInfo(pydantic.BaseModel): pending_update_count: int """Number of updates awaiting delivery""" - last_error_date: int = None + last_error_date: typing.Optional[int] = None """Unix time for the most recent error that happened when trying to deliver an update via webhook""" - last_error_message: str = None + last_error_message: typing.Optional[str] = None """Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook""" - max_connections: int = None + max_connections: typing.Optional[int] = None """Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery""" - allowed_updates: typing.List[str] = None + allowed_updates: typing.Optional[typing.List[str]] = None """A list of update types the bot is subscribed to. Defaults to all update types""" @@ -215,13 +215,13 @@ class User(pydantic.BaseModel): first_name: str """User‘s or bot’s first name""" - last_name: str = None + last_name: typing.Optional[str] = None """User‘s or bot’s last name""" - username: str = None + username: typing.Optional[str] = None """User‘s or bot’s username""" - language_code: str = None + language_code: typing.Optional[str] = None """IETF language tag of the user's language""" @@ -238,37 +238,37 @@ class Chat(pydantic.BaseModel): type: str """Type of chat, can be either 'private', 'group', 'supergroup' or 'channel'""" - title: str = None + title: typing.Optional[str] = None """Title, for supergroups, channels and group chats""" - username: str = None + username: typing.Optional[str] = None """Username, for private chats, supergroups and channels if available""" - first_name: str = None + first_name: typing.Optional[str] = None """First name of the other party in a private chat""" - last_name: str = None + last_name: typing.Optional[str] = None """Last name of the other party in a private chat""" - all_members_are_administrators: bool = None + all_members_are_administrators: typing.Optional[bool] = None """True if a group has ‘All Members Are Admins’ enabled.""" - photo: types.ChatPhoto = None + photo: typing.Optional[types.ChatPhoto] = None """Chat photo. Returned only in getChat.""" - description: str = None + description: typing.Optional[str] = None """Description, for supergroups and channel chats. Returned only in getChat.""" - invite_link: str = None + invite_link: typing.Optional[str] = None """Chat invite link, for supergroups and channel chats. Each administrator in a chat generates their own invite links, so the bot must first generate the link using exportChatInviteLink. Returned only in getChat.""" - pinned_message: types.Message = None + pinned_message: typing.Optional[types.Message] = None """Pinned message, for groups, supergroups and channels. Returned only in getChat.""" - sticker_set_name: str = None + sticker_set_name: typing.Optional[str] = None """For supergroups, name of group sticker set. Returned only in getChat.""" - can_set_sticker_set: bool = None + can_set_sticker_set: typing.Optional[bool] = None """True, if the bot can change the group sticker set. Returned only in getChat.""" @@ -282,7 +282,7 @@ class Message(pydantic.BaseModel): message_id: int """Unique message identifier inside this chat""" - from_user: types.User = pydantic.Schema(None, alias="from") + from_user: typing.Optional[types.User] = pydantic.Schema(None, alias="from") """Sender, empty for messages sent to channels""" date: int @@ -291,133 +291,133 @@ class Message(pydantic.BaseModel): chat: types.Chat """Conversation the message belongs to""" - forward_from: types.User = None + forward_from: typing.Optional[types.User] = None """For forwarded messages, sender of the original message""" - forward_from_chat: types.Chat = None + forward_from_chat: typing.Optional[types.Chat] = None """For messages forwarded from channels, information about the original channel""" - forward_from_message_id: int = None + forward_from_message_id: typing.Optional[int] = None """For messages forwarded from channels, identifier of the original message in the channel""" - forward_signature: str = None + forward_signature: typing.Optional[str] = None """For messages forwarded from channels, signature of the post author if present""" - forward_sender_name: str = None + forward_sender_name: typing.Optional[str] = None """Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages""" - forward_date: int = None + forward_date: typing.Optional[int] = None """For forwarded messages, date the original message was sent in Unix time""" - reply_to_message: types.Message = None + reply_to_message: typing.Optional[types.Message] = None """For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.""" - edit_date: int = None + edit_date: typing.Optional[int] = None """Date the message was last edited in Unix time""" - media_group_id: str = None + media_group_id: typing.Optional[str] = None """The unique identifier of a media message group this message belongs to""" - author_signature: str = None + author_signature: typing.Optional[str] = None """Signature of the post author for messages in channels""" - text: str = None + text: typing.Optional[str] = None """For text messages, the actual UTF-8 text of the message, 0-4096 characters.""" - entities: typing.List[types.MessageEntity] = None + entities: typing.Optional[typing.List[types.MessageEntity]] = None """For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text""" - caption_entities: typing.List[types.MessageEntity] = None + caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None """For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption""" - audio: types.Audio = None + audio: typing.Optional[types.Audio] = None """Message is an audio file, information about the file""" - document: types.Document = None + document: typing.Optional[types.Document] = None """Message is a general file, information about the file""" - animation: types.Animation = None + animation: typing.Optional[types.Animation] = None """Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set""" - game: types.Game = None + game: typing.Optional[types.Game] = None """Message is a game, information about the game.""" - photo: typing.List[types.PhotoSize] = None + photo: typing.Optional[typing.List[types.PhotoSize]] = None """Message is a photo, available sizes of the photo""" - sticker: types.Sticker = None + sticker: typing.Optional[types.Sticker] = None """Message is a sticker, information about the sticker""" - video: types.Video = None + video: typing.Optional[types.Video] = None """Message is a video, information about the video""" - voice: types.Voice = None + voice: typing.Optional[types.Voice] = None """Message is a voice message, information about the file""" - video_note: types.VideoNote = None + video_note: typing.Optional[types.VideoNote] = None """Message is a video note, information about the video message""" - caption: str = None + caption: typing.Optional[str] = None """Caption for the animation, audio, document, photo, video or voice, 0-1024 characters""" - contact: types.Contact = None + contact: typing.Optional[types.Contact] = None """Message is a shared contact, information about the contact""" - location: types.Location = None + location: typing.Optional[types.Location] = None """Message is a shared location, information about the location""" - venue: types.Venue = None + venue: typing.Optional[types.Venue] = None """Message is a venue, information about the venue""" - poll: types.Poll = None + poll: typing.Optional[types.Poll] = None """Message is a native poll, information about the poll""" - new_chat_members: typing.List[types.User] = None + new_chat_members: typing.Optional[typing.List[types.User]] = None """New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)""" - left_chat_member: types.User = None + left_chat_member: typing.Optional[types.User] = None """A member was removed from the group, information about them (this member may be the bot itself)""" - new_chat_title: str = None + new_chat_title: typing.Optional[str] = None """A chat title was changed to this value""" - new_chat_photo: typing.List[types.PhotoSize] = None + new_chat_photo: typing.Optional[typing.List[types.PhotoSize]] = None """A chat photo was change to this value""" - delete_chat_photo: bool = None + delete_chat_photo: typing.Optional[bool] = None """Service message: the chat photo was deleted""" - group_chat_created: bool = None + group_chat_created: typing.Optional[bool] = None """Service message: the group has been created""" - supergroup_chat_created: bool = None + supergroup_chat_created: typing.Optional[bool] = None """Service message: the supergroup has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.""" - channel_chat_created: bool = None + channel_chat_created: typing.Optional[bool] = None """Service message: the channel has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.""" - migrate_to_chat_id: int = None + migrate_to_chat_id: typing.Optional[int] = None """The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.""" - migrate_from_chat_id: int = None + migrate_from_chat_id: typing.Optional[int] = None """The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.""" - pinned_message: types.Message = None + pinned_message: typing.Optional[types.Message] = None """Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.""" - invoice: types.Invoice = None + invoice: typing.Optional[types.Invoice] = None """Message is an invoice for a payment, information about the invoice.""" - successful_payment: types.SuccessfulPayment = None + successful_payment: typing.Optional[types.SuccessfulPayment] = None """Message is a service message about a successful payment, information about the payment.""" - connected_website: str = None + connected_website: typing.Optional[str] = None """The domain name of the website on which the user has logged in.""" - passport_data: types.PassportData = None + passport_data: typing.Optional[types.PassportData] = None """Telegram Passport data""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.""" @@ -437,10 +437,10 @@ class MessageEntity(pydantic.BaseModel): length: int """Length of the entity in UTF-16 code units""" - url: str = None + url: typing.Optional[str] = None """For 'text_link' only, url that will be opened after user taps on the text""" - user: types.User = None + user: typing.Optional[types.User] = None """For 'text_mention' only, the mentioned user""" @@ -460,7 +460,7 @@ class PhotoSize(pydantic.BaseModel): height: int """Photo height""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -477,19 +477,19 @@ class Audio(pydantic.BaseModel): duration: int """Duration of the audio in seconds as defined by sender""" - performer: str = None + performer: typing.Optional[str] = None """Performer of the audio as defined by sender or by audio tags""" - title: str = None + title: typing.Optional[str] = None """Title of the audio as defined by sender or by audio tags""" - mime_type: str = None + mime_type: typing.Optional[str] = None """MIME type of the file as defined by sender""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Thumbnail of the album cover to which the music file belongs""" @@ -503,16 +503,16 @@ class Document(pydantic.BaseModel): file_id: str """Unique file identifier""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Document thumbnail as defined by sender""" - file_name: str = None + file_name: typing.Optional[str] = None """Original filename as defined by sender""" - mime_type: str = None + mime_type: typing.Optional[str] = None """MIME type of the file as defined by sender""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -535,13 +535,13 @@ class Video(pydantic.BaseModel): duration: int """Duration of the video in seconds as defined by sender""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Video thumbnail""" - mime_type: str = None + mime_type: typing.Optional[str] = None """Mime type of a file as defined by sender""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -564,16 +564,16 @@ class Animation(pydantic.BaseModel): duration: int """Duration of the video in seconds as defined by sender""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Animation thumbnail as defined by sender""" - file_name: str = None + file_name: typing.Optional[str] = None """Original animation filename as defined by sender""" - mime_type: str = None + mime_type: typing.Optional[str] = None """MIME type of the file as defined by sender""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -590,10 +590,10 @@ class Voice(pydantic.BaseModel): duration: int """Duration of the audio in seconds as defined by sender""" - mime_type: str = None + mime_type: typing.Optional[str] = None """MIME type of the file as defined by sender""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -613,10 +613,10 @@ class VideoNote(pydantic.BaseModel): duration: int """Duration of the video in seconds as defined by sender""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Video thumbnail""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -633,13 +633,13 @@ class Contact(pydantic.BaseModel): first_name: str """Contact's first name""" - last_name: str = None + last_name: typing.Optional[str] = None """Contact's last name""" - user_id: int = None + user_id: typing.Optional[int] = None """Contact's user identifier in Telegram""" - vcard: str = None + vcard: typing.Optional[str] = None """Additional data about the contact in the form of a vCard""" @@ -673,10 +673,10 @@ class Venue(pydantic.BaseModel): address: str """Address of the venue""" - foursquare_id: str = None + foursquare_id: typing.Optional[str] = None """Foursquare identifier of the venue""" - foursquare_type: str = None + foursquare_type: typing.Optional[str] = None """Foursquare type of the venue. (For example, 'arts_entertainment/default', 'arts_entertainment/aquarium' or 'food/icecream'.)""" @@ -739,10 +739,10 @@ class File(pydantic.BaseModel): file_id: str """Unique identifier for this file""" - file_size: int = None + file_size: typing.Optional[int] = None """File size, if known""" - file_path: str = None + file_path: typing.Optional[str] = None """File path. Use https://api.telegram.org/file/bot/ to get the file.""" @@ -756,13 +756,13 @@ class ReplyKeyboardMarkup(pydantic.BaseModel): keyboard: typing.List[typing.List[types.KeyboardButton]] """Array of button rows, each represented by an Array of KeyboardButton objects""" - resize_keyboard: bool = None + resize_keyboard: typing.Optional[bool] = None """Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.""" - one_time_keyboard: bool = None + one_time_keyboard: typing.Optional[bool] = None """Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false.""" - selective: bool = None + selective: typing.Optional[bool] = None """Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.""" @@ -779,10 +779,10 @@ class KeyboardButton(pydantic.BaseModel): text: str """Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed""" - request_contact: bool = None + request_contact: typing.Optional[bool] = None """If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only""" - request_location: bool = None + request_location: typing.Optional[bool] = None """If True, the user's current location will be sent when the button is pressed. Available in private chats only""" @@ -796,7 +796,7 @@ class ReplyKeyboardRemove(pydantic.BaseModel): remove_keyboard: bool """Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)""" - selective: bool = None + selective: typing.Optional[bool] = None """Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.""" @@ -824,31 +824,31 @@ class InlineKeyboardButton(pydantic.BaseModel): text: str """Label text on the button""" - url: str = None + url: typing.Optional[str] = None """HTTP or tg:// url to be opened when button is pressed""" - login_url: types.LoginUrl = None + login_url: typing.Optional[types.LoginUrl] = None """An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.""" - callback_data: str = None + callback_data: typing.Optional[str] = None """Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes""" - switch_inline_query: str = None + switch_inline_query: typing.Optional[str] = None """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. Can be empty, in which case just the bot’s username will be inserted. Note: 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.""" - switch_inline_query_current_chat: str = None + switch_inline_query_current_chat: typing.Optional[str] = None """If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options.""" - callback_game: types.CallbackGame = None + callback_game: typing.Optional[types.CallbackGame] = None """Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.""" - pay: bool = None + pay: typing.Optional[bool] = None """Specify True, to send a Pay button. NOTE: This type of button must always be the first button in the first row.""" @@ -868,13 +868,13 @@ class LoginUrl(pydantic.BaseModel): NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization.""" - forward_text: str = None + forward_text: typing.Optional[str] = None """New text of the button in forwarded messages.""" - bot_username: str = None + bot_username: typing.Optional[str] = None """Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details.""" - request_write_access: bool = None + request_write_access: typing.Optional[bool] = None """Pass True to request the permission for your bot to send messages to the user.""" @@ -892,19 +892,19 @@ class CallbackQuery(pydantic.BaseModel): from_user: types.User = pydantic.Schema(..., alias="from") """Sender""" - message: types.Message = None + message: typing.Optional[types.Message] = None """Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old""" - inline_message_id: str = None + inline_message_id: typing.Optional[str] = None """Identifier of the message sent via the bot in inline mode, that originated the query.""" chat_instance: str """Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.""" - data: str = None + data: typing.Optional[str] = None """Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.""" - game_short_name: str = None + game_short_name: typing.Optional[str] = None """Short name of a Game to be returned, serves as the unique identifier for the game""" @@ -922,7 +922,7 @@ class ForceReply(pydantic.BaseModel): force_reply: bool """Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'""" - selective: bool = None + selective: typing.Optional[bool] = None """Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.""" @@ -953,49 +953,49 @@ class ChatMember(pydantic.BaseModel): status: str """The member's status in the chat. Can be 'creator', 'administrator', 'member', 'restricted', 'left' or 'kicked'""" - until_date: int = None + until_date: typing.Optional[int] = None """Restricted and kicked only. Date when restrictions will be lifted for this user, unix time""" - can_be_edited: bool = None + can_be_edited: typing.Optional[bool] = None """Administrators only. True, if the bot is allowed to edit administrator privileges of that user""" - can_change_info: bool = None + can_change_info: typing.Optional[bool] = None """Administrators only. True, if the administrator can change the chat title, photo and other settings""" - can_post_messages: bool = None + can_post_messages: typing.Optional[bool] = None """Administrators only. True, if the administrator can post in the channel, channels only""" - can_edit_messages: bool = None + can_edit_messages: typing.Optional[bool] = None """Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only""" - can_delete_messages: bool = None + can_delete_messages: typing.Optional[bool] = None """Administrators only. True, if the administrator can delete messages of other users""" - can_invite_users: bool = None + can_invite_users: typing.Optional[bool] = None """Administrators only. True, if the administrator can invite new users to the chat""" - can_restrict_members: bool = None + can_restrict_members: typing.Optional[bool] = None """Administrators only. True, if the administrator can restrict, ban or unban chat members""" - can_pin_messages: bool = None + can_pin_messages: typing.Optional[bool] = None """Administrators only. True, if the administrator can pin messages, groups and supergroups only""" - can_promote_members: bool = None + can_promote_members: typing.Optional[bool] = None """Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)""" - is_member: bool = None + is_member: typing.Optional[bool] = None """Restricted only. True, if the user is a member of the chat at the moment of the request""" - can_send_messages: bool = None + can_send_messages: typing.Optional[bool] = None """Restricted only. True, if the user can send text messages, contacts, locations and venues""" - can_send_media_messages: bool = None + can_send_media_messages: typing.Optional[bool] = None """Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages""" - can_send_other_messages: bool = None + can_send_other_messages: typing.Optional[bool] = None """Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages""" - can_add_web_page_previews: bool = None + can_add_web_page_previews: typing.Optional[bool] = None """Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages""" @@ -1006,10 +1006,10 @@ class ResponseParameters(pydantic.BaseModel): Source: https://core.telegram.org/bots/api#responseparameters """ - migrate_to_chat_id: int = None + migrate_to_chat_id: typing.Optional[int] = None """The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.""" - retry_after: int = None + retry_after: typing.Optional[int] = None """In case of exceeding flood control, the number of seconds left to wait before the request can be repeated""" @@ -1041,10 +1041,10 @@ class InputMediaPhoto(pydantic.BaseModel): media: str """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name.""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the photo to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" @@ -1064,22 +1064,22 @@ class InputMediaVideo(pydantic.BaseModel): thumb: typing.Optional[types.InputFile, str] = None """Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the video to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - width: int = None + width: typing.Optional[int] = None """Video width""" - height: int = None + height: typing.Optional[int] = None """Video height""" - duration: int = None + duration: typing.Optional[int] = None """Video duration""" - supports_streaming: bool = None + supports_streaming: typing.Optional[bool] = None """Pass True, if the uploaded video is suitable for streaming""" @@ -1099,19 +1099,19 @@ class InputMediaAnimation(pydantic.BaseModel): thumb: typing.Optional[types.InputFile, str] = None """Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the animation to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - width: int = None + width: typing.Optional[int] = None """Animation width""" - height: int = None + height: typing.Optional[int] = None """Animation height""" - duration: int = None + duration: typing.Optional[int] = None """Animation duration""" @@ -1131,19 +1131,19 @@ class InputMediaAudio(pydantic.BaseModel): thumb: typing.Optional[types.InputFile, str] = None """Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the audio to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - duration: int = None + duration: typing.Optional[int] = None """Duration of the audio in seconds""" - performer: str = None + performer: typing.Optional[str] = None """Performer of the audio""" - title: str = None + title: typing.Optional[str] = None """Title of the audio""" @@ -1163,10 +1163,10 @@ class InputMediaDocument(pydantic.BaseModel): thumb: typing.Optional[types.InputFile, str] = None """Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the document to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" @@ -1226,19 +1226,19 @@ class Sticker(pydantic.BaseModel): height: int """Sticker height""" - thumb: types.PhotoSize = None + thumb: typing.Optional[types.PhotoSize] = None """Sticker thumbnail in the .webp or .jpg format""" - emoji: str = None + emoji: typing.Optional[str] = None """Emoji associated with the sticker""" - set_name: str = None + set_name: typing.Optional[str] = None """Name of the sticker set to which the sticker belongs""" - mask_position: types.MaskPosition = None + mask_position: typing.Optional[types.MaskPosition] = None """For mask stickers, the position where the mask should be placed""" - file_size: int = None + file_size: typing.Optional[int] = None """File size""" @@ -1307,7 +1307,7 @@ class InlineQuery(pydantic.BaseModel): from_user: types.User = pydantic.Schema(..., alias="from") """Sender""" - location: types.Location = None + location: typing.Optional[types.Location] = None """Sender location, only for bots that request user location""" query: str @@ -1366,25 +1366,25 @@ class InlineQueryResultArticle(pydantic.BaseModel): input_message_content: types.InputMessageContent """Content of the message to be sent""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - url: str = None + url: typing.Optional[str] = None """URL of the result""" - hide_url: bool = None + hide_url: typing.Optional[bool] = None """Pass True, if you don't want the URL to be shown in the message""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - thumb_url: str = None + thumb_url: typing.Optional[str] = None """Url of the thumbnail for the result""" - thumb_width: int = None + thumb_width: typing.Optional[int] = None """Thumbnail width""" - thumb_height: int = None + thumb_height: typing.Optional[int] = None """Thumbnail height""" @@ -1407,28 +1407,28 @@ class InlineQueryResultPhoto(pydantic.BaseModel): thumb_url: str """URL of the thumbnail for the photo""" - photo_width: int = None + photo_width: typing.Optional[int] = None """Width of the photo""" - photo_height: int = None + photo_height: typing.Optional[int] = None """Height of the photo""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the photo to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the photo""" @@ -1448,31 +1448,31 @@ class InlineQueryResultGif(pydantic.BaseModel): gif_url: str """A valid URL for the GIF file. File size must not exceed 1MB""" - gif_width: int = None + gif_width: typing.Optional[int] = None """Width of the GIF""" - gif_height: int = None + gif_height: typing.Optional[int] = None """Height of the GIF""" - gif_duration: int = None + gif_duration: typing.Optional[int] = None """Duration of the GIF""" thumb_url: str """URL of the static thumbnail for the result (jpeg or gif)""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the GIF file to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the GIF animation""" @@ -1492,31 +1492,31 @@ class InlineQueryResultMpeg4Gif(pydantic.BaseModel): mpeg4_url: str """A valid URL for the MP4 file. File size must not exceed 1MB""" - mpeg4_width: int = None + mpeg4_width: typing.Optional[int] = None """Video width""" - mpeg4_height: int = None + mpeg4_height: typing.Optional[int] = None """Video height""" - mpeg4_duration: int = None + mpeg4_duration: typing.Optional[int] = None """Video duration""" thumb_url: str """URL of the static thumbnail (jpeg or gif) for the result""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the MPEG-4 file to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the video animation""" @@ -1546,28 +1546,28 @@ class InlineQueryResultVideo(pydantic.BaseModel): title: str """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the video to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - video_width: int = None + video_width: typing.Optional[int] = None """Video width""" - video_height: int = None + video_height: typing.Optional[int] = None """Video height""" - video_duration: int = None + video_duration: typing.Optional[int] = None """Video duration in seconds""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).""" @@ -1591,22 +1591,22 @@ class InlineQueryResultAudio(pydantic.BaseModel): title: str """Title""" - caption: str = None + caption: typing.Optional[str] = None """Caption, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - performer: str = None + performer: typing.Optional[str] = None """Performer""" - audio_duration: int = None + audio_duration: typing.Optional[int] = None """Audio duration in seconds""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the audio""" @@ -1630,19 +1630,19 @@ class InlineQueryResultVoice(pydantic.BaseModel): title: str """Recording title""" - caption: str = None + caption: typing.Optional[str] = None """Caption, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - voice_duration: int = None + voice_duration: typing.Optional[int] = None """Recording duration in seconds""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the voice recording""" @@ -1663,10 +1663,10 @@ class InlineQueryResultDocument(pydantic.BaseModel): title: str """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the document to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" document_url: str @@ -1675,22 +1675,22 @@ class InlineQueryResultDocument(pydantic.BaseModel): mime_type: str """Mime type of the content of the file, either 'application/pdf' or 'application/zip'""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the file""" - thumb_url: str = None + thumb_url: typing.Optional[str] = None """URL of the thumbnail (jpeg only) for the file""" - thumb_width: int = None + thumb_width: typing.Optional[int] = None """Thumbnail width""" - thumb_height: int = None + thumb_height: typing.Optional[int] = None """Thumbnail height""" @@ -1717,22 +1717,22 @@ class InlineQueryResultLocation(pydantic.BaseModel): title: str """Location title""" - live_period: int = None + live_period: typing.Optional[int] = None """Period in seconds for which the location can be updated, should be between 60 and 86400.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the location""" - thumb_url: str = None + thumb_url: typing.Optional[str] = None """Url of the thumbnail for the result""" - thumb_width: int = None + thumb_width: typing.Optional[int] = None """Thumbnail width""" - thumb_height: int = None + thumb_height: typing.Optional[int] = None """Thumbnail height""" @@ -1762,25 +1762,25 @@ class InlineQueryResultVenue(pydantic.BaseModel): address: str """Address of the venue""" - foursquare_id: str = None + foursquare_id: typing.Optional[str] = None """Foursquare identifier of the venue if known""" - foursquare_type: str = None + foursquare_type: typing.Optional[str] = None """Foursquare type of the venue, if known. (For example, 'arts_entertainment/default', 'arts_entertainment/aquarium' or 'food/icecream'.)""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the venue""" - thumb_url: str = None + thumb_url: typing.Optional[str] = None """Url of the thumbnail for the result""" - thumb_width: int = None + thumb_width: typing.Optional[int] = None """Thumbnail width""" - thumb_height: int = None + thumb_height: typing.Optional[int] = None """Thumbnail height""" @@ -1804,25 +1804,25 @@ class InlineQueryResultContact(pydantic.BaseModel): first_name: str """Contact's first name""" - last_name: str = None + last_name: typing.Optional[str] = None """Contact's last name""" - vcard: str = None + vcard: typing.Optional[str] = None """Additional data about the contact in the form of a vCard, 0-2048 bytes""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the contact""" - thumb_url: str = None + thumb_url: typing.Optional[str] = None """Url of the thumbnail for the result""" - thumb_width: int = None + thumb_width: typing.Optional[int] = None """Thumbnail width""" - thumb_height: int = None + thumb_height: typing.Optional[int] = None """Thumbnail height""" @@ -1843,7 +1843,7 @@ class InlineQueryResultGame(pydantic.BaseModel): game_short_name: str """Short name of the game""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" @@ -1863,22 +1863,22 @@ class InlineQueryResultCachedPhoto(pydantic.BaseModel): photo_file_id: str """A valid file identifier of the photo""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the photo to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the photo""" @@ -1898,19 +1898,19 @@ class InlineQueryResultCachedGif(pydantic.BaseModel): gif_file_id: str """A valid file identifier for the GIF file""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the GIF file to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the GIF animation""" @@ -1930,19 +1930,19 @@ class InlineQueryResultCachedMpeg4Gif(pydantic.BaseModel): mpeg4_file_id: str """A valid file identifier for the MP4 file""" - title: str = None + title: typing.Optional[str] = None """Title for the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the MPEG-4 file to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the video animation""" @@ -1963,10 +1963,10 @@ class InlineQueryResultCachedSticker(pydantic.BaseModel): sticker_file_id: str """A valid file identifier of the sticker""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the sticker""" @@ -1990,19 +1990,19 @@ class InlineQueryResultCachedDocument(pydantic.BaseModel): document_file_id: str """A valid file identifier for the file""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the document to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the file""" @@ -2025,19 +2025,19 @@ class InlineQueryResultCachedVideo(pydantic.BaseModel): title: str """Title for the result""" - description: str = None + description: typing.Optional[str] = None """Short description of the result""" - caption: str = None + caption: typing.Optional[str] = None """Caption of the video to be sent, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the video""" @@ -2061,16 +2061,16 @@ class InlineQueryResultCachedVoice(pydantic.BaseModel): title: str """Voice message title""" - caption: str = None + caption: typing.Optional[str] = None """Caption, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the voice message""" @@ -2091,16 +2091,16 @@ class InlineQueryResultCachedAudio(pydantic.BaseModel): audio_file_id: str """A valid file identifier for the audio file""" - caption: str = None + caption: typing.Optional[str] = None """Caption, 0-1024 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" - reply_markup: types.InlineKeyboardMarkup = None + reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None """Inline keyboard attached to the message""" - input_message_content: types.InputMessageContent = None + input_message_content: typing.Optional[types.InputMessageContent] = None """Content of the message to be sent instead of the audio""" @@ -2128,10 +2128,10 @@ class InputTextMessageContent(pydantic.BaseModel): message_text: str """Text of the message to be sent, 1-4096 characters""" - parse_mode: str = None + parse_mode: typing.Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.""" - disable_web_page_preview: bool = None + disable_web_page_preview: typing.Optional[bool] = None """Disables link previews for links in the sent message""" @@ -2148,7 +2148,7 @@ class InputLocationMessageContent(pydantic.BaseModel): longitude: float """Longitude of the location in degrees""" - live_period: int = None + live_period: typing.Optional[int] = None """Period in seconds for which the location can be updated, should be between 60 and 86400.""" @@ -2171,10 +2171,10 @@ class InputVenueMessageContent(pydantic.BaseModel): address: str """Address of the venue""" - foursquare_id: str = None + foursquare_id: typing.Optional[str] = None """Foursquare identifier of the venue, if known""" - foursquare_type: str = None + foursquare_type: typing.Optional[str] = None """Foursquare type of the venue, if known. (For example, 'arts_entertainment/default', 'arts_entertainment/aquarium' or 'food/icecream'.)""" @@ -2191,10 +2191,10 @@ class InputContactMessageContent(pydantic.BaseModel): first_name: str """Contact's first name""" - last_name: str = None + last_name: typing.Optional[str] = None """Contact's last name""" - vcard: str = None + vcard: typing.Optional[str] = None """Additional data about the contact in the form of a vCard, 0-2048 bytes""" @@ -2212,10 +2212,10 @@ class ChosenInlineResult(pydantic.BaseModel): from_user: types.User = pydantic.Schema(..., alias="from") """The user that chose the result""" - location: types.Location = None + location: typing.Optional[types.Location] = None """Sender location, only for bots that require user location""" - inline_message_id: str = None + inline_message_id: typing.Optional[str] = None """Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.""" query: str @@ -2302,16 +2302,16 @@ class OrderInfo(pydantic.BaseModel): Source: https://core.telegram.org/bots/api#orderinfo """ - name: str = None + name: typing.Optional[str] = None """User name""" - phone_number: str = None + phone_number: typing.Optional[str] = None """User's phone number""" - email: str = None + email: typing.Optional[str] = None """User email""" - shipping_address: types.ShippingAddress = None + shipping_address: typing.Optional[types.ShippingAddress] = None """User shipping address""" @@ -2348,10 +2348,10 @@ class SuccessfulPayment(pydantic.BaseModel): invoice_payload: str """Bot specified invoice payload""" - shipping_option_id: str = None + shipping_option_id: typing.Optional[str] = None """Identifier of the shipping option chosen by the user""" - order_info: types.OrderInfo = None + order_info: typing.Optional[types.OrderInfo] = None """Order info provided by the user""" telegram_payment_charge_id: str @@ -2403,10 +2403,10 @@ class PreCheckoutQuery(pydantic.BaseModel): invoice_payload: str """Bot specified invoice payload""" - shipping_option_id: str = None + shipping_option_id: typing.Optional[str] = None """Identifier of the shipping option chosen by the user""" - order_info: types.OrderInfo = None + order_info: typing.Optional[types.OrderInfo] = None """Order info provided by the user""" @@ -2461,28 +2461,28 @@ class EncryptedPassportElement(pydantic.BaseModel): type: str """Element type. One of 'personal_details', 'passport', 'driver_license', 'identity_card', 'internal_passport', 'address', 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration', 'temporary_registration', 'phone_number', 'email'.""" - data: str = None + data: typing.Optional[str] = None """Base64-encoded encrypted Telegram Passport element data provided by the user, available for 'personal_details', 'passport', 'driver_license', 'identity_card', 'internal_passport' and 'address' types. Can be decrypted and verified using the accompanying EncryptedCredentials.""" - phone_number: str = None + phone_number: typing.Optional[str] = None """User's verified phone number, available only for 'phone_number' type""" - email: str = None + email: typing.Optional[str] = None """User's verified email address, available only for 'email' type""" - files: typing.List[types.PassportFile] = None + files: typing.Optional[typing.List[types.PassportFile]] = None """Array of encrypted files with documents provided by the user, available for 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration' and 'temporary_registration' types. Files can be decrypted and verified using the accompanying EncryptedCredentials.""" - front_side: types.PassportFile = None + front_side: typing.Optional[types.PassportFile] = None """Encrypted file with the front side of the document, provided by the user. Available for 'passport', 'driver_license', 'identity_card' and 'internal_passport'. The file can be decrypted and verified using the accompanying EncryptedCredentials.""" - reverse_side: types.PassportFile = None + reverse_side: typing.Optional[types.PassportFile] = None """Encrypted file with the reverse side of the document, provided by the user. Available for 'driver_license' and 'identity_card'. The file can be decrypted and verified using the accompanying EncryptedCredentials.""" - selfie: types.PassportFile = None + selfie: typing.Optional[types.PassportFile] = None """Encrypted file with the selfie of the user holding a document, provided by the user; available for 'passport', 'driver_license', 'identity_card' and 'internal_passport'. The file can be decrypted and verified using the accompanying EncryptedCredentials.""" - translation: typing.List[types.PassportFile] = None + translation: typing.Optional[typing.List[types.PassportFile]] = None """Array of encrypted files with translated versions of documents provided by the user. Available if requested for 'passport', 'driver_license', 'identity_card', 'internal_passport', 'utility_bill', 'bank_statement', 'rental_agreement', 'passport_registration' and 'temporary_registration' types. Files can be decrypted and verified using the accompanying EncryptedCredentials.""" hash: str @@ -2751,13 +2751,13 @@ class Game(pydantic.BaseModel): photo: typing.List[types.PhotoSize] """Photo that will be displayed in the game message in chats.""" - text: str = None + text: typing.Optional[str] = None """Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.""" - text_entities: typing.List[types.MessageEntity] = None + text_entities: typing.Optional[typing.List[types.MessageEntity]] = None """Special entities that appear in text, such as usernames, URLs, bot commands, etc.""" - animation: types.Animation = None + animation: typing.Optional[types.Animation] = None """Animation that will be displayed in the game message in chats. Upload via BotFather""" diff --git a/generator/normalizers.py b/generator/normalizers.py index c92f9e8e..7d260809 100644 --- a/generator/normalizers.py +++ b/generator/normalizers.py @@ -37,12 +37,10 @@ def normalize_type_annotation(item: dict): @functools.lru_cache() -def normalize_type(string, required=True): +def normalize_type(string): if not string: return "typing.Any" - union = "typing.Union" if required else "typing.Optional" - lower = string.lower() split = lower.split() @@ -52,7 +50,7 @@ def normalize_type(string, required=True): if "or" in split: split_types = string.split(" or ") norm_str = ", ".join(map(normalize_type, map(str.strip, split_types))) - return f"{union}[{norm_str}]" + return f"typing.Union[{norm_str}]" if "number" in lower: return normalize_type(string.replace("number", "").strip()) if lower in ["true", "false"]: @@ -83,3 +81,12 @@ def get_returning(description): break return return_type, sentence + "." + + +def normalize_optional(python_type: str, required: bool = True) -> str: + if not required: + if "typing.Union" in python_type: + python_type = python_type.replace("typing.Union", "typing.Optional") + else: + python_type = f"typing.Optional[{python_type}]" + return python_type diff --git a/generator/structures.py b/generator/structures.py index 8d240d9d..8b5d720e 100644 --- a/generator/structures.py +++ b/generator/structures.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing from dataclasses import dataclass, field -from generator.normalizers import normalize_type, get_returning +from generator.normalizers import normalize_type, get_returning, normalize_optional @dataclass @@ -21,10 +21,11 @@ class Annotation: @property def python_type(self) -> str: - return normalize_type(self.type, self.required) + result = normalize_type(self.type) + return normalize_optional(result, self.required) @property - def python_argument(self): + def python_field(self): result = f"{self.python_name}: {self.python_type}" value = "" if self.required else "None" diff --git a/generator/templates/type.py.jinja2 b/generator/templates/type.py.jinja2 index 5b5a6f72..2c3bd694 100644 --- a/generator/templates/type.py.jinja2 +++ b/generator/templates/type.py.jinja2 @@ -5,7 +5,7 @@ class {{ entity.python_name }}(pydantic.BaseModel): Source: https://core.telegram.org/bots/api#{{ entity.anchor }} """ {% for annotation in entity.annotations %} - {{ annotation.python_argument }} + {{ annotation.python_field }} """{{ annotation.description|indent(width=4) }}""" {% else %} pass