Regenerate corresponding to Bot API 5.1

This commit is contained in:
Alex Root Junior 2021-03-14 23:15:19 +02:00
parent a6f824a117
commit 20d0c979b8
227 changed files with 1039 additions and 435 deletions

View file

@ -1 +1 @@
4.9
5.1

View file

@ -28,4 +28,4 @@ __all__ = (
)
__version__ = "3.0.0-alpha.6"
__api_version__ = "4.9"
__api_version__ = "5.1"

View file

@ -30,12 +30,14 @@ from ..methods import (
AnswerShippingQuery,
Close,
CopyMessage,
CreateChatInviteLink,
CreateNewStickerSet,
DeleteChatPhoto,
DeleteChatStickerSet,
DeleteMessage,
DeleteStickerFromSet,
DeleteWebhook,
EditChatInviteLink,
EditMessageCaption,
EditMessageLiveLocation,
EditMessageMedia,
@ -61,6 +63,7 @@ from ..methods import (
PinChatMessage,
PromoteChatMember,
RestrictChatMember,
RevokeChatInviteLink,
SendAnimation,
SendAudio,
SendChatAction,
@ -103,6 +106,7 @@ from ..types import (
UNSET,
BotCommand,
Chat,
ChatInviteLink,
ChatMember,
ChatPermissions,
Downloadable,
@ -141,10 +145,7 @@ T = TypeVar("T")
class Bot(ContextInstanceMixin["Bot"]):
def __init__(
self,
token: str,
session: Optional[BaseSession] = None,
parse_mode: Optional[str] = None,
self, token: str, session: Optional[BaseSession] = None, parse_mode: Optional[str] = None,
) -> None:
"""
Bot class
@ -343,15 +344,12 @@ class Bot(ContextInstanceMixin["Bot"]):
: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 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 updates regardless of type (default). If not specified, the previous setting will be used.
: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.
:param request_timeout: Request timeout
:return: An Array of Update objects is returned.
"""
call = GetUpdates(
offset=offset,
limit=limit,
timeout=timeout,
allowed_updates=allowed_updates,
offset=offset, limit=limit, timeout=timeout, allowed_updates=allowed_updates,
)
return await self(call, request_timeout=request_timeout)
@ -384,7 +382,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param certificate: Upload your public key certificate so that the root certificate in use can be checked. See our `self-signed guide <https://core.telegram.org/bots/self-signed>`_ for details.
:param ip_address: The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
:param max_connections: Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to *40*. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
: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 updates regardless of type (default). If not specified, the previous setting will be used.
: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.
:param drop_pending_updates: Pass :code:`True` to drop all pending updates
:param request_timeout: Request timeout
:return: Returns True on success.
@ -400,9 +398,7 @@ class Bot(ContextInstanceMixin["Bot"]):
return await self(call, request_timeout=request_timeout)
async def delete_webhook(
self,
drop_pending_updates: Optional[bool] = None,
request_timeout: Optional[int] = None,
self, drop_pending_updates: Optional[bool] = None, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to remove webhook integration if you decide to switch back to :class:`aiogram.methods.get_updates.GetUpdates`. Returns :code:`True` on success.
@ -413,15 +409,10 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = DeleteWebhook(
drop_pending_updates=drop_pending_updates,
)
call = DeleteWebhook(drop_pending_updates=drop_pending_updates,)
return await self(call, request_timeout=request_timeout)
async def get_webhook_info(
self,
request_timeout: Optional[int] = None,
) -> WebhookInfo:
async def get_webhook_info(self, request_timeout: Optional[int] = None,) -> WebhookInfo:
"""
Use this method to get current webhook status. Requires no parameters. On success, returns a :class:`aiogram.types.webhook_info.WebhookInfo` object. If the bot is using :class:`aiogram.methods.get_updates.GetUpdates`, will return an object with the *url* field empty.
@ -439,10 +430,7 @@ class Bot(ContextInstanceMixin["Bot"]):
# Source: https://core.telegram.org/bots/api#available-methods
# =============================================================================================
async def get_me(
self,
request_timeout: Optional[int] = None,
) -> User:
async def get_me(self, request_timeout: Optional[int] = None,) -> User:
"""
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a :class:`aiogram.types.user.User` object.
@ -454,10 +442,7 @@ class Bot(ContextInstanceMixin["Bot"]):
call = GetMe()
return await self(call, request_timeout=request_timeout)
async def log_out(
self,
request_timeout: Optional[int] = None,
) -> bool:
async def log_out(self, request_timeout: Optional[int] = None,) -> bool:
"""
Use this method to log out from the cloud Bot API server before launching the bot locally. You **must** log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns :code:`True` on success. Requires no parameters.
@ -469,10 +454,7 @@ class Bot(ContextInstanceMixin["Bot"]):
call = LogOut()
return await self(call, request_timeout=request_timeout)
async def close(
self,
request_timeout: Optional[int] = None,
) -> bool:
async def close(self, request_timeout: Optional[int] = None,) -> bool:
"""
Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns :code:`True` on success. Requires no parameters.
@ -575,7 +557,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None,
) -> MessageId:
"""
Use this method to copy messages of any kind. The method is analogous to the method :class:`aiogram.methods.forward_messages.ForwardMessages`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Use this method to copy messages of any kind. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Source: https://core.telegram.org/bots/api#copymessage
@ -1314,7 +1296,7 @@ class Bot(ContextInstanceMixin["Bot"]):
Source: https://core.telegram.org/bots/api#senddice
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param emoji: Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', or '🎰'. Dice can have values 1-6 for '🎲' and '🎯', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'
:param emoji: Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found
@ -1333,10 +1315,7 @@ class Bot(ContextInstanceMixin["Bot"]):
return await self(call, request_timeout=request_timeout)
async def send_chat_action(
self,
chat_id: Union[int, str],
action: str,
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], action: str, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns :code:`True` on success.
@ -1352,10 +1331,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SendChatAction(
chat_id=chat_id,
action=action,
)
call = SendChatAction(chat_id=chat_id, action=action,)
return await self(call, request_timeout=request_timeout)
async def get_user_profile_photos(
@ -1376,18 +1352,10 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns a UserProfilePhotos object.
"""
call = GetUserProfilePhotos(
user_id=user_id,
offset=offset,
limit=limit,
)
call = GetUserProfilePhotos(user_id=user_id, offset=offset, limit=limit,)
return await self(call, request_timeout=request_timeout)
async def get_file(
self,
file_id: str,
request_timeout: Optional[int] = None,
) -> File:
async def get_file(self, file_id: str, request_timeout: Optional[int] = None,) -> File:
"""
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a :class:`aiogram.types.file.File` object is returned. The file can then be downloaded via the link :code:`https://api.telegram.org/file/bot<token>/<file_path>`, where :code:`<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling :class:`aiogram.methods.get_file.GetFile` again.
**Note:** This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
@ -1398,9 +1366,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: On success, a File object is returned.
"""
call = GetFile(
file_id=file_id,
)
call = GetFile(file_id=file_id,)
return await self(call, request_timeout=request_timeout)
async def kick_chat_member(
@ -1408,6 +1374,7 @@ class Bot(ContextInstanceMixin["Bot"]):
chat_id: Union[int, str],
user_id: int,
until_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
revoke_messages: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
@ -1418,6 +1385,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param chat_id: Unique identifier for the target group or username of the target supergroup or channel (in the format :code:`@channelusername`)
:param user_id: Unique identifier of the target user
:param until_date: Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
:param revoke_messages: Pass :code:`True` to delete all messages from the chat for the user that is being removed. If :code:`False`, the user will be able to see messages in the group that were sent before the user was removed. Always :code:`True` for supergroups and channels.
:param request_timeout: Request timeout
:return: In the case of supergroups and channels, the user will not be able to return to
the chat on their own using invite links, etc. Returns True on success.
@ -1426,6 +1394,7 @@ class Bot(ContextInstanceMixin["Bot"]):
chat_id=chat_id,
user_id=user_id,
until_date=until_date,
revoke_messages=revoke_messages,
)
return await self(call, request_timeout=request_timeout)
@ -1448,11 +1417,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: The user will not return to the group or channel automatically, but will be able
to join via link, etc. Returns True on success.
"""
call = UnbanChatMember(
chat_id=chat_id,
user_id=user_id,
only_if_banned=only_if_banned,
)
call = UnbanChatMember(chat_id=chat_id, user_id=user_id, only_if_banned=only_if_banned,)
return await self(call, request_timeout=request_timeout)
async def restrict_chat_member(
@ -1476,10 +1441,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: Returns True on success.
"""
call = RestrictChatMember(
chat_id=chat_id,
user_id=user_id,
permissions=permissions,
until_date=until_date,
chat_id=chat_id, user_id=user_id, permissions=permissions, until_date=until_date,
)
return await self(call, request_timeout=request_timeout)
@ -1488,14 +1450,16 @@ class Bot(ContextInstanceMixin["Bot"]):
chat_id: Union[int, str],
user_id: int,
is_anonymous: Optional[bool] = None,
can_change_info: Optional[bool] = None,
can_manage_chat: Optional[bool] = None,
can_post_messages: Optional[bool] = None,
can_edit_messages: Optional[bool] = None,
can_delete_messages: Optional[bool] = None,
can_invite_users: Optional[bool] = None,
can_manage_voice_chats: Optional[bool] = None,
can_restrict_members: Optional[bool] = None,
can_pin_messages: Optional[bool] = None,
can_promote_members: Optional[bool] = None,
can_change_info: Optional[bool] = None,
can_invite_users: Optional[bool] = None,
can_pin_messages: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
@ -1506,14 +1470,16 @@ class Bot(ContextInstanceMixin["Bot"]):
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param user_id: Unique identifier of the target user
:param is_anonymous: Pass :code:`True`, if the administrator's presence in the chat is hidden
:param can_change_info: Pass True, if the administrator can change chat title, photo and other settings
:param can_manage_chat: Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
:param can_post_messages: Pass True, if the administrator can create channel posts, channels only
:param can_edit_messages: Pass True, if the administrator can edit messages of other users and can pin messages, channels only
:param can_delete_messages: Pass True, if the administrator can delete messages of other users
:param can_invite_users: Pass True, if the administrator can invite new users to the chat
:param can_manage_voice_chats: Pass True, if the administrator can manage voice chats, supergroups only
:param can_restrict_members: Pass True, if the administrator can restrict, ban or unban chat members
:param can_pin_messages: Pass True, if the administrator can pin messages, supergroups only
:param can_promote_members: Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
:param can_change_info: Pass True, if the administrator can change chat title, photo and other settings
:param can_invite_users: Pass True, if the administrator can invite new users to the chat
:param can_pin_messages: Pass True, if the administrator can pin messages, supergroups only
:param request_timeout: Request timeout
:return: Returns True on success.
"""
@ -1521,14 +1487,16 @@ class Bot(ContextInstanceMixin["Bot"]):
chat_id=chat_id,
user_id=user_id,
is_anonymous=is_anonymous,
can_change_info=can_change_info,
can_manage_chat=can_manage_chat,
can_post_messages=can_post_messages,
can_edit_messages=can_edit_messages,
can_delete_messages=can_delete_messages,
can_invite_users=can_invite_users,
can_manage_voice_chats=can_manage_voice_chats,
can_restrict_members=can_restrict_members,
can_pin_messages=can_pin_messages,
can_promote_members=can_promote_members,
can_change_info=can_change_info,
can_invite_users=can_invite_users,
can_pin_messages=can_pin_messages,
)
return await self(call, request_timeout=request_timeout)
@ -1551,9 +1519,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: Returns True on success.
"""
call = SetChatAdministratorCustomTitle(
chat_id=chat_id,
user_id=user_id,
custom_title=custom_title,
chat_id=chat_id, user_id=user_id, custom_title=custom_title,
)
return await self(call, request_timeout=request_timeout)
@ -1573,21 +1539,16 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetChatPermissions(
chat_id=chat_id,
permissions=permissions,
)
call = SetChatPermissions(chat_id=chat_id, permissions=permissions,)
return await self(call, request_timeout=request_timeout)
async def export_chat_invite_link(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> str:
"""
Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success.
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` — after this the link will become available to the bot via the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
@ -1595,16 +1556,78 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns the new invite link as String on success.
"""
call = ExportChatInviteLink(
chat_id=chat_id,
call = ExportChatInviteLink(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def create_chat_invite_link(
self,
chat_id: Union[int, str],
expire_date: Optional[int] = None,
member_limit: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> ChatInviteLink:
"""
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatinvitelink
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
:param request_timeout: Request timeout
:return: Returns the new invite link as ChatInviteLink object.
"""
call = CreateChatInviteLink(
chat_id=chat_id, expire_date=expire_date, member_limit=member_limit,
)
return await self(call, request_timeout=request_timeout)
async def set_chat_photo(
async def edit_chat_invite_link(
self,
chat_id: Union[int, str],
photo: InputFile,
invite_link: str,
expire_date: Optional[int] = None,
member_limit: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> ChatInviteLink:
"""
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatinvitelink
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param invite_link: The invite link to edit
:param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
:param request_timeout: Request timeout
:return: Returns the edited invite link as a ChatInviteLink object.
"""
call = EditChatInviteLink(
chat_id=chat_id,
invite_link=invite_link,
expire_date=expire_date,
member_limit=member_limit,
)
return await self(call, request_timeout=request_timeout)
async def revoke_chat_invite_link(
self, chat_id: Union[int, str], invite_link: str, request_timeout: Optional[int] = None,
) -> ChatInviteLink:
"""
Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#revokechatinvitelink
:param chat_id: Unique identifier of the target chat or username of the target channel (in the format :code:`@channelusername`)
:param invite_link: The invite link to revoke
:param request_timeout: Request timeout
:return: Returns the revoked invite link as ChatInviteLink object.
"""
call = RevokeChatInviteLink(chat_id=chat_id, invite_link=invite_link,)
return await self(call, request_timeout=request_timeout)
async def set_chat_photo(
self, chat_id: Union[int, str], photo: InputFile, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success.
@ -1616,16 +1639,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetChatPhoto(
chat_id=chat_id,
photo=photo,
)
call = SetChatPhoto(chat_id=chat_id, photo=photo,)
return await self(call, request_timeout=request_timeout)
async def delete_chat_photo(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success.
@ -1636,16 +1654,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = DeleteChatPhoto(
chat_id=chat_id,
)
call = DeleteChatPhoto(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def set_chat_title(
self,
chat_id: Union[int, str],
title: str,
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], title: str, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success.
@ -1657,10 +1670,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetChatTitle(
chat_id=chat_id,
title=title,
)
call = SetChatTitle(chat_id=chat_id, title=title,)
return await self(call, request_timeout=request_timeout)
async def set_chat_description(
@ -1679,10 +1689,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetChatDescription(
chat_id=chat_id,
description=description,
)
call = SetChatDescription(chat_id=chat_id, description=description,)
return await self(call, request_timeout=request_timeout)
async def pin_chat_message(
@ -1704,9 +1711,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: Returns True on success.
"""
call = PinChatMessage(
chat_id=chat_id,
message_id=message_id,
disable_notification=disable_notification,
chat_id=chat_id, message_id=message_id, disable_notification=disable_notification,
)
return await self(call, request_timeout=request_timeout)
@ -1726,16 +1731,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = UnpinChatMessage(
chat_id=chat_id,
message_id=message_id,
)
call = UnpinChatMessage(chat_id=chat_id, message_id=message_id,)
return await self(call, request_timeout=request_timeout)
async def unpin_all_chat_messages(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success.
@ -1746,15 +1746,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = UnpinAllChatMessages(
chat_id=chat_id,
)
call = UnpinAllChatMessages(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def leave_chat(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method for your bot to leave a group, supergroup or channel. Returns :code:`True` on success.
@ -1765,15 +1761,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = LeaveChat(
chat_id=chat_id,
)
call = LeaveChat(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def get_chat(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> Chat:
"""
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a :class:`aiogram.types.chat.Chat` object on success.
@ -1784,15 +1776,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns a Chat object on success.
"""
call = GetChat(
chat_id=chat_id,
)
call = GetChat(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def get_chat_administrators(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> List[ChatMember]:
"""
Use this method to get a list of administrators in a chat. On success, returns an Array of :class:`aiogram.types.chat_member.ChatMember` objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
@ -1806,15 +1794,11 @@ class Bot(ContextInstanceMixin["Bot"]):
supergroup and no administrators were appointed, only the creator will be
returned.
"""
call = GetChatAdministrators(
chat_id=chat_id,
)
call = GetChatAdministrators(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def get_chat_members_count(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> int:
"""
Use this method to get the number of members in a chat. Returns *Int* on success.
@ -1825,16 +1809,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns Int on success.
"""
call = GetChatMembersCount(
chat_id=chat_id,
)
call = GetChatMembersCount(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def get_chat_member(
self,
chat_id: Union[int, str],
user_id: int,
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], user_id: int, request_timeout: Optional[int] = None,
) -> ChatMember:
"""
Use this method to get information about a member of a chat. Returns a :class:`aiogram.types.chat_member.ChatMember` object on success.
@ -1846,10 +1825,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns a ChatMember object on success.
"""
call = GetChatMember(
chat_id=chat_id,
user_id=user_id,
)
call = GetChatMember(chat_id=chat_id, user_id=user_id,)
return await self(call, request_timeout=request_timeout)
async def set_chat_sticker_set(
@ -1869,16 +1845,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: Use the field can_set_sticker_set optionally returned in getChat requests to
check if the bot can use this method. Returns True on success.
"""
call = SetChatStickerSet(
chat_id=chat_id,
sticker_set_name=sticker_set_name,
)
call = SetChatStickerSet(chat_id=chat_id, sticker_set_name=sticker_set_name,)
return await self(call, request_timeout=request_timeout)
async def delete_chat_sticker_set(
self,
chat_id: Union[int, str],
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success.
@ -1890,9 +1861,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: Use the field can_set_sticker_set optionally returned in getChat requests to
check if the bot can use this method. Returns True on success.
"""
call = DeleteChatStickerSet(
chat_id=chat_id,
)
call = DeleteChatStickerSet(chat_id=chat_id,)
return await self(call, request_timeout=request_timeout)
async def answer_callback_query(
@ -1929,9 +1898,7 @@ class Bot(ContextInstanceMixin["Bot"]):
return await self(call, request_timeout=request_timeout)
async def set_my_commands(
self,
commands: List[BotCommand],
request_timeout: Optional[int] = None,
self, commands: List[BotCommand], request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to change the list of the bot's commands. Returns :code:`True` on success.
@ -1942,15 +1909,10 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetMyCommands(
commands=commands,
)
call = SetMyCommands(commands=commands,)
return await self(call, request_timeout=request_timeout)
async def get_my_commands(
self,
request_timeout: Optional[int] = None,
) -> List[BotCommand]:
async def get_my_commands(self, request_timeout: Optional[int] = None,) -> List[BotCommand]:
"""
Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of :class:`aiogram.types.bot_command.BotCommand` on success.
@ -2125,18 +2087,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: On success, the stopped Poll with the final results is returned.
"""
call = StopPoll(
chat_id=chat_id,
message_id=message_id,
reply_markup=reply_markup,
)
call = StopPoll(chat_id=chat_id, message_id=message_id, reply_markup=reply_markup,)
return await self(call, request_timeout=request_timeout)
async def delete_message(
self,
chat_id: Union[int, str],
message_id: int,
request_timeout: Optional[int] = None,
self, chat_id: Union[int, str], message_id: int, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to delete a message, including service messages, with the following limitations:
@ -2164,10 +2119,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = DeleteMessage(
chat_id=chat_id,
message_id=message_id,
)
call = DeleteMessage(chat_id=chat_id, message_id=message_id,)
return await self(call, request_timeout=request_timeout)
# =============================================================================================
@ -2212,9 +2164,7 @@ class Bot(ContextInstanceMixin["Bot"]):
return await self(call, request_timeout=request_timeout)
async def get_sticker_set(
self,
name: str,
request_timeout: Optional[int] = None,
self, name: str, request_timeout: Optional[int] = None,
) -> StickerSet:
"""
Use this method to get a sticker set. On success, a :class:`aiogram.types.sticker_set.StickerSet` object is returned.
@ -2225,16 +2175,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: On success, a StickerSet object is returned.
"""
call = GetStickerSet(
name=name,
)
call = GetStickerSet(name=name,)
return await self(call, request_timeout=request_timeout)
async def upload_sticker_file(
self,
user_id: int,
png_sticker: InputFile,
request_timeout: Optional[int] = None,
self, user_id: int, png_sticker: InputFile, request_timeout: Optional[int] = None,
) -> File:
"""
Use this method to upload a .PNG file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple times). Returns the uploaded :class:`aiogram.types.file.File` on success.
@ -2246,10 +2191,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns the uploaded File on success.
"""
call = UploadStickerFile(
user_id=user_id,
png_sticker=png_sticker,
)
call = UploadStickerFile(user_id=user_id, png_sticker=png_sticker,)
return await self(call, request_timeout=request_timeout)
async def create_new_sticker_set(
@ -2327,10 +2269,7 @@ class Bot(ContextInstanceMixin["Bot"]):
return await self(call, request_timeout=request_timeout)
async def set_sticker_position_in_set(
self,
sticker: str,
position: int,
request_timeout: Optional[int] = None,
self, sticker: str, position: int, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to move a sticker in a set created by the bot to a specific position. Returns :code:`True` on success.
@ -2342,16 +2281,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetStickerPositionInSet(
sticker=sticker,
position=position,
)
call = SetStickerPositionInSet(sticker=sticker, position=position,)
return await self(call, request_timeout=request_timeout)
async def delete_sticker_from_set(
self,
sticker: str,
request_timeout: Optional[int] = None,
self, sticker: str, request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to delete a sticker from a set created by the bot. Returns :code:`True` on success.
@ -2362,9 +2296,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = DeleteStickerFromSet(
sticker=sticker,
)
call = DeleteStickerFromSet(sticker=sticker,)
return await self(call, request_timeout=request_timeout)
async def set_sticker_set_thumb(
@ -2385,11 +2317,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param request_timeout: Request timeout
:return: Returns True on success.
"""
call = SetStickerSetThumb(
name=name,
user_id=user_id,
thumb=thumb,
)
call = SetStickerSetThumb(name=name, user_id=user_id, thumb=thumb,)
return await self(call, request_timeout=request_timeout)
# =============================================================================================
@ -2576,9 +2504,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:return: On success, True is returned.
"""
call = AnswerPreCheckoutQuery(
pre_checkout_query_id=pre_checkout_query_id,
ok=ok,
error_message=error_message,
pre_checkout_query_id=pre_checkout_query_id, ok=ok, error_message=error_message,
)
return await self(call, request_timeout=request_timeout)
@ -2606,10 +2532,7 @@ class Bot(ContextInstanceMixin["Bot"]):
fixed (the contents of the field for which you returned the error must change).
Returns True on success.
"""
call = SetPassportDataErrors(
user_id=user_id,
errors=errors,
)
call = SetPassportDataErrors(user_id=user_id, errors=errors,)
return await self(call, request_timeout=request_timeout)
# =============================================================================================

View file

@ -150,6 +150,12 @@ class Dispatcher(Router):
elif update.poll_answer:
update_type = "poll_answer"
event = update.poll_answer
elif update.my_chat_member:
update_type = "my_chat_member"
event = update.my_chat_member
elif update.chat_member:
update_type = "chat_member"
event = update.chat_member
else:
warnings.warn(
"Detected unknown update type.\n"

View file

@ -29,5 +29,7 @@ BUILTIN_FILTERS: Dict[str, Tuple[Type[BaseFilter], ...]] = {
"pre_checkout_query": (),
"poll": (),
"poll_answer": (),
"my_chat_member": (),
"chat_member": (),
"error": (ExceptionMessageFilter, ExceptionTypeFilter),
}

View file

@ -22,7 +22,7 @@ class ContentTypesFilter(BaseFilter):
cls, value: Optional[Union[Sequence[str], str]]
) -> Optional[Sequence[str]]:
if not value:
value = [ContentType.TEXT]
return value
if isinstance(value, str):
value = [value]
allowed_content_types = set(ContentType.all())

View file

@ -7,11 +7,13 @@ from .message import MessageHandler, MessageHandlerCommandMixin
from .poll import PollHandler
from .pre_checkout_query import PreCheckoutQueryHandler
from .shipping_query import ShippingQueryHandler
from .chat_member import ChatMemberUpdated
__all__ = (
"BaseHandler",
"BaseHandlerMixin",
"CallbackQueryHandler",
"ChatMemberUpdated",
"ChosenInlineResultHandler",
"ErrorHandler",
"InlineQueryHandler",

View file

@ -51,6 +51,9 @@ class Router:
)
self.poll = TelegramEventObserver(router=self, event_name="poll")
self.poll_answer = TelegramEventObserver(router=self, event_name="poll_answer")
self.my_chat_member = TelegramEventObserver(router=self, event_name="my_chat_member")
self.chat_member = TelegramEventObserver(router=self, event_name="chat_member")
self.errors = TelegramEventObserver(router=self, event_name="error")
self.startup = EventObserver()
@ -68,6 +71,8 @@ class Router:
"pre_checkout_query": self.pre_checkout_query,
"poll": self.poll,
"poll_answer": self.poll_answer,
"my_chat_member": self.my_chat_member,
"chat_member": self.chat_member,
"error": self.errors,
}

View file

@ -6,12 +6,14 @@ from .answer_shipping_query import AnswerShippingQuery
from .base import Request, Response, TelegramMethod
from .close import Close
from .copy_message import CopyMessage
from .create_chat_invite_link import CreateChatInviteLink
from .create_new_sticker_set import CreateNewStickerSet
from .delete_chat_photo import DeleteChatPhoto
from .delete_chat_sticker_set import DeleteChatStickerSet
from .delete_message import DeleteMessage
from .delete_sticker_from_set import DeleteStickerFromSet
from .delete_webhook import DeleteWebhook
from .edit_chat_invite_link import EditChatInviteLink
from .edit_message_caption import EditMessageCaption
from .edit_message_live_location import EditMessageLiveLocation
from .edit_message_media import EditMessageMedia
@ -37,6 +39,7 @@ from .log_out import LogOut
from .pin_chat_message import PinChatMessage
from .promote_chat_member import PromoteChatMember
from .restrict_chat_member import RestrictChatMember
from .revoke_chat_invite_link import RevokeChatInviteLink
from .send_animation import SendAnimation
from .send_audio import SendAudio
from .send_chat_action import SendChatAction
@ -113,6 +116,9 @@ __all__ = (
"SetChatAdministratorCustomTitle",
"SetChatPermissions",
"ExportChatInviteLink",
"CreateChatInviteLink",
"EditChatInviteLink",
"RevokeChatInviteLink",
"SetChatPhoto",
"DeleteChatPhoto",
"SetChatTitle",

View file

@ -19,7 +19,7 @@ if TYPE_CHECKING: # pragma: no cover
class CopyMessage(TelegramMethod[MessageId]):
"""
Use this method to copy messages of any kind. The method is analogous to the method :class:`aiogram.methods.forward_messages.ForwardMessages`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Use this method to copy messages of any kind. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Source: https://core.telegram.org/bots/api#copymessage
"""

View file

@ -0,0 +1,31 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from ..types import ChatInviteLink
from .base import Request, TelegramMethod
if TYPE_CHECKING: # pragma: no cover
from ..client.bot import Bot
class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
"""
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatinvitelink
"""
__returning__ = ChatInviteLink
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
expire_date: Optional[int] = None
"""Point in time (Unix timestamp) when the link will expire"""
member_limit: Optional[int] = None
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="createChatInviteLink", data=data)

View file

@ -0,0 +1,33 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from ..types import ChatInviteLink
from .base import Request, TelegramMethod
if TYPE_CHECKING: # pragma: no cover
from ..client.bot import Bot
class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
"""
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatinvitelink
"""
__returning__ = ChatInviteLink
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
invite_link: str
"""The invite link to edit"""
expire_date: Optional[int] = None
"""Point in time (Unix timestamp) when the link will expire"""
member_limit: Optional[int] = None
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="editChatInviteLink", data=data)

View file

@ -10,9 +10,9 @@ if TYPE_CHECKING: # pragma: no cover
class ExportChatInviteLink(TelegramMethod[str]):
"""
Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success.
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` — after this the link will become available to the bot via the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
"""

View file

@ -31,7 +31,7 @@ class GetUpdates(TelegramMethod[List[Update]]):
timeout: Optional[int] = None
"""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."""
allowed_updates: Optional[List[str]] = None
"""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 updates regardless of type (default). If not specified, the previous setting will be used."""
"""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."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()

View file

@ -24,6 +24,8 @@ class KickChatMember(TelegramMethod[bool]):
"""Unique identifier of the target user"""
until_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only."""
revoke_messages: Optional[bool] = None
"""Pass :code:`True` to delete all messages from the chat for the user that is being removed. If :code:`False`, the user will be able to see messages in the group that were sent before the user was removed. Always :code:`True` for supergroups and channels."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()

View file

@ -23,22 +23,26 @@ class PromoteChatMember(TelegramMethod[bool]):
"""Unique identifier of the target user"""
is_anonymous: Optional[bool] = None
"""Pass :code:`True`, if the administrator's presence in the chat is hidden"""
can_change_info: Optional[bool] = None
"""Pass True, if the administrator can change chat title, photo and other settings"""
can_manage_chat: Optional[bool] = None
"""Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege"""
can_post_messages: Optional[bool] = None
"""Pass True, if the administrator can create channel posts, channels only"""
can_edit_messages: Optional[bool] = None
"""Pass True, if the administrator can edit messages of other users and can pin messages, channels only"""
can_delete_messages: Optional[bool] = None
"""Pass True, if the administrator can delete messages of other users"""
can_invite_users: Optional[bool] = None
"""Pass True, if the administrator can invite new users to the chat"""
can_manage_voice_chats: Optional[bool] = None
"""Pass True, if the administrator can manage voice chats, supergroups only"""
can_restrict_members: Optional[bool] = None
"""Pass True, if the administrator can restrict, ban or unban chat members"""
can_pin_messages: Optional[bool] = None
"""Pass True, if the administrator can pin messages, supergroups only"""
can_promote_members: Optional[bool] = None
"""Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)"""
can_change_info: Optional[bool] = None
"""Pass True, if the administrator can change chat title, photo and other settings"""
can_invite_users: Optional[bool] = None
"""Pass True, if the administrator can invite new users to the chat"""
can_pin_messages: Optional[bool] = None
"""Pass True, if the administrator can pin messages, supergroups only"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()

View file

@ -0,0 +1,29 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Union
from ..types import ChatInviteLink
from .base import Request, TelegramMethod
if TYPE_CHECKING: # pragma: no cover
from ..client.bot import Bot
class RevokeChatInviteLink(TelegramMethod[ChatInviteLink]):
"""
Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#revokechatinvitelink
"""
__returning__ = ChatInviteLink
chat_id: Union[int, str]
"""Unique identifier of the target chat or username of the target channel (in the format :code:`@channelusername`)"""
invite_link: str
"""The invite link to revoke"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="revokeChatInviteLink", data=data)

View file

@ -27,7 +27,7 @@ class SendDice(TelegramMethod[Message]):
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
emoji: Optional[str] = None
"""Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', or '🎰'. Dice can have values 1-6 for '🎲' and '🎯', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'"""
"""Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
reply_to_message_id: Optional[int] = None

View file

@ -37,7 +37,7 @@ class SetWebhook(TelegramMethod[bool]):
max_connections: Optional[int] = None
"""Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to *40*. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput."""
allowed_updates: Optional[List[str]] = None
"""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 updates regardless of type (default). If not specified, the previous setting will be used."""
"""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."""
drop_pending_updates: Optional[bool] = None
"""Pass :code:`True` to drop all pending updates"""

View file

@ -5,8 +5,10 @@ from .bot_command import BotCommand
from .callback_game import CallbackGame
from .callback_query import CallbackQuery
from .chat import Chat
from .chat_invite_link import ChatInviteLink
from .chat_location import ChatLocation
from .chat_member import ChatMember
from .chat_member_updated import ChatMemberUpdated
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto
from .chosen_inline_result import ChosenInlineResult
@ -64,6 +66,7 @@ from .location import Location
from .login_url import LoginUrl
from .mask_position import MaskPosition
from .message import ContentType, Message
from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged
from .message_entity import MessageEntity
from .message_id import MessageId
from .order_info import OrderInfo
@ -101,6 +104,9 @@ from .venue import Venue
from .video import Video
from .video_note import VideoNote
from .voice import Voice
from .voice_chat_ended import VoiceChatEnded
from .voice_chat_participants_invited import VoiceChatParticipantsInvited
from .voice_chat_started import VoiceChatStarted
from .webhook_info import WebhookInfo
__all__ = (
@ -133,6 +139,10 @@ __all__ = (
"Location",
"Venue",
"ProximityAlertTriggered",
"MessageAutoDeleteTimerChanged",
"VoiceChatStarted",
"VoiceChatEnded",
"VoiceChatParticipantsInvited",
"UserProfilePhotos",
"File",
"ReplyKeyboardMarkup",
@ -145,7 +155,9 @@ __all__ = (
"CallbackQuery",
"ForceReply",
"ChatPhoto",
"ChatInviteLink",
"ChatMember",
"ChatMemberUpdated",
"ChatPermissions",
"ChatLocation",
"BotCommand",

View file

@ -19,7 +19,7 @@ class Chat(TelegramObject):
"""
id: int
"""Unique identifier for this chat. 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."""
"""Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier."""
type: str
"""Type of chat, can be either 'private', 'group', 'supergroup' or 'channel'"""
title: Optional[str] = None
@ -37,13 +37,15 @@ class Chat(TelegramObject):
description: Optional[str] = None
"""*Optional*. Description, for groups, supergroups and channel chats. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
invite_link: Optional[str] = None
"""*Optional*. Chat invite link, for groups, supergroups and channel chats. Each administrator in a chat generates their own invite links, so the bot must first generate the link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink`. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
"""*Optional*. Primary invite link, for groups, supergroups and channel chats. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
pinned_message: Optional[Message] = None
"""*Optional*. The most recent pinned message (by sending date). Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
permissions: Optional[ChatPermissions] = None
"""*Optional*. Default chat member permissions, for groups and supergroups. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
slow_mode_delay: Optional[int] = None
"""*Optional*. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
message_auto_delete_time: Optional[int] = None
"""*Optional*. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
sticker_set_name: Optional[str] = None
"""*Optional*. For supergroups, name of group sticker set. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
can_set_sticker_set: Optional[bool] = None

View file

@ -0,0 +1,29 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
from .user import User
class ChatInviteLink(TelegramObject):
"""
Represents an invite link for a chat.
Source: https://core.telegram.org/bots/api#chatinvitelink
"""
invite_link: str
"""The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with ''."""
creator: User
"""Creator of the link"""
is_primary: bool
"""True, if the link is primary"""
is_revoked: bool
"""True, if the link is revoked"""
expire_date: Optional[int] = None
"""*Optional*. Point in time (Unix timestamp) when the link will expire or has been expired"""
member_limit: Optional[int] = None
"""*Optional*. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""

View file

@ -28,12 +28,16 @@ class ChatMember(TelegramObject):
"""*Optional*. Owner and administrators only. True, if the user's presence in the chat is hidden"""
can_be_edited: Optional[bool] = None
"""*Optional*. Administrators only. True, if the bot is allowed to edit administrator privileges of that user"""
can_manage_chat: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege"""
can_post_messages: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can post in the channel; channels only"""
can_edit_messages: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can edit messages of other users and can pin messages; channels only"""
can_delete_messages: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can delete messages of other users"""
can_manage_voice_chats: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can manage voice chats"""
can_restrict_members: Optional[bool] = None
"""*Optional*. Administrators only. True, if the administrator can restrict, ban or unban chat members"""
can_promote_members: Optional[bool] = None
@ -58,7 +62,6 @@ class ChatMember(TelegramObject):
"""*Optional*. Restricted only. True, if the user is allowed to add web page previews to their messages"""
until_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""*Optional*. Restricted and kicked only. Date when restrictions will be lifted for this user; unix time"""
"""Restricted and kicked only. Date when restrictions will be lifted for this user; unix time"""
@property
def is_chat_admin(self) -> bool:

View file

@ -0,0 +1,35 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Optional
from pydantic import Field
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
from .chat import Chat
from .chat_invite_link import ChatInviteLink
from .chat_member import ChatMember
from .user import User
class ChatMemberUpdated(TelegramObject):
"""
This object represents changes in the status of a chat member.
Source: https://core.telegram.org/bots/api#chatmemberupdated
"""
chat: Chat
"""Chat the user belongs to"""
from_user: User = Field(..., alias="from")
"""Performer of the action, which resulted in the change"""
date: datetime.datetime
"""Date the change was done in Unix time"""
old_chat_member: ChatMember
"""Previous information about the chat member"""
new_chat_member: ChatMember
"""New information about the chat member"""
invite_link: Optional[ChatInviteLink] = None
"""*Optional*. Chat invite link, which was used by the user to join the chat; for joining by invite link events only."""

View file

@ -19,6 +19,6 @@ class Contact(TelegramObject):
last_name: Optional[str] = None
"""*Optional*. Contact's last name"""
user_id: Optional[int] = None
"""*Optional*. Contact's user identifier in Telegram"""
"""*Optional*. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier."""
vcard: Optional[str] = None
"""*Optional*. Additional data about the contact in the form of a `vCard <https://en.wikipedia.org/wiki/VCard>`_"""

View file

@ -13,7 +13,7 @@ class Dice(TelegramObject):
emoji: str
"""Emoji on which the dice throw animation is based"""
value: int
"""Value of the dice, 1-6 for '🎲' and '🎯' base emoji, 1-5 for '🏀' and '' base emoji, 1-64 for '🎰' base emoji"""
"""Value of the dice, 1-6 for '🎲', '🎯' and '🎳' base emoji, 1-5 for '🏀' and '' base emoji, 1-64 for '🎰' base emoji"""
class DiceEmoji:
@ -22,3 +22,4 @@ class DiceEmoji:
BASKETBALL = "🏀"
FOOTBALL = ""
SLOT_MACHINE = "🎰"
BOWLING = "🎳"

View file

@ -28,5 +28,7 @@ class InlineQueryResult(MutableTelegramObject):
- :class:`aiogram.types.inline_query_result_video.InlineQueryResultVideo`
- :class:`aiogram.types.inline_query_result_voice.InlineQueryResultVoice`
**Note:** All URLs passed in inline query results will be available to end users and therefore must be assumed to be public.
Source: https://core.telegram.org/bots/api#inlinequeryresult
"""

View file

@ -11,6 +11,7 @@ from .base import UNSET, TelegramObject
if TYPE_CHECKING: # pragma: no cover
from ..methods import (
CopyMessage,
SendAnimation,
SendAudio,
SendContact,
@ -44,6 +45,7 @@ if TYPE_CHECKING: # pragma: no cover
from .invoice import Invoice
from .labeled_price import LabeledPrice
from .location import Location
from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged
from .message_entity import MessageEntity
from .passport_data import PassportData
from .photo_size import PhotoSize
@ -58,6 +60,9 @@ if TYPE_CHECKING: # pragma: no cover
from .video import Video
from .video_note import VideoNote
from .voice import Voice
from .voice_chat_ended import VoiceChatEnded
from .voice_chat_participants_invited import VoiceChatParticipantsInvited
from .voice_chat_started import VoiceChatStarted
class Message(TelegramObject):
@ -151,10 +156,12 @@ class Message(TelegramObject):
"""*Optional*. 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: Optional[bool] = None
"""*Optional*. 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."""
message_auto_delete_timer_changed: Optional[MessageAutoDeleteTimerChanged] = None
"""*Optional*. Service message: auto-delete timer settings changed in the chat"""
migrate_to_chat_id: Optional[int] = None
"""*Optional*. 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."""
"""*Optional*. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier."""
migrate_from_chat_id: Optional[int] = None
"""*Optional*. 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."""
"""*Optional*. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier."""
pinned_message: Optional[Message] = None
"""*Optional*. 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: Optional[Invoice] = None
@ -167,6 +174,12 @@ class Message(TelegramObject):
"""*Optional*. Telegram Passport data"""
proximity_alert_triggered: Optional[ProximityAlertTriggered] = None
"""*Optional*. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location."""
voice_chat_started: Optional[VoiceChatStarted] = None
"""*Optional*. Service message: voice chat started"""
voice_chat_ended: Optional[VoiceChatEnded] = None
"""*Optional*. Service message: voice chat ended"""
voice_chat_participants_invited: Optional[VoiceChatParticipantsInvited] = None
"""*Optional*. Service message: new participants invited to a voice chat"""
reply_markup: Optional[InlineKeyboardMarkup] = None
"""*Optional*. Inline keyboard attached to the message. :code:`login_url` buttons are represented as ordinary :code:`url` buttons."""
@ -228,6 +241,14 @@ class Message(TelegramObject):
return ContentType.POLL
if self.dice:
return ContentType.DICE
if self.message_auto_delete_timer_changed:
return ContentType.MESSAGE_AUTO_DELETE_TIMER_CHANGED
if self.voice_chat_started:
return ContentType.VOICE_CHAT_STARTED
if self.voice_chat_ended:
return ContentType.VOICE_CHAT_ENDED
if self.voice_chat_participants_invited:
return ContentType.VOICE_CHAT_PARTICIPANTS_INVITED
return ContentType.UNKNOWN
@ -1517,6 +1538,179 @@ class Message(TelegramObject):
reply_markup=reply_markup,
)
def send_copy(
self: Message,
chat_id: Union[str, int],
disable_notification: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
reply_markup: Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, None] = None,
) -> Union[
SendAnimation,
SendAudio,
SendContact,
SendDocument,
SendLocation,
SendMessage,
SendPhoto,
SendPoll,
SendDice,
SendSticker,
SendVenue,
SendVideo,
SendVideoNote,
SendVoice,
]:
"""
Send copy of message.
Is similar to :meth:`aiogram.client.bot.Bot.copy_message`
but returning the sent message instead of :class:`aiogram.types.message_id.MessageId`
.. note::
This method don't use the API method named `copyMessage` and
historically implemented before the similar method is added to API
:param chat_id:
:param disable_notification:
:param reply_to_message_id:
:param reply_markup:
:return:
"""
from ..methods import (
SendAnimation,
SendAudio,
SendContact,
SendDice,
SendDocument,
SendLocation,
SendMessage,
SendPhoto,
SendPoll,
SendSticker,
SendVenue,
SendVideo,
SendVideoNote,
SendVoice,
)
kwargs = {
"chat_id": chat_id,
"reply_markup": reply_markup or self.reply_markup,
"disable_notification": disable_notification,
"reply_to_message_id": reply_to_message_id,
}
text = self.text or self.caption
entities = self.entities or self.caption_entities
if self.text:
return SendMessage(text=text, entities=entities, **kwargs)
elif self.audio:
return SendAudio(
audio=self.audio.file_id,
caption=text,
title=self.audio.title,
performer=self.audio.performer,
duration=self.audio.duration,
caption_entities=entities,
**kwargs,
)
elif self.animation:
return SendAnimation(
animation=self.animation.file_id, caption=text, caption_entities=entities, **kwargs
)
elif self.document:
return SendDocument(
document=self.document.file_id, caption=text, caption_entities=entities, **kwargs
)
elif self.photo:
return SendPhoto(
photo=self.photo[-1].file_id, caption=text, caption_entities=entities, **kwargs
)
elif self.sticker:
return SendSticker(sticker=self.sticker.file_id, **kwargs)
elif self.video:
return SendVideo(
video=self.video.file_id, caption=text, caption_entities=entities, **kwargs
)
elif self.video_note:
return SendVideoNote(video_note=self.video_note.file_id, **kwargs)
elif self.voice:
return SendVoice(voice=self.voice.file_id, **kwargs)
elif self.contact:
return SendContact(
phone_number=self.contact.phone_number,
first_name=self.contact.first_name,
last_name=self.contact.last_name,
vcard=self.contact.vcard,
**kwargs,
)
elif self.venue:
return SendVenue(
latitude=self.venue.location.latitude,
longitude=self.venue.location.longitude,
title=self.venue.title,
address=self.venue.address,
foursquare_id=self.venue.foursquare_id,
foursquare_type=self.venue.foursquare_type,
**kwargs,
)
elif self.location:
return SendLocation(
latitude=self.location.latitude, longitude=self.location.longitude, **kwargs
)
elif self.poll:
return SendPoll(
question=self.poll.question,
options=[option.text for option in self.poll.options],
**kwargs,
)
elif self.dice: # Dice value can't be controlled
return SendDice(**kwargs)
else:
raise TypeError("This type of message can't be copied.")
async def copy_to(
self,
chat_id: Union[int, str],
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
) -> CopyMessage:
"""
Copy message
:param chat_id:
:param caption:
:param parse_mode:
:param caption_entities:
:param disable_notification:
:param reply_to_message_id:
:param allow_sending_without_reply:
:param reply_markup:
:return:
"""
from ..methods import CopyMessage
return CopyMessage(
chat_id=chat_id,
from_chat_id=self.chat.id,
message_id=self.message_id,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
)
class ContentType(helper.Helper):
mode = helper.HelperMode.snake_case
@ -1549,6 +1743,10 @@ class ContentType(helper.Helper):
PASSPORT_DATA = helper.Item() # passport_data
POLL = helper.Item() # poll
DICE = helper.Item() # dice
MESSAGE_AUTO_DELETE_TIMER_CHANGED = helper.Item() # message_auto_delete_timer_changed
VOICE_CHAT_STARTED = helper.Item() # voice_chat_started
VOICE_CHAT_ENDED = helper.Item() # voice_chat_ended
VOICE_CHAT_PARTICIPANTS_INVITED = helper.Item() # voice_chat_participants_invited
UNKNOWN = helper.Item() # unknown
ANY = helper.Item() # any

View file

@ -0,0 +1,19 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
pass
class MessageAutoDeleteTimerChanged(TelegramObject):
"""
This object represents a service message about a change in auto-delete timer settings.
Source: https://core.telegram.org/bots/api#messageautodeletetimerchanged
"""
message_auto_delete_time: int
"""New auto-delete time for messages in the chat"""

View file

@ -13,6 +13,6 @@ class ResponseParameters(TelegramObject):
"""
migrate_to_chat_id: Optional[int] = None
"""*Optional*. 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."""
"""*Optional*. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier."""
retry_after: Optional[int] = None
"""*Optional*. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated"""

View file

@ -6,6 +6,7 @@ from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
from .callback_query import CallbackQuery
from .chat_member_updated import ChatMemberUpdated
from .chosen_inline_result import ChosenInlineResult
from .inline_query import InlineQuery
from .message import Message
@ -48,3 +49,7 @@ class Update(TelegramObject):
"""*Optional*. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot"""
poll_answer: Optional[PollAnswer] = None
"""*Optional*. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself."""
my_chat_member: Optional[ChatMemberUpdated] = None
"""*Optional*. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user."""
chat_member: Optional[ChatMemberUpdated] = None
"""*Optional*. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify 'chat_member' in the list of *allowed_updates* to receive these updates."""

View file

@ -13,7 +13,7 @@ class User(TelegramObject):
"""
id: int
"""Unique identifier for this user or bot"""
"""Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier."""
is_bot: bool
"""True, if this user is a bot"""
first_name: str

View file

@ -0,0 +1,19 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
pass
class VoiceChatEnded(TelegramObject):
"""
This object represents a service message about a voice chat ended in the chat.
Source: https://core.telegram.org/bots/api#voicechatended
"""
duration: int
"""Voice chat duration; in seconds"""

View file

@ -0,0 +1,19 @@
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
from .user import User
class VoiceChatParticipantsInvited(TelegramObject):
"""
This object represents a service message about new members invited to a voice chat.
Source: https://core.telegram.org/bots/api#voicechatparticipantsinvited
"""
users: Optional[List[User]] = None
"""*Optional*. New members that were invited to the voice chat"""

View file

@ -0,0 +1,16 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from .base import TelegramObject
if TYPE_CHECKING: # pragma: no cover
pass
class VoiceChatStarted(TelegramObject):
"""
This object represents a service message about a voice chat started in the chat. Currently holds no information.
Source: https://core.telegram.org/bots/api#voicechatstarted
"""

View file

@ -27,4 +27,4 @@ class WebhookInfo(TelegramObject):
max_connections: Optional[int] = None
"""*Optional*. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery"""
allowed_updates: Optional[List[str]] = None
"""*Optional*. A list of update types the bot is subscribed to. Defaults to all update types"""
"""*Optional*. A list of update types the bot is subscribed to. Defaults to all update types except *chat_member*"""

View file

@ -1 +1 @@
4.9
5.1

View file

@ -1 +1 @@
3.0.0a6
3.0.0a7

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return AddStickerToSet(...)
return AddStickerToSet(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return AnswerCallbackQuery(...)
return AnswerCallbackQuery(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return AnswerInlineQuery(...)
return AnswerInlineQuery(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return AnswerPreCheckoutQuery(...)
return AnswerPreCheckoutQuery(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return AnswerShippingQuery(...)
return AnswerShippingQuery(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return Close(...)
return Close(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return CopyMessage(...)
return CopyMessage(...)

View file

@ -0,0 +1,51 @@
####################
createChatInviteLink
####################
Returns: :obj:`ChatInviteLink`
.. automodule:: aiogram.methods.create_chat_invite_link
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: ChatInviteLink = await bot.create_chat_invite_link(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.create_chat_invite_link import CreateChatInviteLink`
- alias: :code:`from aiogram.methods import CreateChatInviteLink`
In handlers with current bot
----------------------------
.. code-block:: python
result: ChatInviteLink = await CreateChatInviteLink(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: ChatInviteLink = await bot(CreateChatInviteLink(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
return CreateChatInviteLink(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return CreateNewStickerSet(...)
return CreateNewStickerSet(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return DeleteChatPhoto(...)
return DeleteChatPhoto(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return DeleteChatStickerSet(...)
return DeleteChatStickerSet(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return DeleteMessage(...)
return DeleteMessage(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return DeleteStickerFromSet(...)
return DeleteStickerFromSet(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return DeleteWebhook(...)
return DeleteWebhook(...)

View file

@ -0,0 +1,51 @@
##################
editChatInviteLink
##################
Returns: :obj:`ChatInviteLink`
.. automodule:: aiogram.methods.edit_chat_invite_link
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: ChatInviteLink = await bot.edit_chat_invite_link(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.edit_chat_invite_link import EditChatInviteLink`
- alias: :code:`from aiogram.methods import EditChatInviteLink`
In handlers with current bot
----------------------------
.. code-block:: python
result: ChatInviteLink = await EditChatInviteLink(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: ChatInviteLink = await bot(EditChatInviteLink(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
return EditChatInviteLink(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return EditMessageCaption(...)
return EditMessageCaption(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return EditMessageLiveLocation(...)
return EditMessageLiveLocation(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return EditMessageMedia(...)
return EditMessageMedia(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return EditMessageReplyMarkup(...)
return EditMessageReplyMarkup(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return EditMessageText(...)
return EditMessageText(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return ExportChatInviteLink(...)
return ExportChatInviteLink(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return ForwardMessage(...)
return ForwardMessage(...)

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: Chat = await bot(GetChat(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: List[ChatMember] = await bot(GetChatAdministrators(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: ChatMember = await bot(GetChatMember(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: int = await bot(GetChatMembersCount(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: File = await bot(GetFile(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: List[GameHighScore] = await bot(GetGameHighScores(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: User = await bot(GetMe(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: List[BotCommand] = await bot(GetMyCommands(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: StickerSet = await bot(GetStickerSet(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: List[Update] = await bot(GetUpdates(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: UserProfilePhotos = await bot(GetUserProfilePhotos(...))

View file

@ -42,4 +42,3 @@ With specific bot
.. code-block:: python
result: WebhookInfo = await bot(GetWebhookInfo(...))

View file

@ -55,6 +55,9 @@ Available methods
set_chat_administrator_custom_title
set_chat_permissions
export_chat_invite_link
create_chat_invite_link
edit_chat_invite_link
revoke_chat_invite_link
set_chat_photo
delete_chat_photo
set_chat_title
@ -136,4 +139,3 @@ Games
send_game
set_game_score
get_game_high_scores

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return KickChatMember(...)
return KickChatMember(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return LeaveChat(...)
return LeaveChat(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return LogOut(...)
return LogOut(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return PinChatMessage(...)
return PinChatMessage(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return PromoteChatMember(...)
return PromoteChatMember(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return RestrictChatMember(...)
return RestrictChatMember(...)

View file

@ -0,0 +1,51 @@
####################
revokeChatInviteLink
####################
Returns: :obj:`ChatInviteLink`
.. automodule:: aiogram.methods.revoke_chat_invite_link
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: ChatInviteLink = await bot.revoke_chat_invite_link(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.revoke_chat_invite_link import RevokeChatInviteLink`
- alias: :code:`from aiogram.methods import RevokeChatInviteLink`
In handlers with current bot
----------------------------
.. code-block:: python
result: ChatInviteLink = await RevokeChatInviteLink(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: ChatInviteLink = await bot(RevokeChatInviteLink(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
return RevokeChatInviteLink(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendAnimation(...)
return SendAnimation(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendAudio(...)
return SendAudio(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendChatAction(...)
return SendChatAction(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendContact(...)
return SendContact(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendDice(...)
return SendDice(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendDocument(...)
return SendDocument(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendGame(...)
return SendGame(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendInvoice(...)
return SendInvoice(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendLocation(...)
return SendLocation(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendMediaGroup(...)
return SendMediaGroup(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendMessage(...)
return SendMessage(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendPhoto(...)
return SendPhoto(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendPoll(...)
return SendPoll(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendSticker(...)
return SendSticker(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendVenue(...)
return SendVenue(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendVideo(...)
return SendVideo(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendVideoNote(...)
return SendVideoNote(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SendVoice(...)
return SendVoice(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SetChatAdministratorCustomTitle(...)
return SetChatAdministratorCustomTitle(...)

View file

@ -48,4 +48,4 @@ As reply into Webhook in handler
.. code-block:: python
return SetChatDescription(...)
return SetChatDescription(...)

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