From a80927baf9fa9ec60e7df07d84fdf060f915e11a Mon Sep 17 00:00:00 2001 From: Anthony Byuraev Date: Sat, 9 May 2020 23:23:08 +0300 Subject: [PATCH] UPG: add setChatAdministratorCustomTitle --- telebot/__init__.py | 14 ++++++++++++++ telebot/apihelper.py | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index d67d40a..0c4cf8a 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -985,6 +985,20 @@ class TeleBot: can_edit_messages, can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members) + def set_chat_administrator_custom_title(self, chat_id, user_id, custom_title): + """ + 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 + (in the format @supergroupusername) + :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: + """ + return apihelper.set_chat_administrator_custom_title(self.token, chat_id, user_id, custom_title) + def export_chat_invite_link(self, chat_id): """ Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 97a7a66..fbf58c0 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -586,7 +586,6 @@ def restrict_chat_member(token, chat_id, user_id, until_date=None, can_send_mess payload['can_add_web_page_previews'] = can_add_web_page_previews if can_invite_users: payload['can_invite_users'] = can_invite_users - return _make_request(token, method_url, params=payload, method='post') @@ -614,6 +613,13 @@ def promote_chat_member(token, chat_id, user_id, can_change_info=None, can_post_ return _make_request(token, method_url, params=payload, method='post') +def set_chat_administrator_custom_title(token, chat_id, user_id, custom_title): + method_url = 'setChatAdministratorCustomTitle' + payload = { + 'chat_id': chat_id, 'user_id': user_id, 'custom_title': custom_title} + return _make_request(token, method_url, params=payload, method='post') + + def export_chat_invite_link(token, chat_id): method_url = 'exportChatInviteLink' payload = {'chat_id': chat_id}