Regenerate code

This commit is contained in:
jrootjunior 2019-11-14 14:44:17 +02:00
parent 5d1c54aa17
commit 4189c3e798
77 changed files with 271 additions and 233 deletions

View file

@ -1,3 +1,4 @@
import datetime
from typing import List, Optional, Union
from ..methods import (
@ -77,9 +78,6 @@ from ..types import (
InlineKeyboardMarkup,
InlineQueryResult,
InputFile,
InputMedia,
InputMediaPhoto,
InputMediaVideo,
LabeledPrice,
MaskPosition,
Message,
@ -97,7 +95,7 @@ from ..types import (
from .base import BaseBot
class Bot(ContextInstanceMixin, BaseBot):
class Bot(BaseBot):
"""
Class where located all API methods
"""
@ -134,7 +132,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:rtype: :obj:`List[Update]`
"""
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.emit(call)
@ -675,7 +673,7 @@ class Bot(ContextInstanceMixin, BaseBot):
async def send_media_group(
self,
chat_id: Union[int, str],
media: List[Union[InputMediaPhoto, InputMediaVideo]],
media: Union[str, InputFile],
disable_notification: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
) -> List[Message]:
@ -687,7 +685,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
:type chat_id: :obj:`Union[int, str]`
:param media: A JSON-serialized array describing photos and videos to be sent, must include 210 items
:type media: :obj:`List[Union[InputMediaPhoto, InputMediaVideo]]`
:type media: :obj:`Union[str, InputFile]`
:param disable_notification: Sends the messages silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`Optional[bool]`
:param reply_to_message_id: If the messages are a reply, ID of the original message
@ -965,7 +963,7 @@ class Bot(ContextInstanceMixin, BaseBot):
)
return await self.emit(call)
async def send_chat_action(self, chat_id: Union[int, str], action: str) -> bool:
async def send_chat_action(self, chat_id: Union[int, str], action: str,) -> 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 True on success.
Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of 'Retrieving image, please wait…', the bot may use sendChatAction with action = upload_photo. The user will see a 'sending photo' status for the bot.
@ -980,11 +978,11 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SendChatAction(chat_id=chat_id, action=action)
call = SendChatAction(chat_id=chat_id, action=action,)
return await self.emit(call)
async def get_user_profile_photos(
self, user_id: int, offset: Optional[int] = None, limit: Optional[int] = None
self, user_id: int, offset: Optional[int] = None, limit: Optional[int] = None,
) -> UserProfilePhotos:
"""
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
@ -1000,10 +998,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns a UserProfilePhotos object.
:rtype: :obj:`UserProfilePhotos`
"""
call = GetUserProfilePhotos(user_id=user_id, offset=offset, limit=limit)
call = GetUserProfilePhotos(user_id=user_id, offset=offset, limit=limit,)
return await self.emit(call)
async def get_file(self, file_id: str) -> File:
async def get_file(self, file_id: str,) -> 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 File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <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 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.
@ -1015,11 +1013,14 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: On success, a File object is returned.
:rtype: :obj:`File`
"""
call = GetFile(file_id=file_id)
call = GetFile(file_id=file_id,)
return await self.emit(call)
async def kick_chat_member(
self, chat_id: Union[int, str], user_id: int, until_date: Optional[int] = None
self,
chat_id: Union[int, str],
user_id: int,
until_date: Optional[Union[int, datetime.datetime, datetime.timedelta]] = None,
) -> bool:
"""
Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
@ -1031,14 +1032,14 @@ class Bot(ContextInstanceMixin, BaseBot):
:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`
: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
:type until_date: :obj:`Optional[int]`
:type until_date: :obj:`Optional[Union[int, datetime.datetime, datetime.timedelta]]`
:return: In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc. Returns True on success.
:rtype: :obj:`bool`
"""
call = KickChatMember(chat_id=chat_id, user_id=user_id, until_date=until_date)
call = KickChatMember(chat_id=chat_id, user_id=user_id, until_date=until_date,)
return await self.emit(call)
async def unban_chat_member(self, chat_id: Union[int, str], user_id: int) -> bool:
async def unban_chat_member(self, chat_id: Union[int, str], user_id: int,) -> bool:
"""
Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. Returns True on success.
@ -1051,7 +1052,7 @@ class Bot(ContextInstanceMixin, BaseBot):
: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.
:rtype: :obj:`bool`
"""
call = UnbanChatMember(chat_id=chat_id, user_id=user_id)
call = UnbanChatMember(chat_id=chat_id, user_id=user_id,)
return await self.emit(call)
async def restrict_chat_member(
@ -1059,7 +1060,7 @@ class Bot(ContextInstanceMixin, BaseBot):
chat_id: Union[int, str],
user_id: int,
permissions: ChatPermissions,
until_date: Optional[int] = None,
until_date: Optional[Union[int, datetime.datetime, datetime.timedelta]] = None,
) -> bool:
"""
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
@ -1073,12 +1074,12 @@ class Bot(ContextInstanceMixin, BaseBot):
:param permissions: New user permissions
:type permissions: :obj:`ChatPermissions`
:param until_date: Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
:type until_date: :obj:`Optional[int]`
:type until_date: :obj:`Optional[Union[int, datetime.datetime, datetime.timedelta]]`
:return: Returns True on success.
:rtype: :obj:`bool`
"""
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.emit(call)
@ -1138,7 +1139,7 @@ class Bot(ContextInstanceMixin, BaseBot):
return await self.emit(call)
async def set_chat_permissions(
self, chat_id: Union[int, str], permissions: ChatPermissions
self, chat_id: Union[int, str], permissions: ChatPermissions,
) -> bool:
"""
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
@ -1152,10 +1153,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SetChatPermissions(chat_id=chat_id, permissions=permissions)
call = SetChatPermissions(chat_id=chat_id, permissions=permissions,)
return await self.emit(call)
async def export_chat_invite_link(self, chat_id: Union[int, str]) -> str:
async def export_chat_invite_link(self, chat_id: Union[int, str],) -> 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.
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 exportChatInviteLink after this the link will become available to the bot via the getChat method. If your bot needs to generate a new invite link replacing its previous one, use exportChatInviteLink again.
@ -1167,10 +1168,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns the new invite link as String on success.
:rtype: :obj:`str`
"""
call = ExportChatInviteLink(chat_id=chat_id)
call = ExportChatInviteLink(chat_id=chat_id,)
return await self.emit(call)
async def set_chat_photo(self, chat_id: Union[int, str], photo: InputFile) -> bool:
async def set_chat_photo(self, chat_id: Union[int, str], photo: InputFile,) -> 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 True on success.
@ -1183,10 +1184,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SetChatPhoto(chat_id=chat_id, photo=photo)
call = SetChatPhoto(chat_id=chat_id, photo=photo,)
return await self.emit(call)
async def delete_chat_photo(self, chat_id: Union[int, str]) -> bool:
async def delete_chat_photo(self, chat_id: Union[int, str],) -> 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 True on success.
@ -1197,10 +1198,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = DeleteChatPhoto(chat_id=chat_id)
call = DeleteChatPhoto(chat_id=chat_id,)
return await self.emit(call)
async def set_chat_title(self, chat_id: Union[int, str], title: str) -> bool:
async def set_chat_title(self, chat_id: Union[int, str], title: str,) -> 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 True on success.
@ -1213,11 +1214,11 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SetChatTitle(chat_id=chat_id, title=title)
call = SetChatTitle(chat_id=chat_id, title=title,)
return await self.emit(call)
async def set_chat_description(
self, chat_id: Union[int, str], description: Optional[str] = None
self, chat_id: Union[int, str], description: Optional[str] = None,
) -> bool:
"""
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
@ -1231,7 +1232,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SetChatDescription(chat_id=chat_id, description=description)
call = SetChatDescription(chat_id=chat_id, description=description,)
return await self.emit(call)
async def pin_chat_message(
@ -1255,11 +1256,11 @@ class Bot(ContextInstanceMixin, BaseBot):
:rtype: :obj:`bool`
"""
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.emit(call)
async def unpin_chat_message(self, chat_id: Union[int, str]) -> bool:
async def unpin_chat_message(self, chat_id: Union[int, str],) -> bool:
"""
Use this method to unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the can_pin_messages admin right in the supergroup or can_edit_messages admin right in the channel. Returns True on success.
@ -1270,10 +1271,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = UnpinChatMessage(chat_id=chat_id)
call = UnpinChatMessage(chat_id=chat_id,)
return await self.emit(call)
async def leave_chat(self, chat_id: Union[int, str]) -> bool:
async def leave_chat(self, chat_id: Union[int, str],) -> bool:
"""
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
@ -1284,10 +1285,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = LeaveChat(chat_id=chat_id)
call = LeaveChat(chat_id=chat_id,)
return await self.emit(call)
async def get_chat(self, chat_id: Union[int, str]) -> Chat:
async def get_chat(self, chat_id: Union[int, str],) -> 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 Chat object on success.
@ -1298,10 +1299,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns a Chat object on success.
:rtype: :obj:`Chat`
"""
call = GetChat(chat_id=chat_id)
call = GetChat(chat_id=chat_id,)
return await self.emit(call)
async def get_chat_administrators(self, chat_id: Union[int, str]) -> List[ChatMember]:
async def get_chat_administrators(self, chat_id: Union[int, str],) -> List[ChatMember]:
"""
Use this method to get a list of administrators in a chat. On success, returns an Array of 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.
@ -1312,10 +1313,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: On success, returns an Array of 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.
:rtype: :obj:`List[ChatMember]`
"""
call = GetChatAdministrators(chat_id=chat_id)
call = GetChatAdministrators(chat_id=chat_id,)
return await self.emit(call)
async def get_chat_members_count(self, chat_id: Union[int, str]) -> int:
async def get_chat_members_count(self, chat_id: Union[int, str],) -> int:
"""
Use this method to get the number of members in a chat. Returns Int on success.
@ -1326,10 +1327,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns Int on success.
:rtype: :obj:`int`
"""
call = GetChatMembersCount(chat_id=chat_id)
call = GetChatMembersCount(chat_id=chat_id,)
return await self.emit(call)
async def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> ChatMember:
async def get_chat_member(self, chat_id: Union[int, str], user_id: int,) -> ChatMember:
"""
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
@ -1342,10 +1343,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns a ChatMember object on success.
:rtype: :obj:`ChatMember`
"""
call = GetChatMember(chat_id=chat_id, user_id=user_id)
call = GetChatMember(chat_id=chat_id, user_id=user_id,)
return await self.emit(call)
async def set_chat_sticker_set(self, chat_id: Union[int, str], sticker_set_name: str) -> bool:
async def set_chat_sticker_set(self, chat_id: Union[int, str], sticker_set_name: str,) -> bool:
"""
Use this method to set a new group sticker set for 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 getChat requests to check if the bot can use this method. Returns True on success.
@ -1358,10 +1359,10 @@ class Bot(ContextInstanceMixin, BaseBot):
: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.
:rtype: :obj:`bool`
"""
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.emit(call)
async def delete_chat_sticker_set(self, chat_id: Union[int, str]) -> bool:
async def delete_chat_sticker_set(self, chat_id: Union[int, str],) -> 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 getChat requests to check if the bot can use this method. Returns True on success.
@ -1372,7 +1373,7 @@ class Bot(ContextInstanceMixin, BaseBot):
: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.
:rtype: :obj:`bool`
"""
call = DeleteChatStickerSet(chat_id=chat_id)
call = DeleteChatStickerSet(chat_id=chat_id,)
return await self.emit(call)
async def answer_callback_query(
@ -1500,7 +1501,7 @@ class Bot(ContextInstanceMixin, BaseBot):
async def edit_message_media(
self,
media: InputMedia,
media: Union[str, InputFile],
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
@ -1512,7 +1513,7 @@ class Bot(ContextInstanceMixin, BaseBot):
Source: https://core.telegram.org/bots/api#editmessagemedia
:param media: A JSON-serialized object for a new media content of the message
:type media: :obj:`InputMedia`
:type media: :obj:`Union[str, InputFile]`
:param chat_id: Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
:type chat_id: :obj:`Optional[Union[int, str]]`
:param message_id: Required if inline_message_id is not specified. Identifier of the message to edit
@ -1584,10 +1585,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: On success, the stopped Poll with the final results is returned.
:rtype: :obj:`Poll`
"""
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.emit(call)
async def delete_message(self, chat_id: Union[int, str], message_id: int) -> bool:
async def delete_message(self, chat_id: Union[int, str], message_id: int,) -> bool:
"""
Use this method to delete a message, including service messages, with the following limitations:
- A message can only be deleted if it was sent less than 48 hours ago.
@ -1607,7 +1608,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = DeleteMessage(chat_id=chat_id, message_id=message_id)
call = DeleteMessage(chat_id=chat_id, message_id=message_id,)
return await self.emit(call)
# =============================================================================================
@ -1652,7 +1653,7 @@ class Bot(ContextInstanceMixin, BaseBot):
)
return await self.emit(call)
async def get_sticker_set(self, name: str) -> StickerSet:
async def get_sticker_set(self, name: str,) -> StickerSet:
"""
Use this method to get a sticker set. On success, a StickerSet object is returned.
@ -1663,10 +1664,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: On success, a StickerSet object is returned.
:rtype: :obj:`StickerSet`
"""
call = GetStickerSet(name=name)
call = GetStickerSet(name=name,)
return await self.emit(call)
async def upload_sticker_file(self, user_id: int, png_sticker: InputFile) -> File:
async def upload_sticker_file(self, user_id: int, png_sticker: InputFile,) -> 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 File on success.
@ -1679,7 +1680,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns the uploaded File on success.
:rtype: :obj:`File`
"""
call = UploadStickerFile(user_id=user_id, png_sticker=png_sticker)
call = UploadStickerFile(user_id=user_id, png_sticker=png_sticker,)
return await self.emit(call)
async def create_new_sticker_set(
@ -1760,7 +1761,7 @@ class Bot(ContextInstanceMixin, BaseBot):
)
return await self.emit(call)
async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
async def set_sticker_position_in_set(self, sticker: str, position: int,) -> bool:
"""
Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.
@ -1773,10 +1774,10 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = SetStickerPositionInSet(sticker=sticker, position=position)
call = SetStickerPositionInSet(sticker=sticker, position=position,)
return await self.emit(call)
async def delete_sticker_from_set(self, sticker: str) -> bool:
async def delete_sticker_from_set(self, sticker: str,) -> bool:
"""
Use this method to delete a sticker from a set created by the bot. Returns True on success.
@ -1787,7 +1788,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: Returns True on success.
:rtype: :obj:`bool`
"""
call = DeleteStickerFromSet(sticker=sticker)
call = DeleteStickerFromSet(sticker=sticker,)
return await self.emit(call)
# =============================================================================================
@ -1983,7 +1984,7 @@ class Bot(ContextInstanceMixin, BaseBot):
return await self.emit(call)
async def answer_pre_checkout_query(
self, pre_checkout_query_id: str, ok: bool, error_message: Optional[str] = None
self, pre_checkout_query_id: str, ok: bool, error_message: Optional[str] = None,
) -> bool:
"""
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
@ -2000,7 +2001,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:rtype: :obj:`bool`
"""
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.emit(call)
@ -2010,7 +2011,7 @@ class Bot(ContextInstanceMixin, BaseBot):
# =============================================================================================
async def set_passport_data_errors(
self, user_id: int, errors: List[PassportElementError]
self, user_id: int, errors: List[PassportElementError],
) -> bool:
"""
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
@ -2025,7 +2026,7 @@ class Bot(ContextInstanceMixin, BaseBot):
:return: The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
:rtype: :obj:`bool`
"""
call = SetPassportDataErrors(user_id=user_id, errors=errors)
call = SetPassportDataErrors(user_id=user_id, errors=errors,)
return await self.emit(call)
# =============================================================================================