pyTelegramBotAPI 4.32.0__py3-none-any.whl → 4.33.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyTelegramBotAPI
3
- Version: 4.32.0
3
+ Version: 4.33.0
4
4
  Summary: Python Telegram bot API.
5
5
  Project-URL: Homepage, https://github.com/eternnoir/pyTelegramBotAPI
6
6
  Project-URL: Documentation, https://pytba.readthedocs.org
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Programming Language :: Python :: 3.14
22
- Requires-Python: >=3.9
22
+ Requires-Python: >=3.10
23
23
  Requires-Dist: requests
24
24
  Provides-Extra: coloredlogs
25
25
  Requires-Dist: coloredlogs; extra == 'coloredlogs'
@@ -51,7 +51,7 @@ Description-Content-Type: text/markdown
51
51
  <p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
52
52
  <p align="center">Both synchronous and asynchronous.</p>
53
53
 
54
- ## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#march-1-2026"><img src="https://img.shields.io/badge/Bot%20API-9.5-blue?logo=telegram" alt="Supported Bot API version"></a>
54
+ ## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api-changelog#april-3-2026"><img src="https://img.shields.io/badge/Bot%20API-9.6-blue?logo=telegram" alt="Supported Bot API version"></a>
55
55
 
56
56
  <h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
57
57
  <h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
@@ -110,7 +110,7 @@ Description-Content-Type: text/markdown
110
110
 
111
111
  ## Getting started
112
112
 
113
- This API is tested with Python 3.9-3.13 and Pypy 3.
113
+ This API is tested with Python 3.10-3.14 and PyPy 3.
114
114
  There are two ways to install the library:
115
115
 
116
116
  * Installation using pip (a Python package manager):
@@ -1,18 +1,18 @@
1
- telebot/__init__.py,sha256=N66uzken5iV53MtWlKrwB3YcS6Ecnd3wCv3ny5qlFZU,499445
2
- telebot/apihelper.py,sha256=Nd1XLwABjWw7X_BcJ87GghVqwHuZ1MR8KMGKW01cgWI,124058
3
- telebot/async_telebot.py,sha256=pSBVbVCu_6WBS2eGC0Fc3IvvrsNOPEILKQsu9uBqRvI,473014
1
+ telebot/__init__.py,sha256=n10cPWnpA8bCX52oPCrxmDfbC6PkbDnC4HQVYLRK2Bs,506985
2
+ telebot/apihelper.py,sha256=8Zk2w8SpLxC62Iyiyw514RjAWLRWlYOtS3UGg9pTUsE,126258
3
+ telebot/async_telebot.py,sha256=NfIrtalP4hiuZ4AyuxWeU2FnQC6k0faH_D77H2CmZ90,480898
4
4
  telebot/asyncio_filters.py,sha256=Mea64Q--9yznmy2YuLrK2gVXBtbDDFjlaTU6u6EwOlg,13307
5
5
  telebot/asyncio_handler_backends.py,sha256=8yYMIIspdMKs-udbpLXUGZ1R-ZgW1Dz4vKjKmo_C4Zg,2883
6
- telebot/asyncio_helper.py,sha256=_OS0nlnMVibqTa-D6HXVMnLCTU9__eKfCRK0hCJKgyQ,125373
6
+ telebot/asyncio_helper.py,sha256=dm8s6ZwRn6XZWuDApHCiOxk61oIwZJKmxWvAtCmsWYE,127920
7
7
  telebot/callback_data.py,sha256=k4Rz3lAONG5J2M9TESKMIjqXoBNJMfEy9nnrmJAyi3Q,5358
8
8
  telebot/custom_filters.py,sha256=ImvJ_gasI2NDbog2NBEkqUEQdVEzaONVOCaJwOTi-Mc,13430
9
9
  telebot/formatting.py,sha256=hIaE3IiiumD6tf-X8DSDvFQyGHPq48nmEdLVJcr_nKQ,15950
10
- telebot/handler_backends.py,sha256=t1j1sQVS511AcQYd73TrvlxpS6757UQ0cVmWrA9_kg4,8226
10
+ telebot/handler_backends.py,sha256=INPxzW-osA9ICwpTqUrxZK1Bs4tGJDz99HcyJ5ZUWHY,8245
11
11
  telebot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  telebot/service_utils.py,sha256=xLmlZLTVs34UOdQtMvwduor8hnLxQCx8iJ92wDGl2Mw,2053
13
- telebot/types.py,sha256=4-42IPSNjvGD_BGfNPjw3g8aHKw2SCIoYTapYJBrKwU,585087
14
- telebot/util.py,sha256=YZfYvvIfptXN9ZnidGr7tbZSgiNY0mlo3zQOYwT1ngc,22524
15
- telebot/version.py,sha256=WNORxQXzb_lRKkuKqIvZdOBq1oOOlaj8Dv539VW_D0g,99
13
+ telebot/types.py,sha256=Y1vKzCH7SYrbIeU6xKQWYAIQZI-fL1zj6o2tsDLEtv0,599365
14
+ telebot/util.py,sha256=vJX8HO2Lhjt4_I8mBLC5-iAZr5xJvZ1wd4JFQSUP2dw,21886
15
+ telebot/version.py,sha256=wuWsdohLIO2ZX8wCiMw8LqRlFD5nDJQMm1EfG48Lj2c,99
16
16
  telebot/asyncio_storage/__init__.py,sha256=DpVFdTvFpJveTbHY2CezqGWjHKjG__qMdmJvFEc_ekw,446
17
17
  telebot/asyncio_storage/base_storage.py,sha256=T5FWpT057w-FSbprDBCEY2P1wzdrYoe8yonBOJLpSQs,3966
18
18
  telebot/asyncio_storage/memory_storage.py,sha256=XQO8hYPBOenrv8KHd3Bzj8Eg7OCmvJV4rbmKJPl5eB0,6074
@@ -36,7 +36,7 @@ telebot/storage/base_storage.py,sha256=Xcgb2LdGV_5L16W1TnRXG0tvkopNCf9xh37ri1Xza
36
36
  telebot/storage/memory_storage.py,sha256=PNDLz67TMioY_A-po9la4-qblIdoCERh7fHU18KqIeU,6024
37
37
  telebot/storage/pickle_storage.py,sha256=6vvR8vzNE0SUKiAYP_bM3Cx9if4-xLNOMkHvJtdgbM4,7399
38
38
  telebot/storage/redis_storage.py,sha256=WY8khaSVmEkJO6kQbQ-t916564BIwX2kinUMg_wLLDM,9774
39
- pytelegrambotapi-4.32.0.dist-info/METADATA,sha256=y1OsQhZ_zb0FXmnQP3efWbRBIk6loiULhqeOb9VR3G4,48258
40
- pytelegrambotapi-4.32.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
41
- pytelegrambotapi-4.32.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
42
- pytelegrambotapi-4.32.0.dist-info/RECORD,,
39
+ pytelegrambotapi-4.33.0.dist-info/METADATA,sha256=mSaTWkjqiGh_Ufc-iB7DFhEOltvrYyvVE3zsMK9PN2M,48270
40
+ pytelegrambotapi-4.33.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
41
+ pytelegrambotapi-4.33.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
42
+ pytelegrambotapi-4.33.0.dist-info/RECORD,,
telebot/__init__.py CHANGED
@@ -249,6 +249,7 @@ class TeleBot:
249
249
  self.edited_business_message_handlers = []
250
250
  self.deleted_business_messages_handlers = []
251
251
  self.purchased_paid_media_handlers = []
252
+ self.managed_bot_handlers = []
252
253
 
253
254
  self.custom_filters = {}
254
255
  self.state_handlers = []
@@ -726,6 +727,7 @@ class TeleBot:
726
727
  new_edited_business_messages = None
727
728
  new_deleted_business_messages = None
728
729
  new_purchased_paid_media = None
730
+ new_managed_bots = None
729
731
 
730
732
  for update in updates:
731
733
  if apihelper.ENABLE_MIDDLEWARE and not self.use_class_middlewares:
@@ -810,6 +812,9 @@ class TeleBot:
810
812
  if update.purchased_paid_media:
811
813
  if new_purchased_paid_media is None: new_purchased_paid_media = []
812
814
  new_purchased_paid_media.append(update.purchased_paid_media)
815
+ if update.managed_bot:
816
+ if new_managed_bots is None: new_managed_bots = []
817
+ new_managed_bots.append(update.managed_bot)
813
818
 
814
819
  if new_messages:
815
820
  self.process_new_messages(new_messages)
@@ -857,6 +862,8 @@ class TeleBot:
857
862
  self.process_new_deleted_business_messages(new_deleted_business_messages)
858
863
  if new_purchased_paid_media:
859
864
  self.process_new_purchased_paid_media(new_purchased_paid_media)
865
+ if new_managed_bots:
866
+ self.process_new_managed_bot(new_managed_bots)
860
867
 
861
868
  def process_new_messages(self, new_messages):
862
869
  """
@@ -999,6 +1006,12 @@ class TeleBot:
999
1006
  """
1000
1007
  self._notify_command_handlers(self.purchased_paid_media_handlers, new_purchased_paid_media, 'purchased_paid_media')
1001
1008
 
1009
+ def process_new_managed_bot(self, new_managed_bots):
1010
+ """
1011
+ :meta private:
1012
+ """
1013
+ self._notify_command_handlers(self.managed_bot_handlers, new_managed_bots, 'managed_bot')
1014
+
1002
1015
  def process_middlewares(self, update):
1003
1016
  """
1004
1017
  :meta private:
@@ -5227,6 +5240,33 @@ class TeleBot:
5227
5240
  apihelper.get_business_connection(self.token, business_connection_id)
5228
5241
  )
5229
5242
 
5243
+ def get_managed_bot_token(self, user_id: int) -> str:
5244
+ """
5245
+ Use this method to get the token of a managed bot. Returns the token as String on success.
5246
+
5247
+ Telegram documentation: https://core.telegram.org/bots/api#getmanagedbottoken
5248
+
5249
+ :param user_id: User identifier of the managed bot whose token will be returned
5250
+ :type user_id: :obj:`int`
5251
+
5252
+ :return: Returns the token as String on success.
5253
+ :rtype: :obj:`str`
5254
+ """
5255
+ return apihelper.get_managed_bot_token(self.token, user_id)
5256
+
5257
+ def replace_managed_bot_token(self, user_id: int) -> str:
5258
+ """
5259
+ Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.
5260
+
5261
+ Telegram documentation: https://core.telegram.org/bots/api#replacemanagedbottoken
5262
+
5263
+ :param user_id: User identifier of the managed bot whose token will be replaced
5264
+ :type user_id: :obj:`int`
5265
+
5266
+ :return: Returns the new token as String on success.
5267
+ :rtype: :obj:`str`
5268
+ """
5269
+ return apihelper.replace_managed_bot_token(self.token, user_id)
5230
5270
 
5231
5271
  def set_my_commands(self, commands: List[types.BotCommand],
5232
5272
  scope: Optional[types.BotCommandScope]=None,
@@ -6049,7 +6089,6 @@ class TeleBot:
6049
6089
  send_email_to_provider=send_email_to_provider, is_flexible=is_flexible ,subscription_period=subscription_period,
6050
6090
  business_connection_id=business_connection_id)
6051
6091
 
6052
-
6053
6092
  # noinspection PyShadowingBuiltins
6054
6093
  def send_poll(
6055
6094
  self, chat_id: Union[int, str], question: str, options: List[Union[str, types.InputPollOption]],
@@ -6074,7 +6113,15 @@ class TeleBot:
6074
6113
  question_parse_mode: Optional[str] = None,
6075
6114
  question_entities: Optional[List[types.MessageEntity]] = None,
6076
6115
  message_effect_id: Optional[str]=None,
6077
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
6116
+ allow_paid_broadcast: Optional[bool]=None,
6117
+ allows_revoting: Optional[bool]=None,
6118
+ shuffle_options: Optional[bool]=None,
6119
+ allow_adding_options: Optional[bool]=None,
6120
+ hide_results_until_closes: Optional[bool]=None,
6121
+ correct_option_ids: Optional[List[int]]=None,
6122
+ description: Optional[str]=None,
6123
+ description_parse_mode: Optional[str]=None,
6124
+ description_entities: Optional[List[types.MessageEntity]]=None) -> types.Message:
6078
6125
  """
