From 5ea0aa095d0c7a5961ae321d9c86d7374c490751 Mon Sep 17 00:00:00 2001 From: Gabben Date: Tue, 31 Dec 2019 23:00:37 +0500 Subject: [PATCH] New method from Bot API 4.5 - setChatAdministratorCustomTitle --- aiogram/bot/api.py | 1 + aiogram/bot/bot.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 9589c3e5..0c2d572f 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -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 diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 5e8f05d9..54f5afe2 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -1118,6 +1118,22 @@ 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. + + :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: