Skip to content

Commit ae6e7ad

Browse files
authored
Add style and icon_custom_emoji_id to InlineKeyboardButton and KeyboardButton
Add style and icon_custom_emoji_id to InlineKeyboardButton and KeyboardButton
1 parent bc4374f commit ae6e7ad

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

telebot/types.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,21 +2928,31 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
29282928
:param request_chat: Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will
29292929
send its identifier to the bot in a “chat_shared” service message. Available in private chats only.
29302930
:type request_chat: :class:`telebot.types.KeyboardButtonRequestChat`
2931+
2932+
:param icon_custom_emoji_id: Optional. Custom emoji identifier to be shown on the button.
2933+
Can only be used if the bot has a Telegram Premium subscription.
2934+
:type icon_custom_emoji_id: :obj:`str`
2935+
2936+
:param style: Optional. Style of the button. Can be used to change the color of the button.
2937+
:type style: :obj:`str`
29312938

29322939
:return: Instance of the class
29332940
:rtype: :class:`telebot.types.KeyboardButton`
29342941
"""
29352942
def __init__(self, text: str, request_contact: Optional[bool]=None,
29362943
request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None,
29372944
web_app: Optional[WebAppInfo]=None, request_user: Optional[KeyboardButtonRequestUser]=None,
2938-
request_chat: Optional[KeyboardButtonRequestChat]=None, request_users: Optional[KeyboardButtonRequestUsers]=None):
2945+
request_chat: Optional[KeyboardButtonRequestChat]=None, request_users: Optional[KeyboardButtonRequestUsers]=None,
2946+
icon_custom_emoji_id: Optional[str]=None, style: Optional[str]=None):
29392947
self.text: str = text
29402948
self.request_contact: Optional[bool] = request_contact
29412949
self.request_location: Optional[bool] = request_location
29422950
self.request_poll: Optional[KeyboardButtonPollType] = request_poll
29432951
self.web_app: Optional[WebAppInfo] = web_app
29442952
self.request_chat: Optional[KeyboardButtonRequestChat] = request_chat
29452953
self.request_users: Optional[KeyboardButtonRequestUsers] = request_users
2954+
self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
2955+
self.style: Optional[str] = style
29462956
if request_user is not None:
29472957
log_deprecation_warning('The parameter "request_user" is deprecated, use "request_users" instead')
29482958
if self.request_users is None:
@@ -2967,6 +2977,10 @@ def to_dict(self):
29672977
json_dict['request_users'] = self.request_users.to_dict()
29682978
if self.request_chat is not None:
29692979
json_dict['request_chat'] = self.request_chat.to_dict()
2980+
if self.icon_custom_emoji_id is not None:
2981+
json_dict['icon_custom_emoji_id'] = self.icon_custom_emoji_id
2982+
if self.style is not None:
2983+
json_dict['style'] = self.style
29702984
return json_dict
29712985

29722986

@@ -3133,6 +3147,13 @@ class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable)
31333147

31343148
:param copy_text: Optional. Description of the button that copies the specified text to the clipboard.
31353149
:type copy_text: :class:`telebot.types.CopyTextButton`
3150+
3151+
:param icon_custom_emoji_id: Optional. Custom emoji identifier to be shown on the button.
3152+
Can only be used if the bot has a Telegram Premium subscription.
3153+
:type icon_custom_emoji_id: :obj:`str`
3154+
3155+
:param style: Optional. Style of the button. Can be used to change the color of the button.
3156+
:type style: :obj:`str`
31363157

31373158
:return: Instance of the class
31383159
:rtype: :class:`telebot.types.InlineKeyboardButton`
@@ -3155,7 +3176,7 @@ def de_json(cls, json_string):
31553176
def __init__(self, text: str, url: Optional[str]=None, callback_data: Optional[str]=None, web_app: Optional[WebAppInfo]=None,
31563177
switch_inline_query: Optional[str]=None, switch_inline_query_current_chat: Optional[str]=None,
31573178
switch_inline_query_chosen_chat: Optional[SwitchInlineQueryChosenChat]=None, callback_game=None, pay: Optional[bool]=None,
3158-
login_url: Optional[LoginUrl]=None, copy_text: Optional[CopyTextButton]=None, **kwargs):
3179+
login_url: Optional[LoginUrl]=None, copy_text: Optional[CopyTextButton]=None, icon_custom_emoji_id: Optional[str] = None, style: Optional[str] = None, **kwargs):
31593180
self.text: str = text
31603181
self.url: Optional[str] = url
31613182
self.callback_data: Optional[str] = callback_data
@@ -3167,6 +3188,8 @@ def __init__(self, text: str, url: Optional[str]=None, callback_data: Optional[s
31673188
self.pay: Optional[bool] = pay
31683189
self.login_url: Optional[LoginUrl] = login_url
31693190
self.copy_text: Optional[CopyTextButton] = copy_text
3191+
self.icon_custom_emoji_id = icon_custom_emoji_id
3192+
self.style = style
31703193

31713194
def to_json(self):
31723195
return json.dumps(self.to_dict())
@@ -3193,6 +3216,10 @@ def to_dict(self):
31933216
json_dict['switch_inline_query_chosen_chat'] = self.switch_inline_query_chosen_chat.to_dict()
31943217
if self.copy_text is not None:
31953218
json_dict['copy_text'] = self.copy_text.to_dict()
3219+
if self.icon_custom_emoji_id is not None:
3220+
json_dict['icon_custom_emoji_id'] = self.icon_custom_emoji_id
3221+
if self.style is not None:
3222+
json_dict['style'] = self.style
31963223
return json_dict
31973224

31983225

0 commit comments

Comments
 (0)