6079
6126
  Use this method to send a native poll.
6080
6127
  On success, the sent Message is returned.
@@ -6096,10 +6143,10 @@ class TeleBot:
6096
6143
  :param type: Poll type, “quiz” or “regular”, defaults to “regular”
6097
6144
  :type type: :obj:`str`
6098
6145
 
6099
- :param allows_multiple_answers: True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
6146
+ :param allows_multiple_answers: True, if the poll allows multiple answers, defaults to False
6100
6147
  :type allows_multiple_answers: :obj:`bool`
6101
6148
 
6102
- :param correct_option_id: 0-based identifier of the correct answer option. Available only for polls in quiz mode, defaults to None
6149
+ :param correct_option_id: Deprecated, use correct_option_ids instead.
6103
6150
  :type correct_option_id: :obj:`int`
6104
6151
 
6105
6152
  :param explanation: Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
@@ -6108,10 +6155,11 @@ class TeleBot:
6108
6155
  :param explanation_parse_mode: Mode for parsing entities in the explanation. See formatting options for more details.
6109
6156
  :type explanation_parse_mode: :obj:`str`
6110
6157
 
6111
- :param open_period: Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
6158
+ :param open_period: Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with close_date.
6112
6159
  :type open_period: :obj:`int`
6113
6160
 
6114
6161
  :param close_date: Point in time (Unix timestamp) when the poll will be automatically closed.
6162
+ Must be at least 5 and no more than 2628000 seconds in the future. Can't be used together with open_period.
6115
6163
  :type close_date: :obj:`int` | :obj:`datetime`
6116
6164
 
6117
6165
  :param is_closed: Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
@@ -6160,6 +6208,30 @@ class TeleBot:
6160
6208
  of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
6161
6209
  :type allow_paid_broadcast: :obj:`bool`
6162
6210
 
6211
+ :param allows_revoting: Pass True, if the poll allows to change chosen answer options, defaults to False for quizzes and to True for regular polls
6212
+ :type allows_revoting: :obj:`bool`
6213
+
6214
+ :param shuffle_options: Pass True, if the poll options must be shown in random order
6215
+ :type shuffle_options: :obj:`bool`
6216
+
6217
+ :param allow_adding_options: Pass True, if answer options can be added to the poll after creation; not supported for anonymous polls and quizzes
6218
+ :type allow_adding_options: :obj:`bool`
6219
+
6220
+ :param hide_results_until_closes: Pass True, if poll results must be shown only after the poll closes
6221
+ :type hide_results_until_closes: :obj:`bool`
6222
+
6223
+ :param correct_option_ids: A JSON-serialized list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode
6224
+ :type correct_option_ids: :obj:`list` of :obj:`int`
6225
+
6226
+ :param description: Description of the poll to be sent, 0-1024 characters after entities parsing
6227
+ :type description: :obj:`str`
6228
+
6229
+ :param description_parse_mode: Mode for parsing entities in the poll description. See formatting options for more details.
6230
+ :type description_parse_mode: :obj:`str`
6231
+
6232
+ :param description_entities: A JSON-serialized list of special entities that appear in the poll description, which can be specified instead of description_parse_mode
6233
+ :type description_entities: :obj:`list` of :obj:`MessageEntity`
6234
+
6163
6235
  :return: On success, the sent Message is returned.
6164
6236
  :rtype: :obj:`types.Message`
