Merge pull request #250 from gabbhack/4.5

Bot API 4.5 (without MarkdownV2)
This commit is contained in:
Alex Root Junior 2019-12-31 21:14:47 +02:00 committed by GitHub
commit b66ad8762d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 47 additions and 1 deletions

View file

@ -188,6 +188,7 @@ class Methods(Helper):
UNBAN_CHAT_MEMBER = Item() # unbanChatMember
RESTRICT_CHAT_MEMBER = Item() # restrictChatMember
PROMOTE_CHAT_MEMBER = Item() # promoteChatMember
SET_CHAT_ADMINISTRATOR_CUSTOM_TITLE = Item() # setChatAdministratorCustomTitle
SET_CHAT_PERMISSIONS = Item() # setChatPermissions
EXPORT_CHAT_INVITE_LINK = Item() # exportChatInviteLink
SET_CHAT_PHOTO = Item() # setChatPhoto

View file

@ -1118,6 +1118,24 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
result = await self.request(api.Methods.PROMOTE_CHAT_MEMBER, payload)
return result
async def set_chat_administrator_custom_title(self, chat_id: typing.Union[base.Integer, base.String], user_id: base.Integer, custom_title: base.String) -> base.Boolean:
"""
Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
Returns True on success.
Source: https://core.telegram.org/bots/api#setchatadministratorcustomtitle
:param chat_id: Unique identifier for the target chat or username of the target supergroup
:param user_id: Unique identifier of the target user
:param custom_title: New custom title for the administrator; 0-16 characters, emoji are not allowed
:return: True on success.
"""
payload = generate_payload(**locals())
result = await self.request(api.Methods.SET_CHAT_ADMINISTRATOR_CUSTOM_TITLE, payload)
return result
async def set_chat_permissions(self, chat_id: typing.Union[base.Integer, base.String],
permissions: types.ChatPermissions) -> base.Boolean:

View file

@ -14,6 +14,7 @@ class Animation(base.TelegramObject, mixins.Downloadable):
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
thumb: PhotoSize = fields.Field(base=PhotoSize)
file_name: base.String = fields.Field()
mime_type: base.String = fields.Field()

View file

@ -11,6 +11,7 @@ class Audio(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#audio
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
duration: base.Integer = fields.Field()
performer: base.String = fields.Field()
title: base.String = fields.Field()

View file

@ -30,6 +30,7 @@ class Chat(base.TelegramObject):
invite_link: base.String = fields.Field()
pinned_message: 'Message' = fields.Field(base='Message')
permissions: ChatPermissions = fields.Field(base=ChatPermissions)
slow_mode_delay: base.Integer = fields.Field()
sticker_set_name: base.String = fields.Field()
can_set_sticker_set: base.Boolean = fields.Field()
@ -296,6 +297,20 @@ class Chat(base.TelegramObject):
can_pin_messages=can_pin_messages,
can_promote_members=can_promote_members)
async def set_administrator_custom_title(self, user_id: base.Integer, custom_title: base.String) -> base.Boolean:
"""
Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
Returns True on success.
Source: https://core.telegram.org/bots/api#setchatadministratorcustomtitle
:param user_id: Unique identifier of the target user
:param custom_title: New custom title for the administrator; 0-16 characters, emoji are not allowed
:return: True on success.
"""
return await self.bot.set_chat_administrator_custom_title(chat_id=self.id, user_id=user_id, custom_title=custom_title)
async def pin_message(self, message_id: int, disable_notification: bool = False):
"""
Use this method to pin a message in a supergroup.

View file

@ -16,6 +16,7 @@ class ChatMember(base.TelegramObject):
"""
user: User = fields.Field(base=User)
status: base.String = fields.Field()
custom_title: base.String = fields.Field()
until_date: datetime.datetime = fields.DateTimeField()
can_be_edited: base.Boolean = fields.Field()
can_change_info: base.Boolean = fields.Field()

View file

@ -12,7 +12,9 @@ class ChatPhoto(base.TelegramObject):
https://core.telegram.org/bots/api#chatphoto
"""
small_file_id: base.String = fields.Field()
small_file_unique_id: base.String = fields.Field()
big_file_id: base.String = fields.Field()
big_file_unique_id: base.String = fields.Field()
async def download_small(self, destination=None, timeout=30, chunk_size=65536, seek=True, make_dirs=True):
"""

View file

@ -11,6 +11,7 @@ class Document(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#document
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
thumb: PhotoSize = fields.Field(base=PhotoSize)
file_name: base.String = fields.Field()
mime_type: base.String = fields.Field()

View file

@ -17,5 +17,6 @@ class File(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#file
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
file_size: base.Integer = fields.Field()
file_path: base.String = fields.Field()

View file

@ -9,7 +9,7 @@ class PassportFile(base.TelegramObject):
https://core.telegram.org/bots/api#passportfile
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
file_size: base.Integer = fields.Field()
file_date: base.Integer = fields.Field()

View file

@ -10,6 +10,7 @@ class PhotoSize(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#photosize
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
width: base.Integer = fields.Field()
height: base.Integer = fields.Field()
file_size: base.Integer = fields.Field()

View file

@ -12,6 +12,7 @@ class Sticker(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#sticker
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
width: base.Integer = fields.Field()
height: base.Integer = fields.Field()
is_animated: base.Boolean = fields.Field()

View file

@ -11,6 +11,7 @@ class Video(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#video
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
width: base.Integer = fields.Field()
height: base.Integer = fields.Field()
duration: base.Integer = fields.Field()

View file

@ -11,6 +11,7 @@ class VideoNote(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#videonote
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
length: base.Integer = fields.Field()
duration: base.Integer = fields.Field()
thumb: PhotoSize = fields.Field(base=PhotoSize)

View file

@ -10,6 +10,7 @@ class Voice(base.TelegramObject, mixins.Downloadable):
https://core.telegram.org/bots/api#voice
"""
file_id: base.String = fields.Field()
file_unique_id: base.String = fields.Field()
duration: base.Integer = fields.Field()
mime_type: base.String = fields.Field()
file_size: base.Integer = fields.Field()