6165
6237
  """
@@ -6192,6 +6264,7 @@ class TeleBot:
6192
6264
 
6193
6265
  explanation_parse_mode = self.parse_mode if (explanation_parse_mode is None) else explanation_parse_mode
6194
6266
  question_parse_mode = self.parse_mode if (question_parse_mode is None) else question_parse_mode
6267
+ description_parse_mode = self.parse_mode if (description_parse_mode is None) else description_parse_mode
6195
6268
 
6196
6269
  if options and (not isinstance(options[0], types.InputPollOption)):
6197
6270
  # show a deprecation warning
@@ -6203,19 +6276,33 @@ class TeleBot:
6203
6276
  options = [types.InputPollOption(option.text, text_entities=option.text_entities) for option in options]
6204
6277
  else:
6205
6278
  raise RuntimeError("Type of 'options' items is unknown. Options should be List[types.InputPollOption], other types are deprecated.")
6279
+
6280
+ # handle deprecated correct_option_id parameter
6281
+ if correct_option_id is not None:
6282
+ if correct_option_ids is not None:
6283
+ # show a conflict warning
6284
+ logger.warning("Both 'correct_option_id' and 'correct_option_ids' parameters are set: use 'correct_option_ids' instead.")
6285
+ else:
6286
+ # convert correct_option_id to correct_option_ids
6287
+ correct_option_ids = [correct_option_id]
6288
+ logger.warning("The parameter 'correct_option_id' is deprecated, use 'correct_option_ids' instead.")
6289
+
6206
6290
 
6207
6291
  return types.Message.de_json(
6208
6292
  apihelper.send_poll(
6209
6293
  self.token, chat_id, question, options,
6210
6294
  is_anonymous=is_anonymous, type=type, allows_multiple_answers=allows_multiple_answers,
6211
- correct_option_id=correct_option_id, explanation=explanation,
6295
+ explanation=explanation,
6212
6296
  explanation_parse_mode=explanation_parse_mode, open_period=open_period,
6213
6297
  close_date=close_date, is_closed=is_closed, disable_notification=disable_notification,
6214
6298
  reply_markup=reply_markup, timeout=timeout, explanation_entities=explanation_entities,
6215
6299
  protect_content=protect_content, message_thread_id=message_thread_id,
6216
6300
  reply_parameters=reply_parameters, business_connection_id=business_connection_id,
6217
6301
  question_parse_mode=question_parse_mode, question_entities=question_entities,
6218
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
6302
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
6303
+ allows_revoting=allows_revoting, shuffle_options=shuffle_options,
6304
+ allow_adding_options=allow_adding_options, hide_results_until_closes=hide_results_until_closes, correct_option_ids=correct_option_ids,
6305
+ description=description, description_parse_mode=description_parse_mode, description_entities=description_entities)
6219
6306
  )
6220
6307
 
6221
6308
 
@@ -6796,10 +6883,10 @@ class TeleBot:
6796
6883
  :param text: Text that will be shown along with the gift; 0-255 characters
6797
6884
  :type text: :obj:`str`
6798
6885
 
6799
- :param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
6886
+ :param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
6800
6887
  :type text_parse_mode: :obj:`str`
6801
6888
 
6802
- :param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
6889
+ :param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
6803
6890
  :type text_entities: :obj:`list` of :obj:`types.MessageEntity`
6804
6891
 
6805
6892
  :return: Returns True on success.
@@ -7503,10 +7590,10 @@ class TeleBot:
7503
7590
  :param text: Text that will be shown along with the service message about the subscription; 0-128 characters
7504
7591
  :type text: :obj:`str`
7505
7592
 
7506
- :param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
7593
+ :param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
7507
7594
  :type text_parse_mode: :obj:`str`
7508
7595
 
7509
- :param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
7596
+ :param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
7510
7597
  :type text_entities: :obj:`list` of :class:`telebot.types.MessageEntity`
7511
7598
 
7512
7599
  :return: Returns True on success.
@@ -8127,6 +8214,25 @@ class TeleBot:
8127
8214
  self.token, user_id, result, allow_user_chats=allow_user_chats, allow_bot_chats=allow_bot_chats,
8128
8215
  allow_group_chats=allow_group_chats, allow_channel_chats=allow_channel_chats)
8129
8216
  )
8217
+
8218
+ def save_prepared_keyboard_button(self, user_id: int, button: types.KeyboardButton) -> types.PreparedKeyboardButton:
8219
+ """
8220
+ Use this method to store a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object.
8221
+
8222
+ Telegram Documentation: https://core.telegram.org/bots/api#savepreparedkeyboardbutton
8223
+
8224
+ :param user_id: Unique identifier of the target user that can use the button
8225
+ :type user_id: :obj:`int`
8226
+
8227
+ :param button: A JSON-serialized object describing the button to be saved. The button must be of the type request_users, request_chat, or request_managed_bot
8228
+ :type button: :class:`telebot.types.KeyboardButton`
8229
+
8230
+ :return: On success, a PreparedKeyboardButton object is returned.
8231
+ :rtype: :class:`telebot.types.PreparedKeyboardButton`
8232
+ """
8233
+ return types.PreparedKeyboardButton.de_json(
8234
+ apihelper.save_prepared_keyboard_button(self.token, user_id, button)
8235
+ )
8130
8236
 
8131
8237
  def register_for_reply(self, message: types.Message, callback: Callable, *args, **kwargs) -> None:
8132
8238
  """
@@ -10346,6 +10452,53 @@ class TeleBot:
10346
10452
  handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
10347
10453
  self.add_deleted_business_messages_handler(handler_dict)
10348
10454
 
10455
+ def managed_bot_handler(self, func=None, **kwargs):
10456
+ """
10457
+ Handles new incoming updates about managed bot. As a parameter to the decorator function, it passes :class:`telebot.types.ManagedBotUpdated` object.
10458
+
10459
+ :param func: Function executed as a filter
10460
+ :type func: :obj:`function`
10461
+
10462
+ :param kwargs: Optional keyword arguments(custom filters)
10463
+ :return: None
10464
+ """
10465
+ def decorator(handler):
10466
+ handler_dict = self._build_handler_dict(handler, func=func, **kwargs)
10467
+ self.add_managed_bot_handler(handler_dict)
10468
+ return handler
10469
+
10470
+ return decorator
10471
+
10472
+ def add_managed_bot_handler(self, handler_dict):
10473
+ """
10474
+ Adds a managed_bot handler.
10475
+ Note that you should use register_managed_bot_handler to add managed_bot_handler to the bot.
10476
+
10477
+ :meta private:
10478
+ :param handler_dict:
10479
+ :return:
10480
+ """
10481
+ self.managed_bot_handlers.append(handler_dict)
10482
+
10483
+ def register_managed_bot_handler(self, callback: Callable, func: Optional[Callable]=None, pass_bot: Optional[bool]=False, **kwargs):
10484
+ """
10485
+ Registers managed bot handler.
10486
+
10487
+ :param callback: function to be called
10488
+ :type callback: :obj:`function`
10489
+
10490
+ :param func: Function executed as a filter
10491
+ :type func: :obj:`function`
10492
+
10493
+ :param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files)
10494
+ :type pass_bot: :obj:`bool`
10495
+
10496
+ :param kwargs: Optional keyword arguments(custom filters)
10497
+ :return: None
10498
+ """
10499
+ handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
10500
+ self.add_managed_bot_handler(handler_dict)
10501
+
10349
10502
 
10350
10503
  def add_custom_filter(self, custom_filter: Union[SimpleCustomFilter, AdvancedCustomFilter]):
10351
10504
  """
telebot/apihelper.py CHANGED
@@ -1606,6 +1606,16 @@ def get_business_connection(token, business_connection_id):
1606
1606
  payload = {'business_connection_id': business_connection_id}
1607
1607
  return _make_request(token, method_url, params=payload , method='post')
1608
1608
 
1609
+ def get_managed_bot_token(token, user_id):
1610
+ method_url = 'getManagedBotToken'
1611
+ payload = {'user_id': user_id}
1612
+ return _make_request(token, method_url, params=payload , method='post')
1613
+
1614
+ def replace_managed_bot_token(token, user_id):
1615
+ method_url = 'replaceManagedBotToken'
1616
+ payload = {'user_id': user_id}
1617
+ return _make_request(token, method_url, params=payload , method='post')
1618
+
1609
1619
  def delete_my_commands(token, scope=None, language_code=None):
1610
1620
  method_url = r'deleteMyCommands'
1611
1621
  payload = {}
@@ -1893,7 +1903,9 @@ def send_invoice(
1893
1903
  :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
1894
1904
  :param reply_parameters: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
1895
1905
  :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only
1896
- :param allow_paid_broadcast:
1906
+ :param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
1907
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat
1908
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.
1897
1909
  :return:
1898
1910
  """
1899
1911
  method_url = r'sendInvoice'
@@ -2486,6 +2498,12 @@ def save_prepared_inline_message(token, user_id, result: types.InlineQueryResult
2486
2498
  return _make_request(token, method_url, params=payload, method='post')
2487
2499
 
2488
2500
 
2501
+ def save_prepared_keyboard_button(token, user_id, button):
2502
+ method_url = 'savePreparedKeyboardButton'
2503
+ payload = {'user_id': user_id, 'button': button.to_json()}
2504
+ return _make_request(token, method_url, params=payload, method='post')
2505
+
2506
+
2489
2507
  def create_invoice_link(token, title, description, payload, provider_token,
2490
2508
  currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
2491
2509
  photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
@@ -2534,11 +2552,12 @@ def create_invoice_link(token, title, description, payload, provider_token,
2534
2552
  # noinspection PyShadowingBuiltins
2535
2553
  def send_poll(
2536
2554
  token, chat_id, question, options,
2537
- is_anonymous = None, type = None, allows_multiple_answers = None, correct_option_id = None, explanation = None,
2555
+ is_anonymous = None, type = None, allows_multiple_answers = None, explanation = None,
2538
2556
  explanation_parse_mode=None, open_period = None, close_date = None, is_closed = None, disable_notification=False,
2539
2557
  reply_markup=None, timeout=None, explanation_entities=None, protect_content=None, message_thread_id=None,
2540
2558
  reply_parameters=None, business_connection_id=None, question_parse_mode=None, question_entities=None, message_effect_id=None,
2541
- allow_paid_broadcast=None):
2559
+ allow_paid_broadcast=None, allows_revoting=None, shuffle_options=None, allow_adding_options=None, hide_results_until_closes=None,
2560
+ correct_option_ids=None, description=None, description_parse_mode=None, description_entities=None):
2542
2561
  method_url = r'sendPoll'
2543
2562
  payload = {
2544
2563
  'chat_id': str(chat_id),
@@ -2552,8 +2571,6 @@ def send_poll(
2552
2571
  payload['type'] = type
2553
2572
  if allows_multiple_answers is not None:
2554
2573
  payload['allows_multiple_answers'] = allows_multiple_answers
2555
- if correct_option_id is not None:
2556
- payload['correct_option_id'] = correct_option_id
2557
2574
  if explanation:
2558
2575
  payload['explanation'] = explanation
2559
2576
  if explanation_parse_mode:
@@ -2591,6 +2608,22 @@ def send_poll(
2591
2608
  payload['message_effect_id'] = message_effect_id
2592
2609
  if allow_paid_broadcast is not None:
2593
2610
  payload['allow_paid_broadcast'] = allow_paid_broadcast
2611
+ if allows_revoting is not None:
2612
+ payload['allows_revoting'] = allows_revoting
2613
+ if shuffle_options is not None:
2614
+ payload['shuffle_options'] = shuffle_options
2615
+ if allow_adding_options is not None:
2616
+ payload['allow_adding_options'] = allow_adding_options
2617
+ if hide_results_until_closes is not None:
2618
+ payload['hide_results_until_closes'] = hide_results_until_closes
2619
+ if correct_option_ids is not None:
2620
+ payload['correct_option_ids'] = json.dumps(correct_option_ids)
2621
+ if description is not None:
2622
+ payload['description'] = description
2623
+ if description_parse_mode is not None:
2624
+ payload['description_parse_mode'] = description_parse_mode
2625
+ if description_entities is not None:
2626
+ payload['description_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(description_entities))
2594
2627
  return _make_request(token, method_url, params=payload)
2595
2628
 
2596
2629
  def create_forum_topic(token, chat_id, name, icon_color=None, icon_custom_emoji_id=None):