pyTelegramBotAPI 4.27.0__py3-none-any.whl → 4.28.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.27.0
3
+ Version: 4.28.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
@@ -20,9 +20,10 @@ Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Requires-Python: >=3.9
23
+ Requires-Dist: aiohttp
24
+ Requires-Dist: pytest
23
25
  Requires-Dist: requests
24
- Provides-Extra: aiohttp
25
- Requires-Dist: aiohttp; extra == 'aiohttp'
26
+ Requires-Dist: wheel
26
27
  Provides-Extra: coloredlogs
27
28
  Requires-Dist: coloredlogs; extra == 'coloredlogs'
28
29
  Provides-Extra: fastapi
@@ -53,7 +54,7 @@ Description-Content-Type: text/markdown
53
54
  <p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
54
55
  <p align="center">Both synchronous and asynchronous.</p>
55
56
 
56
- ## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#april-11-2025"><img src="https://img.shields.io/badge/Bot%20API-9.0-blue?logo=telegram" alt="Supported Bot API version"></a>
57
+ ## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#july-3-2025"><img src="https://img.shields.io/badge/Bot%20API-9.1-blue?logo=telegram" alt="Supported Bot API version"></a>
57
58
 
58
59
  <h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
59
60
  <h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
@@ -1,17 +1,18 @@
1
- telebot/__init__.py,sha256=2mh62ufcsqa6yVZ-o3wxFeC2OoZcgzqjiq4k6FsY8mU,461330
2
- telebot/apihelper.py,sha256=jDrLQ73oVc-ifS-NACYPg_17notWrnOa8r6hxD97JPk,110724
3
- telebot/async_telebot.py,sha256=oz2EmoRHQIxq6wuncYAw2X3Yjus7ub1IQJH4iXvamNg,435236
1
+ telebot/__init__.py,sha256=oJAPslyXwChfC7QxlYjTrc34j3eUy7LkudLbRuzUIE4,466264
2
+ telebot/apihelper.py,sha256=rQ0GRK3mMoB3Bb50OLxlvnEBIm7Buc4ZkufRdMDRNpE,112155
3
+ telebot/async_telebot.py,sha256=HPt3YDDqubUAyUUlWoTShgzctOTVdEQhHfmzrDATzA8,440065
4
4
  telebot/asyncio_filters.py,sha256=UM5AznjF5Ffym20_linOvqn5mHy5KfXy9MdKjFbKtcQ,12857
5
5
  telebot/asyncio_handler_backends.py,sha256=BWS7zr93FJNZJmPHBoXo4i_PIHGlmrEoWy1miXax9aI,2785
6
- telebot/asyncio_helper.py,sha256=stIsXlyd_95iyPe-NEYZAIbbMTafLBpQNh_1_yCkbZU,111890
6
+ telebot/asyncio_helper.py,sha256=SMBghFpt8PbU1zfrvJNWl8yrqfj2yx27fERp1ied8K8,113372
7
7
  telebot/callback_data.py,sha256=k4Rz3lAONG5J2M9TESKMIjqXoBNJMfEy9nnrmJAyi3Q,5358
8
8
  telebot/custom_filters.py,sha256=ncF8_zwlSqkuATI46Xc6HQ5Y1ZoQ1fO6AlcRbs7bO3U,12975
9
9
  telebot/formatting.py,sha256=at8WpXpmJLSat9XSgnpzFOIA6gKrHVBcvB8lJIlATjE,15509
10
10
  telebot/handler_backends.py,sha256=lyKu0PaH2c4y5FfyQS3M9tOyBJ8ATjxHZkATzu01XpE,7969
11
+ telebot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
12
  telebot/service_utils.py,sha256=xLmlZLTVs34UOdQtMvwduor8hnLxQCx8iJ92wDGl2Mw,2053
12
- telebot/types.py,sha256=HElHzFvLphEjQW5XkO03fN7jG23uAiEGUW0qagxGUb4,526208
13
- telebot/util.py,sha256=ylRtI4DI4I1BJAF2Ack7WyGbTN1cRkubUCbhLNiiPj4,21385
14
- telebot/version.py,sha256=6XpR6fdH_JIujp5a7pvLIsErZ72nf_vw984JlDPg_xM,99
13
+ telebot/types.py,sha256=yDpS17EAQQQ7HI3JkDJl80SoG6rHeRoXSd61Nu_gUTM,541823
14
+ telebot/util.py,sha256=puZxJl9jmZ5aONJNWXcdaz3EW2Ihp0i6UF7QlTB7Hp8,21472
15
+ telebot/version.py,sha256=us8iLXp2mI4_heWUjEQ28nwgPUbvjUrb7BZ1q46UFrw,99
15
16
  telebot/asyncio_storage/__init__.py,sha256=fraOWJby1ddJmPAXf1oXWmZJXRodSpING17MF875NPI,433
16
17
  telebot/asyncio_storage/base_storage.py,sha256=JVoT2Xk3EfyWFauE6ToeHP2E3kwt81KRkACay6wQynE,3819
17
18
  telebot/asyncio_storage/memory_storage.py,sha256=h8yc2xpfLmbcBjPmKkqNhZtUtpNQ7EuKIfMGue61e7w,5849
@@ -35,7 +36,7 @@ telebot/storage/base_storage.py,sha256=AJ7X3ZTMzVeQsgfQV8bRHxvRj7QUvOcTrGI1fWiuM
35
36
  telebot/storage/memory_storage.py,sha256=-r1vuIt1YHq9btkr6E7BCu4Do-wUDlNcttG22SSgEYo,5799
36
37
  telebot/storage/pickle_storage.py,sha256=wjFuRxSBeCMB3h-fUqLgqe2XcZoc6-ixkN5qsm3th9I,7136
37
38
  telebot/storage/redis_storage.py,sha256=DReU2lc8cI0f3XMIT1N9-suGZ6jE8H9I_mapK3A-lyE,9450
38
- pytelegrambotapi-4.27.0.dist-info/METADATA,sha256=5I7yKcrtpvNMCL-mW8wcsCm9Icx4XOvC_TBc3CBhxos,48345
39
- pytelegrambotapi-4.27.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
40
- pytelegrambotapi-4.27.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
41
- pytelegrambotapi-4.27.0.dist-info/RECORD,,
39
+ pytelegrambotapi-4.28.0.dist-info/METADATA,sha256=1WD1itGR6DLn4CD5jhTfk0mkGgWoncL8GKtL9_P8BCk,48342
40
+ pytelegrambotapi-4.28.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ pytelegrambotapi-4.28.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
42
+ pytelegrambotapi-4.28.0.dist-info/RECORD,,
telebot/__init__.py CHANGED
@@ -2104,6 +2104,90 @@ class TeleBot:
2104
2104
  message_thread_id=message_thread_id, protect_content=protect_content, remove_caption=remove_caption)
2105
2105
  return [types.MessageID.de_json(message_id) for message_id in result]
2106
2106
 
2107
+ def send_checklist(
2108
+ self, business_connection_id: str, chat_id: Union[int, str],
2109
+ checklist: types.InputChecklist,
2110
+ disable_notification: Optional[bool]=None,
2111
+ protect_content: Optional[bool]=None,
2112
+ message_effect_id: Optional[str]=None,
2113
+ reply_parameters: Optional[types.ReplyParameters]=None,
2114
+ reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Message:
2115
+ """
2116
+ Use this method to send a checklist on behalf of a connected business account. On success,
2117
+ the sent Message is returned.
2118
+
2119
+ Telegram documentation: https://core.telegram.org/bots/api#sendchecklist
2120
+
2121
+ :param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
2122
+ :type business_connection_id: :obj:`str`
2123
+
2124
+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
2125
+ :type chat_id: :obj:`int` or :obj:`str`
2126
+
2127
+ :param checklist: A JSON-serialized object for the checklist to send
2128
+ :type checklist: :class:`telebot.types.InputChecklist`
2129
+
2130
+ :param disable_notification: Sends the message silently. Users will receive a notification with no sound.
2131
+ :type disable_notification: :obj:`bool`
2132
+
2133
+ :param protect_content: Protects the contents of the sent message from forwarding and saving
2134
+ :type protect_content: :obj:`bool`
2135
+
2136
+ :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only
2137
+ :type message_effect_id: :obj:`str`
2138
+
2139
+ :param reply_parameters: Additional parameters for replies to messages
2140
+ :type reply_parameters: :class:`telebot.types.ReplyParameters`
2141
+
2142
+ :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard.
2143
+ :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup`
2144
+
2145
+ :return: On success, the sent Message is returned.
2146
+ :rtype: :class:`telebot.types.Message`
2147
+ """
2148
+ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
2149
+ protect_content = self.protect_content if (protect_content is None) else protect_content
2150
+
2151
+ if reply_parameters and (reply_parameters.allow_sending_without_reply is None):
2152
+ reply_parameters.allow_sending_without_reply = self.allow_sending_without_reply
2153
+
2154
+ return types.Message.de_json(
2155
+ apihelper.send_checklist(
2156
+ self.token, business_connection_id, chat_id, checklist, disable_notification=disable_notification,
2157
+ protect_content=protect_content, message_effect_id=message_effect_id,
2158
+ reply_parameters=reply_parameters, reply_markup=reply_markup))
2159
+
2160
+ def edit_message_checklist(
2161
+ self, business_connection_id: str, chat_id: Union[int, str],
2162
+ message_id: int, checklist: types.InputChecklist,
2163
+ reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Message:
2164
+ """
2165
+ Use this method to edit a checklist on behalf of a connected business account. On success,
2166
+ the edited Message is returned.
2167
+
2168
+ Telegram documentation: https://core.telegram.org/bots/api#editmessagechecklist
2169
+
2170
+ :param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
2171
+ :type business_connection_id: :obj:`str`
2172
+
2173
+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
2174
+ :type chat_id: :obj:`int` or :obj:`str`
2175
+
2176
+ :param message_id: Unique identifier for the target message
2177
+ :type message_id: :obj:`int`
2178
+
2179
+ :param checklist: A JSON-serialized object for the new checklist
2180
+ :type checklist: :class:`telebot.types.InputChecklist`
2181
+
2182
+ :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard.
2183
+ :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup`
2184
+
2185
+ :return: On success, the edited Message is returned.
2186
+ :rtype: :class:`telebot.types.Message`
2187
+ """
2188
+ return types.Message.de_json(
2189
+ apihelper.edit_message_checklist(
2190
+ self.token, business_connection_id, chat_id, message_id, checklist, reply_markup=reply_markup))
2107
2191
 
2108
2192
  def send_dice(
2109
2193
  self, chat_id: Union[int, str],
@@ -3528,7 +3612,7 @@ class TeleBot:
3528
3612
  proximity_alert_radius: Optional[int]=None,
3529
3613
  live_period: Optional[int]=None,
3530
3614
  business_connection_id: Optional[str]=None
3531
- ) -> types.Message or bool:
3615
+ ) -> Union[types.Message, bool]:
3532
3616
  """
3533
3617
  Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly
3534
3618
  disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message
@@ -3590,7 +3674,7 @@ class TeleBot:
3590
3674
  inline_message_id: Optional[str]=None,
3591
3675
  reply_markup: Optional[types.InlineKeyboardMarkup]=None,
3592
3676
  timeout: Optional[int]=None,
3593
- business_connection_id: Optional[str]=None) -> types.Message or bool:
3677
+ business_connection_id: Optional[str]=None) -> Union[types.Message, bool]:
3594
3678
  """
3595
3679
  Use this method to stop updating a live location message before live_period expires.
3596
3680
  On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
@@ -5599,7 +5683,7 @@ class TeleBot:
5599
5683
  :param question: Poll question, 1-300 characters
5600
5684
  :type question: :obj:`str`
5601
5685
 
5602
- :param options: A JSON-serialized list of 2-10 answer options
5686
+ :param options: A JSON-serialized list of 2-12 answer options
5603
5687
  :type options: :obj:`list` of :obj:`InputPollOption` | :obj:`list` of :obj:`str`
5604
5688
 
5605
5689
  :param is_anonymous: True, if the poll needs to be anonymous, defaults to True
@@ -5818,6 +5902,17 @@ class TeleBot:
5818
5902
  """
5819
5903
  return apihelper.answer_pre_checkout_query(
5820
5904
  self.token, pre_checkout_query_id, ok, error_message=error_message)
5905
+
5906
+ def get_my_star_balance(self) -> types.StarAmount:
5907
+ """
5908
+ Returns the bot's current Telegram Stars balance. On success, returns a StarAmount object.
5909
+
5910
+ Telegram documentation: https://core.telegram.org/bots/api#getmystarbalance
5911
+
5912
+ :return: On success, returns a StarAmount object.
5913
+ :rtype: :obj:`types.StarAmount`
5914
+ """
5915
+ return types.StarAmount.de_json(apihelper.get_my_star_balance(self.token))
5821
5916
 
5822
5917
 
5823
5918
  def get_star_transactions(self, offset: Optional[int]=None, limit: Optional[int]=None) -> types.StarTransactions:
telebot/apihelper.py CHANGED
@@ -473,6 +473,36 @@ def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_m
473
473
  payload['video_start_timestamp'] = video_start_timestamp
474
474
  return _make_request(token, method_url, params=payload)
475
475
 
476
+ def send_checklist(
477
+ token, business_connection_id, chat_id, checklist,
478
+ disable_notification=None, protect_content=None, message_effect_id=None,
479
+ reply_parameters=None, reply_markup=None
480
+ ):
481
+ method_url = r'sendChecklist'
482
+ payload = {'chat_id': chat_id, 'checklist': checklist, 'business_connection_id': business_connection_id}
483
+ if disable_notification is not None:
484
+ payload['disable_notification'] = disable_notification
485
+ if protect_content is not None:
486
+ payload['protect_content'] = protect_content
487
+ if message_effect_id:
488
+ payload['message_effect_id'] = message_effect_id
489
+ if reply_parameters:
490
+ payload['reply_parameters'] = reply_parameters.to_json()
491
+ if reply_markup:
492
+ payload['reply_markup'] = _convert_markup(reply_markup)
493
+ return _make_request(token, method_url, params=payload)
494
+
495
+
496
+ def edit_message_checklist(
497
+ token, business_connection_id, chat_id, message_id, checklist,
498
+ reply_markup=None
499
+ ):
500
+ method_url = r'editMessageChecklist'
501
+ payload = {'chat_id': chat_id, 'message_id': message_id, 'checklist': checklist, 'business_connection_id': business_connection_id}
502
+ if reply_markup:
503
+ payload['reply_markup'] = _convert_markup(reply_markup)
504
+ return _make_request(token, method_url, params=payload)
505
+
476
506
 
477
507
  def send_dice(
478
508
  token, chat_id,
@@ -1817,6 +1847,10 @@ def answer_pre_checkout_query(token, pre_checkout_query_id, ok, error_message=No
1817
1847
  payload['error_message'] = error_message
1818
1848
  return _make_request(token, method_url, params=payload)
1819
1849
 
1850
+ def get_my_star_balance(token):
1851
+ method_url = 'getMyStarBalance'
1852
+ return _make_request(token, method_url)
1853
+
1820
1854
  def get_star_transactions(token, offset=None, limit=None):
1821
1855
  method_url = 'getStarTransactions'
1822
1856
  payload = {}
telebot/async_telebot.py CHANGED
@@ -3619,6 +3619,91 @@ class AsyncTeleBot:
3619
3619
  result = await asyncio_helper.copy_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id,
3620
3620
  protect_content, remove_caption)
3621
3621
  return [types.MessageID.de_json(message_id) for message_id in result]
3622
+
3623
+ async def send_checklist(
3624
+ self, business_connection_id: str, chat_id: Union[int, str],
3625
+ checklist: types.InputChecklist,
3626
+ disable_notification: Optional[bool]=None,
3627
+ protect_content: Optional[bool]=None,
3628
+ message_effect_id: Optional[str]=None,
3629
+ reply_parameters: Optional[types.ReplyParameters]=None,
3630
+ reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Message:
3631
+ """
3632
+ Use this method to send a checklist on behalf of a connected business account. On success,
3633
+ the sent Message is returned.
3634
+
3635
+ Telegram documentation: https://core.telegram.org/bots/api#sendchecklist
3636
+
3637
+ :param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
3638
+ :type business_connection_id: :obj:`str`
3639
+
3640
+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
3641
+ :type chat_id: :obj:`int` or :obj:`str`
3642
+
3643
+ :param checklist: A JSON-serialized object for the checklist to send
3644
+ :type checklist: :class:`telebot.types.InputChecklist`
3645
+
3646
+ :param disable_notification: Sends the message silently. Users will receive a notification with no sound.
3647
+ :type disable_notification: :obj:`bool`
3648
+
3649
+ :param protect_content: Protects the contents of the sent message from forwarding and saving
3650
+ :type protect_content: :obj:`bool`
3651
+
3652
+ :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only
3653
+ :type message_effect_id: :obj:`str`
3654
+
3655
+ :param reply_parameters: Additional parameters for replies to messages
3656
+ :type reply_parameters: :class:`telebot.types.ReplyParameters`
3657
+
3658
+ :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard.
3659
+ :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup`
3660
+
3661
+ :return: On success, the sent Message is returned.
3662
+ :rtype: :class:`telebot.types.Message`
3663
+ """
3664
+ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
3665
+ protect_content = self.protect_content if (protect_content is None) else protect_content
3666
+
3667
+ if reply_parameters and (reply_parameters.allow_sending_without_reply is None):
3668
+ reply_parameters.allow_sending_without_reply = self.allow_sending_without_reply
3669
+
3670
+ return types.Message.de_json(
3671
+ await asyncio_helper.send_checklist(
3672
+ self.token, business_connection_id, chat_id, checklist, disable_notification=disable_notification,
3673
+ protect_content=protect_content, message_effect_id=message_effect_id,
3674
+ reply_parameters=reply_parameters, reply_markup=reply_markup))
3675
+
3676
+ async def edit_message_checklist(
3677
+ self, business_connection_id: str, chat_id: Union[int, str],
3678
+ message_id: int, checklist: types.InputChecklist,
3679
+ reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Message:
3680
+ """
3681
+ Use this method to edit a checklist on behalf of a connected business account. On success,
3682
+ the edited Message is returned.
3683
+
3684
+ Telegram documentation: https://core.telegram.org/bots/api#editmessagechecklist
3685
+
3686
+ :param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
3687
+ :type business_connection_id: :obj:`str`
3688
+
3689
+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
3690
+ :type chat_id: :obj:`int` or :obj:`str`
3691
+
3692
+ :param message_id: Unique identifier for the target message
3693
+ :type message_id: :obj:`int`
3694
+
3695
+ :param checklist: A JSON-serialized object for the new checklist
3696
+ :type checklist: :class:`telebot.types.InputChecklist`
3697
+
3698
+ :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard.
3699
+ :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup`
3700
+
3701
+ :return: On success, the edited Message is returned.
3702
+ :rtype: :class:`telebot.types.Message`
3703
+ """
3704
+ return types.Message.de_json(
3705
+ await asyncio_helper.edit_message_checklist(
3706
+ self.token, business_connection_id, chat_id, message_id, checklist, reply_markup=reply_markup))
3622
3707
 
3623
3708
  async def send_dice(
3624
3709
  self, chat_id: Union[int, str],
@@ -7256,8 +7341,15 @@ class AsyncTeleBot:
7256
7341
  :rtype: :obj:`bool`
7257
7342
  """
7258
7343
  return await asyncio_helper.answer_pre_checkout_query(self.token, pre_checkout_query_id, ok, error_message)
7259
-
7260
7344
 
7345
+
7346
+ async def get_my_star_balance(self) -> types.StarAmount:
7347
+ """
7348
+ A method to get the current Telegram Stars balance of the bot. Requires no parameters.
7349
+ On success, returns a StarAmount object.
7350
+ """
7351
+ return types.StarAmount.de_json(await asyncio_helper.get_my_star_balance(self.token))
7352
+
7261
7353
  async def get_star_transactions(self, offset: Optional[int]=None, limit: Optional[int]=None) -> types.StarTransactions:
7262
7354
  """
7263
7355
  Returns the bot's Telegram Star transactions in chronological order.
telebot/asyncio_helper.py CHANGED
@@ -477,6 +477,35 @@ async def copy_message(token, chat_id, from_chat_id, message_id, caption=None, p
477
477
  payload['video_start_timestamp'] = video_start_timestamp
478
478
  return await _process_request(token, method_url, params=payload)
479
479
 
480
+ async def send_checklist(
481
+ token, business_connection_id, chat_id, checklist,
482
+ disable_notification=None, protect_content=None, message_effect_id=None,
483
+ reply_parameters=None, reply_markup=None
484
+ ):
485
+ method_url = r'sendChecklist'
486
+ payload = {'chat_id': chat_id, 'checklist': checklist, 'business_connection_id': business_connection_id}
487
+ if disable_notification is not None:
488
+ payload['disable_notification'] = disable_notification
489
+ if protect_content is not None:
490
+ payload['protect_content'] = protect_content
491
+ if message_effect_id:
492
+ payload['message_effect_id'] = message_effect_id
493
+ if reply_parameters:
494
+ payload['reply_parameters'] = reply_parameters.to_json()
495
+ if reply_markup:
496
+ payload['reply_markup'] = _convert_markup(reply_markup)
497
+ return await _process_request(token, method_url, params=payload)
498
+
499
+
500
+ async def edit_message_checklist(
501
+ token, business_connection_id, chat_id, message_id, checklist,
502
+ reply_markup=None
503
+ ):
504
+ method_url = r'editMessageChecklist'
505
+ payload = {'chat_id': chat_id, 'message_id': message_id, 'checklist': checklist, 'business_connection_id': business_connection_id}
506
+ if reply_markup:
507
+ payload['reply_markup'] = await _convert_markup(reply_markup)
508
+ return await _process_request(token, method_url, params=payload)
480
509
 
481
510
  async def send_dice(
482
511
  token, chat_id,
@@ -1816,6 +1845,11 @@ async def answer_pre_checkout_query(token, pre_checkout_query_id, ok, error_mess
1816
1845
  payload['error_message'] = error_message
1817
1846
  return await _process_request(token, method_url, params=payload)
1818
1847
 
1848
+
1849
+ async def get_my_star_balance(token):
1850
+ method_url = 'getMyStarBalance'
1851
+ return await _process_request(token, method_url)
1852
+
1819
1853
  async def get_star_transactions(token, offset=None, limit=None):
1820
1854
  method_url = 'getStarTransactions'
1821
1855
  payload = {}
telebot/py.typed ADDED
File without changes
telebot/types.py CHANGED
@@ -1049,6 +1049,9 @@ class Message(JsonDeserializable):
1049
1049
  :param has_media_spoiler: Optional. True, if the message media is covered by a spoiler animation
1050
1050
  :type has_media_spoiler: :obj:`bool`
1051
1051
 
1052
+ :param checklist: Optional. Message is a checklist
1053
+ :type checklist: :class:`telebot.types.Checklist`
1054
+
1052
1055
  :param contact: Optional. Message is a shared contact, information about the contact
1053
1056
  :type contact: :class:`telebot.types.Contact`
1054
1057
 
@@ -1161,6 +1164,15 @@ class Message(JsonDeserializable):
1161
1164
  :param chat_background_set: Optional. Service message: chat background set
1162
1165
  :type chat_background_set: :class:`telebot.types.ChatBackground`
1163
1166
 
1167
+ :param checklist_tasks_done: Optional. Service message: some tasks in a checklist were marked as done or not done
1168
+ :type checklist_tasks_done: :class:`telebot.types.ChecklistTasksDone`
1169
+
1170
+ :param checklist_tasks_added: Optional. Service message: tasks were added to a checklist
1171
+ :type checklist_tasks_added: :class:`telebot.types.ChecklistTasksAdded`
1172
+
1173
+ :param direct_message_price_changed: Optional. Service message: the price for paid messages in the corresponding direct messages chat of a channel has changed
1174
+ :type direct_message_price_changed: :class:`telebot.types.DirectMessagePriceChanged`
1175
+
1164
1176
  :param forum_topic_created: Optional. Service message: forum topic created
1165
1177
  :type forum_topic_created: :class:`telebot.types.ForumTopicCreated`
1166
1178
 
@@ -1461,8 +1473,18 @@ class Message(JsonDeserializable):
1461
1473
  content_type = 'paid_message_price_changed'
1462
1474
  if 'paid_star_count' in obj:
1463
1475
  opts['paid_star_count'] = obj['paid_star_count']
1476
+ if 'checklist' in obj:
1477
+ opts['checklist'] = Checklist.de_json(obj['checklist'])
1478
+ if 'checklist_tasks_done' in obj:
1479
+ opts['checklist_tasks_done'] = ChecklistTasksDone.de_json(obj['checklist_tasks_done'])
1480
+ content_type = 'checklist_tasks_done'
1481
+ if 'checklist_tasks_added' in obj:
1482
+ opts['checklist_tasks_added'] = ChecklistTasksAdded.de_json(obj['checklist_tasks_added'])
1483
+ content_type = 'checklist_tasks_added'
1484
+ if 'direct_message_price_changed' in obj:
1485
+ opts['direct_message_price_changed'] = DirectMessagePriceChanged.de_json(obj['direct_message_price_changed'])
1486
+ content_type = 'direct_message_price_changed'
1464
1487
 
1465
-
1466
1488
  return cls(message_id, from_user, date, chat, content_type, opts, json_string)
1467
1489
 
1468
1490
  @classmethod
@@ -1584,7 +1606,10 @@ class Message(JsonDeserializable):
1584
1606
  self.unique_gift : Optional[UniqueGiftInfo] = None
1585
1607
  self.paid_message_price_changed: Optional[PaidMessagePriceChanged] = None
1586
1608
  self.paid_star_count: Optional[int] = None
1587
-
1609
+ self.checklist: Optional[Checklist] = None
1610
+ self.checklist_tasks_done: Optional[ChecklistTasksDone] = None
1611
+ self.checklist_tasks_added: Optional[List[ChecklistTasksAdded]] = None
1612
+ self.direct_message_price_changed: Optional[DirectMessagePriceChanged] = None
1588
1613
 
1589
1614
  for key in options:
1590
1615
  setattr(self, key, options[key])
@@ -6740,12 +6765,23 @@ class InputMedia(Dictionaryable, JsonSerializable):
6740
6765
  * :class:`InputMediaPhoto`
6741
6766
  * :class:`InputMediaVideo`
6742
6767
  """
6743
- def __init__(self, type, media, caption=None, parse_mode=None, caption_entities=None):
6768
+ def __init__(self, type, media, caption=None, parse_mode=None, caption_entities=None, thumbnail=None):
6744
6769
  self.type: str = type
6745
6770
  self.media: str = media
6746
6771
  self.caption: Optional[str] = caption
6747
6772
  self.parse_mode: Optional[str] = parse_mode
6748
6773
  self.caption_entities: Optional[List[MessageEntity]] = caption_entities
6774
+ self.thumbnail: Optional[Union[str, InputFile]] = thumbnail
6775
+
6776
+ if thumbnail is None:
6777
+ self._thumbnail_name = ''
6778
+ self._thumbnail_dic = None
6779
+ elif service_utils.is_string(self.thumbnail):
6780
+ self._thumbnail_name = ''
6781
+ self._thumbnail_dic = self.thumbnail
6782
+ else:
6783
+ self._thumbnail_name = service_utils.generate_random_token()
6784
+ self._thumbnail_dic = 'attach://{0}'.format(self._thumbnail_name)
6749
6785
 
6750
6786
  if service_utils.is_string(self.media):
6751
6787
  self._media_name = ''
@@ -6759,6 +6795,8 @@ class InputMedia(Dictionaryable, JsonSerializable):
6759
6795
 
6760
6796
  def to_dict(self):
6761
6797
  json_dict = {'type': self.type, 'media': self._media_dic}
6798
+ if self._thumbnail_dic:
6799
+ json_dict['thumbnail'] = self._thumbnail_dic
6762
6800
  if self.caption:
6763
6801
  json_dict['caption'] = self.caption
6764
6802
  if self.parse_mode:
@@ -6773,8 +6811,12 @@ class InputMedia(Dictionaryable, JsonSerializable):
6773
6811
  """
6774
6812
  if service_utils.is_string(self.media):
6775
6813
  return self.to_json(), None
6814
+
6815
+ media_dict = {self._media_name: self.media}
6816
+ if self._thumbnail_name:
6817
+ media_dict[self._thumbnail_name] = self.thumbnail
6776
6818
 
6777
- return self.to_json(), {self._media_name: self.media}
6819
+ return self.to_json(), media_dict
6778
6820
 
6779
6821
 
6780
6822
  class InputMediaPhoto(InputMedia):
@@ -6895,8 +6937,7 @@ class InputMediaVideo(InputMedia):
6895
6937
  show_caption_above_media: Optional[bool] = None, cover: Optional[Union[str, InputFile]] = None,
6896
6938
  start_timestamp: Optional[int] = None):
6897
6939
  super(InputMediaVideo, self).__init__(
6898
- type="video", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities)
6899
- self.thumbnail: Optional[Union[str, InputFile]] = thumbnail
6940
+ type="video", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, thumbnail=thumbnail)
6900
6941
  self.width: Optional[int] = width
6901
6942
  self.height: Optional[int] = height
6902
6943
  self.duration: Optional[int] = duration
@@ -6913,8 +6954,6 @@ class InputMediaVideo(InputMedia):
6913
6954
 
6914
6955
  def to_dict(self):
6915
6956
  ret = super(InputMediaVideo, self).to_dict()
6916
- if self.thumbnail:
6917
- ret['thumbnail'] = self.thumbnail
6918
6957
  if self.width:
6919
6958
  ret['width'] = self.width
6920
6959
  if self.height:
@@ -6988,8 +7027,7 @@ class InputMediaAnimation(InputMedia):
6988
7027
  height: Optional[int] = None, duration: Optional[int] = None,
6989
7028
  has_spoiler: Optional[bool] = None, show_caption_above_media: Optional[bool] = None):
6990
7029
  super(InputMediaAnimation, self).__init__(
6991
- type="animation", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities)
6992
- self.thumbnail: Optional[Union[str, InputFile]] = thumbnail
7030
+ type="animation", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, thumbnail=thumbnail)
6993
7031
  self.width: Optional[int] = width
6994
7032
  self.height: Optional[int] = height
6995
7033
  self.duration: Optional[int] = duration
@@ -7004,8 +7042,6 @@ class InputMediaAnimation(InputMedia):
7004
7042
 
7005
7043
  def to_dict(self):
7006
7044
  ret = super(InputMediaAnimation, self).to_dict()
7007
- if self.thumbnail:
7008
- ret['thumbnail'] = self.thumbnail
7009
7045
  if self.width:
7010
7046
  ret['width'] = self.width
7011
7047
  if self.height:
@@ -7065,8 +7101,7 @@ class InputMediaAudio(InputMedia):
7065
7101
  caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[int] = None,
7066
7102
  performer: Optional[str] = None, title: Optional[str] = None):
7067
7103
  super(InputMediaAudio, self).__init__(
7068
- type="audio", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities)
7069
- self.thumbnail: Optional[Union[str, InputFile]] = thumbnail
7104
+ type="audio", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, thumbnail=thumbnail)
7070
7105
  self.duration: Optional[int] = duration
7071
7106
  self.performer: Optional[str] = performer
7072
7107
  self.title: Optional[str] = title
@@ -7078,8 +7113,6 @@ class InputMediaAudio(InputMedia):
7078
7113
 
7079
7114
  def to_dict(self):
7080
7115
  ret = super(InputMediaAudio, self).to_dict()
7081
- if self.thumbnail:
7082
- ret['thumbnail'] = self.thumbnail
7083
7116
  if self.duration:
7084
7117
  ret['duration'] = self.duration
7085
7118
  if self.performer:
@@ -7130,8 +7163,7 @@ class InputMediaDocument(InputMedia):
7130
7163
  caption_entities: Optional[List[MessageEntity]] = None,
7131
7164
  disable_content_type_detection: Optional[bool] = None):
7132
7165
  super(InputMediaDocument, self).__init__(
7133
- type="document", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities)
7134
- self.thumbnail: Optional[Union[str, InputFile]] = thumbnail
7166
+ type="document", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, thumbnail=thumbnail)
7135
7167
  self.disable_content_type_detection: Optional[bool] = disable_content_type_detection
7136
7168
 
7137
7169
  @property
@@ -7141,8 +7173,6 @@ class InputMediaDocument(InputMedia):
7141
7173
 
7142
7174
  def to_dict(self):
7143
7175
  ret = super(InputMediaDocument, self).to_dict()
7144
- if self.thumbnail:
7145
- ret['thumbnail'] = self.thumbnail
7146
7176
  if self.disable_content_type_detection is not None:
7147
7177
  ret['disable_content_type_detection'] = self.disable_content_type_detection
7148
7178
  return ret
@@ -8781,6 +8811,9 @@ class ExternalReplyInfo(JsonDeserializable):
8781
8811
  :param has_media_spoiler: Optional. True, if the message media is covered by a spoiler animation
8782
8812
  :type has_media_spoiler: :obj:`bool`
8783
8813
 
8814
+ :param checklist: Optional. Message is a checklist
8815
+ :type checklist: :class:`telebot.types.Checklist`
8816
+
8784
8817
  :param contact: Optional. Message is a shared contact, information about the contact
8785
8818
  :type contact: :class:`Contact`
8786
8819
 
@@ -8856,6 +8889,10 @@ class ExternalReplyInfo(JsonDeserializable):
8856
8889
  obj['poll'] = Poll.de_json(obj['poll'])
8857
8890
  if 'venue' in obj:
8858
8891
  obj['venue'] = Venue.de_json(obj['venue'])
8892
+ if 'paid_media' in obj:
8893
+ obj['paid_media'] = PaidMediaInfo.de_json(obj['paid_media'])
8894
+ if 'checklist' in obj:
8895
+ obj['checklist'] = Checklist.de_json(obj['checklist'])
8859
8896
  return cls(**obj)
8860
8897
 
8861
8898
  def __init__(
@@ -8868,7 +8905,8 @@ class ExternalReplyInfo(JsonDeserializable):
8868
8905
  dice: Optional[Dice]=None, game: Optional[Game]=None, giveaway: Optional[Giveaway]=None,
8869
8906
  giveaway_winners: Optional[GiveawayWinners]=None, invoice: Optional[Invoice]=None,
8870
8907
  location: Optional[Location]=None, poll: Optional[Poll]=None,
8871
- venue: Optional[Venue]=None, paid_media: Optional[PaidMediaInfo]=None, **kwargs) -> None:
8908
+ venue: Optional[Venue]=None, paid_media: Optional[PaidMediaInfo]=None,
8909
+ checklist: Optional[Checklist]=None, **kwargs) -> None:
8872
8910
  self.origin: MessageOrigin = origin
8873
8911
  self.chat: Optional[Chat] = chat
8874
8912
  self.message_id: Optional[int] = message_id
@@ -8893,6 +8931,7 @@ class ExternalReplyInfo(JsonDeserializable):
8893
8931
  self.poll: Optional[Poll] = poll
8894
8932
  self.venue: Optional[Venue] = venue
8895
8933
  self.paid_media: Optional[PaidMediaInfo] = paid_media
8934
+ self.checklist: Optional[Checklist] = checklist
8896
8935
 
8897
8936
 
8898
8937
  # noinspection PyUnresolvedReferences,PyShadowingBuiltins
@@ -11618,11 +11657,14 @@ class OwnedGiftUnique(OwnedGift):
11618
11657
  :param transfer_star_count: Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift
11619
11658
  :type transfer_star_count: :obj:`int`
11620
11659
 
11660
+ :param next_transfer_date: Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now
11661
+ :type next_transfer_date: :obj:`int`
11662
+
11621
11663
  :return: Instance of the class
11622
11664
  :rtype: :class:`OwnedGiftUnique`
11623
11665
  """
11624
11666
  def __init__(self, type, gift, owned_gift_id=None, sender_user=None, send_date=None, is_saved=None,
11625
- can_be_transferred=None, transfer_star_count=None, **kwargs):
11667
+ can_be_transferred=None, transfer_star_count=None, next_transfer_date=None, **kwargs):
11626
11668
  super().__init__(type=type)
11627
11669
  self.gift: UniqueGift = gift
11628
11670
  self.owned_gift_id: Optional[str] = owned_gift_id
@@ -11631,6 +11673,7 @@ class OwnedGiftUnique(OwnedGift):
11631
11673
  self.is_saved: Optional[bool] = is_saved
11632
11674
  self.can_be_transferred: Optional[bool] = can_be_transferred
11633
11675
  self.transfer_star_count: Optional[int] = transfer_star_count
11676
+ self.next_transfer_date: Optional[int] = next_transfer_date
11634
11677
  @classmethod
11635
11678
  def de_json(cls, json_string):
11636
11679
  if json_string is None: return None
@@ -12302,24 +12345,35 @@ class UniqueGiftInfo(JsonDeserializable):
12302
12345
  :param gift: Information about the gift
12303
12346
  :type gift: :class:`UniqueGift`
12304
12347
 
12305
- :param origin: Origin of the gift. Currently, either “upgrade” or “transfer”
12348
+ :param origin: Origin of the gift. Currently, either “upgrade” for gifts upgraded from regular gifts, “transfer” for gifts transferred from other users or channels,
12349
+ or “resale” for gifts bought from other users
12306
12350
  :type origin: :obj:`str`
12307
12351
 
12352
+ :param last_resale_star_count: Optional. For gifts bought from other users, the price paid for the gift
12353
+ :type last_resale_star_count: :obj:`int`
12354
+
12308
12355
  :param owned_gift_id: Optional. Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts
12309
12356
  :type owned_gift_id: :obj:`str`
12310
12357
 
12311
12358
  :param transfer_star_count: Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift
12312
12359
  :type transfer_star_count: :obj:`int`
12313
12360
 
12361
+ :param next_transfer_date: Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now
12362
+ :type next_transfer_date: :obj:`int`
12363
+
12314
12364
  :return: Instance of the class
12315
12365
  :rtype: :class:`UniqueGiftInfo`
12316
12366
  """
12317
12367
  def __init__(self, gift: UniqueGift, origin: str, owned_gift_id: Optional[str] = None,
12318
- transfer_star_count: Optional[int] = None, **kwargs):
12368
+ transfer_star_count: Optional[int] = None, next_transfer_date: Optional[int] = None,
12369
+ last_resale_star_count: Optional[int] = None, **kwargs):
12319
12370
  self.gift: UniqueGift = gift
12320
12371
  self.origin: str = origin
12372
+ self.last_resale_star_count: Optional[int] = last_resale_star_count
12321
12373
  self.owned_gift_id: Optional[str] = owned_gift_id
12322
12374
  self.transfer_star_count: Optional[int] = transfer_star_count
12375
+ self.next_transfer_date: Optional[int] = next_transfer_date
12376
+
12323
12377
  @classmethod
12324
12378
  def de_json(cls, json_string):
12325
12379
  if json_string is None: return None
@@ -12433,3 +12487,275 @@ class InputProfilePhotoAnimated(InputProfilePhoto):
12433
12487
  return data
12434
12488
  def convert_input_profile_photo(self):
12435
12489
  return self.to_json(), {self._animation_name: self.animation}
12490
+
12491
+
12492
+ class ChecklistTask(JsonDeserializable):
12493
+ """
12494
+ Describes a task in a checklist.
12495
+
12496
+ Telegram documentation: https://core.telegram.org/bots/api#checklisttask
12497
+
12498
+ :param id: Unique identifier of the task
12499
+ :type id: :obj:`int`
12500
+
12501
+ :param text: Text of the task
12502
+ :type text: :obj:`str`
12503
+
12504
+ :param text_entities: Optional. Special entities that appear in the task text
12505
+ :type text_entities: :obj:`list` of :class:`MessageEntity`
12506
+
12507
+ :param completed_by_user: Optional. User that completed the task; omitted if the task wasn't completed
12508
+ :type completed_by_user: :class:`User`
12509
+
12510
+ :param completion_date: Optional. Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed
12511
+ :type completion_date: :obj:`int`
12512
+
12513
+ :return: Instance of the class
12514
+ :rtype: :class:`ChecklistTask`
12515
+ """
12516
+ def __init__(self, id: int, text: str, text_entities: Optional[List[MessageEntity]] = None,
12517
+ completed_by_user: Optional[User] = None,
12518
+ completion_date: Optional[int] = None, **kwargs):
12519
+ self.id: int = id
12520
+ self.text: str = text
12521
+ self.text_entities: Optional[List[MessageEntity]] = text_entities
12522
+ self.completed_by_user: Optional[User] = completed_by_user
12523
+ self.completion_date: Optional[int] = completion_date
12524
+
12525
+ @classmethod
12526
+ def de_json(cls, json_string):
12527
+ if json_string is None: return None
12528
+ obj = cls.check_json(json_string)
12529
+ if 'text_entities' in obj:
12530
+ obj['text_entities'] = Message.parse_entities(obj['text_entities'])
12531
+ if 'completed_by_user' in obj:
12532
+ obj['completed_by_user'] = User.de_json(obj['completed_by_user'])
12533
+ return cls(**obj)
12534
+
12535
+ class Checklist(JsonDeserializable):
12536
+ """
12537
+ Describes a checklist.
12538
+
12539
+ Telegram documentation: https://core.telegram.org/bots/api#checklist
12540
+
12541
+ :param title: Title of the checklist
12542
+ :type title: :obj:`str`
12543
+
12544
+ :param title_entities: Optional. Special entities that appear in the checklist title
12545
+ :type title_entities: :obj:`list` of :class:`MessageEntity`
12546
+
12547
+ :param tasks: List of tasks in the checklist
12548
+ :type tasks: :obj:`list` of :class:`ChecklistTask`
12549
+
12550
+ :param others_can_add_tasks: Optional. True, if users other than the creator of the list can add tasks to the list
12551
+ :type others_can_add_tasks: :obj:`bool`
12552
+
12553
+ :param others_can_mark_tasks_as_done: Optional. True, if users other than the creator of the list can mark tasks as done or not done in the list
12554
+ :type others_can_mark_tasks_as_done: :obj:`bool`
12555
+
12556
+ :return: Instance of the class
12557
+ :rtype: :class:`Checklist`
12558
+ """
12559
+ def __init__(self, title: str, tasks: List[ChecklistTask],
12560
+ title_entities: Optional[List[MessageEntity]] = None,
12561
+ others_can_add_tasks: Optional[bool] = None,
12562
+ others_can_mark_tasks_as_done: Optional[bool] = None, **kwargs):
12563
+ self.title: str = title
12564
+ self.tasks: List[ChecklistTask] = tasks
12565
+ self.title_entities: Optional[List[MessageEntity]] = title_entities
12566
+ self.others_can_add_tasks: Optional[bool] = others_can_add_tasks
12567
+ self.others_can_mark_tasks_as_done: Optional[bool] = others_can_mark_tasks_as_done
12568
+
12569
+ @classmethod
12570
+ def de_json(cls, json_string):
12571
+ if json_string is None: return None
12572
+ obj = cls.check_json(json_string)
12573
+ if 'title_entities' in obj:
12574
+ obj['title_entities'] = Message.parse_entities(obj['title_entities'])
12575
+ obj['tasks'] = [ChecklistTask.de_json(task) for task in obj['tasks']]
12576
+ return cls(**obj)
12577
+
12578
+ class InputChecklistTask(JsonSerializable):
12579
+ """
12580
+ Describes a task to add to a checklist.
12581
+
12582
+ Telegram documentation: https://core.telegram.org/bots/api#inputchecklisttask
12583
+
12584
+ :param id: Unique identifier of the task; must be positive and unique among all task identifiers currently present in the checklist
12585
+ :type id: :obj:`int`
12586
+
12587
+ :param text: Text of the task; 1-100 characters after entities parsing
12588
+ :type text: :obj:`str`
12589
+
12590
+ :param parse_mode: Optional. Mode for parsing entities in the text. See formatting options for more details.
12591
+ :type parse_mode: :obj:`str`
12592
+
12593
+ :param text_entities: Optional. List of special entities that appear in the text, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are allowed.
12594
+ :type text_entities: :obj:`list` of :class:`MessageEntity`
12595
+
12596
+ :return: Instance of the class
12597
+ :rtype: :class:`InputChecklistTask`
12598
+ """
12599
+ def __init__(self, id: int, text: str, parse_mode: Optional[str] = None,
12600
+ text_entities: Optional[List[MessageEntity]] = None, **kwargs):
12601
+ self.id: int = id
12602
+ self.text: str = text
12603
+ self.parse_mode: Optional[str] = parse_mode
12604
+ self.text_entities: Optional[List[MessageEntity]] = text_entities
12605
+
12606
+ def to_json(self):
12607
+ return json.dumps(self.to_dict())
12608
+
12609
+ def to_dict(self):
12610
+ data = {
12611
+ 'id': self.id,
12612
+ 'text': self.text
12613
+ }
12614
+ if self.parse_mode:
12615
+ data['parse_mode'] = self.parse_mode
12616
+ if self.text_entities:
12617
+ data['text_entities'] = [entity.to_dict() for entity in self.text_entities]
12618
+ return data
12619
+
12620
+ class InputChecklist(JsonSerializable):
12621
+ """
12622
+ Describes a checklist to create.
12623
+
12624
+ Telegram documentation: https://core.telegram.org/bots/api#inputchecklist
12625
+
12626
+ :param title: Title of the checklist; 1-255 characters after entities parsing
12627
+ :type title: :obj:`str`
12628
+
12629
+ :param parse_mode: Optional. Mode for parsing entities in the title. See formatting options for more details.
12630
+ :type parse_mode: :obj:`str`
12631
+
12632
+ :param title_entities: Optional. List of special entities that appear in the title, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are allowed.
12633
+ :type title_entities: :obj:`list` of :class:`MessageEntity`
12634
+
12635
+ :param tasks: List of 1-30 tasks in the checklist
12636
+ :type tasks: :obj:`list` of :class:`InputChecklistTask`
12637
+
12638
+ :param others_can_add_tasks: Optional. Pass True if other users can add tasks to the checklist
12639
+ :type others_can_add_tasks: :obj:`bool`
12640
+
12641
+ :param others_can_mark_tasks_as_done: Optional. Pass True if other users can mark tasks as done or not done in the checklist
12642
+ :type others_can_mark_tasks_as_done: :obj:`bool`
12643
+
12644
+ :return: Instance of the class
12645
+ :rtype: :class:`InputChecklist`
12646
+ """
12647
+ def __init__(self, title: str, tasks: List[InputChecklistTask],
12648
+ parse_mode: Optional[str] = None,
12649
+ title_entities: Optional[List[MessageEntity]] = None,
12650
+ others_can_add_tasks: Optional[bool] = None,
12651
+ others_can_mark_tasks_as_done: Optional[bool] = None, **kwargs):
12652
+ self.title: str = title
12653
+ self.tasks: List[InputChecklistTask] = tasks
12654
+ self.parse_mode: Optional[str] = parse_mode
12655
+ self.title_entities: Optional[List[MessageEntity]] = title_entities
12656
+ self.others_can_add_tasks: Optional[bool] = others_can_add_tasks
12657
+ self.others_can_mark_tasks_as_done: Optional[bool] = others_can_mark_tasks_as_done
12658
+
12659
+ def to_json(self):
12660
+ return json.dumps(self.to_dict())
12661
+
12662
+ def to_dict(self):
12663
+ data = {
12664
+ 'title': self.title,
12665
+ 'tasks': [task.to_dict() for task in self.tasks]
12666
+ }
12667
+ if self.parse_mode:
12668
+ data['parse_mode'] = self.parse_mode
12669
+ if self.title_entities:
12670
+ data['title_entities'] = [entity.to_dict() for entity in self.title_entities]
12671
+ if self.others_can_add_tasks is not None:
12672
+ data['others_can_add_tasks'] = self.others_can_add_tasks
12673
+ if self.others_can_mark_tasks_as_done is not None:
12674
+ data['others_can_mark_tasks_as_done'] = self.others_can_mark_tasks_as_done
12675
+
12676
+
12677
+ class ChecklistTasksDone(JsonDeserializable):
12678
+ """
12679
+ Describes a service message about checklist tasks marked as done or not done.
12680
+
12681
+ Telegram documentation: https://core.telegram.org/bots/api#checklisttasksdone
12682
+
12683
+ :param checklist_message: Optional. Message containing the checklist whose tasks were marked as done or not done. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
12684
+ :type checklist_message: :class:`Message`
12685
+
12686
+ :param marked_as_done_task_ids: Optional. Identifiers of the tasks that were marked as done
12687
+ :type marked_as_done_task_ids: :obj:`list` of :obj:`int
12688
+
12689
+ :param marked_as_not_done_task_ids: Optional. Identifiers of the tasks that were marked as not done
12690
+ :type marked_as_not_done_task_ids: :obj:`list` of :obj:`int`
12691
+
12692
+ :return: Instance of the class
12693
+ :rtype: :class:`ChecklistTasksDone`
12694
+ """
12695
+ def __init__(self, checklist_message: Optional[Message] = None,
12696
+ marked_as_done_task_ids: Optional[List[int]] = None,
12697
+ marked_as_not_done_task_ids: Optional[List[int]] = None, **kwargs):
12698
+ self.checklist_message: Optional[Message] = checklist_message
12699
+ self.marked_as_done_task_ids: Optional[List[int]] = marked_as_done_task_ids
12700
+ self.marked_as_not_done_task_ids: Optional[List[int]] = marked_as_not_done_task_ids
12701
+
12702
+ @classmethod
12703
+ def de_json(cls, json_string):
12704
+ if json_string is None: return None
12705
+ obj = cls.check_json(json_string)
12706
+ if 'checklist_message' in obj:
12707
+ obj['checklist_message'] = Message.de_json(obj['checklist_message'])
12708
+ return cls(**obj)
12709
+
12710
+
12711
+ class ChecklistTasksAdded(JsonDeserializable):
12712
+ """
12713
+ Describes a service message about tasks added to a checklist.
12714
+
12715
+ Telegram documentation: https://core.telegram.org/bots/api#checklisttasksadded
12716
+
12717
+ :param checklist_message: Optional. Message containing the checklist to which the tasks were added. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
12718
+ :type checklist_message: :class:`Message`
12719
+
12720
+ :param tasks: List of tasks added to the checklist
12721
+ :type tasks: :obj:`list` of :class:`ChecklistTask`
12722
+
12723
+ :return: Instance of the class
12724
+ :rtype: :class:`ChecklistTasksAdded`
12725
+ """
12726
+ def __init__(self, tasks: List[ChecklistTask], checklist_message: Optional[Message] = None, **kwargs):
12727
+ self.checklist_message: Optional[Message] = checklist_message
12728
+ self.tasks: List[ChecklistTask] = tasks
12729
+ @classmethod
12730
+ def de_json(cls, json_string):
12731
+ if json_string is None: return None
12732
+ obj = cls.check_json(json_string)
12733
+ if 'checklist_message' in obj:
12734
+ obj['checklist_message'] = Message.de_json(obj['checklist_message'])
12735
+ obj['tasks'] = [ChecklistTask.de_json(task) for task in obj['tasks']]
12736
+ return cls(**obj)
12737
+
12738
+ class DirectMessagePriceChanged(JsonDeserializable):
12739
+ """
12740
+ Describes a service message about a change in the price of direct messages sent to a channel chat.
12741
+
12742
+ Telegram documentation: https://core.telegram.org/bots/api#directmessagepricechanged
12743
+
12744
+ :param are_direct_messages_enabled: True, if direct messages are enabled for the channel chat; false otherwise
12745
+ :type are_direct_messages_enabled: :obj:`bool`
12746
+
12747
+ :param direct_message_star_count: Optional. The new number of Telegram Stars that must be paid by users for each direct message sent to the channel. Does not apply to users who have been exempted by administrators. Defaults to 0.
12748
+ :type direct_message_star_count: :obj:`int`
12749
+
12750
+ :return: Instance of the class
12751
+ :rtype: :class:`DirectMessagePriceChanged`
12752
+ """
12753
+ def __init__(self, are_direct_messages_enabled: bool, direct_message_star_count: Optional[int] = None, **kwargs):
12754
+ self.are_direct_messages_enabled: bool = are_direct_messages_enabled
12755
+ self.direct_message_star_count: Optional[int] = direct_message_star_count
12756
+
12757
+ @classmethod
12758
+ def de_json(cls, json_string):
12759
+ if json_string is None: return None
12760
+ obj = cls.check_json(json_string)
12761
+ return cls(**obj)
telebot/util.py CHANGED
@@ -40,7 +40,8 @@ content_type_service = [
40
40
  'write_access_allowed', 'proximity_alert_triggered', 'forum_topic_created', 'forum_topic_edited',
41
41
  'forum_topic_closed', 'forum_topic_reopened', 'general_forum_topic_hidden', 'general_forum_topic_unhidden',
42
42
  'giveaway_created', 'giveaway', 'giveaway_winners', 'giveaway_completed', 'video_chat_scheduled',
43
- 'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited',
43
+ 'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited','checklist_tasks_done',
44
+ 'checklist_tasks_added','direct_message_price_changed'
44
45
  ]
45
46
 
46
47
  #: All update types, should be used for allowed_updates parameter in polling.
@@ -255,7 +256,7 @@ def extract_command(text: str) -> Union[str, None]:
255
256
  return text.split()[0].split('@')[0][1:] if is_command(text) else None
256
257
 
257
258
 
258
- def extract_arguments(text: str) -> str or None:
259
+ def extract_arguments(text: str) -> Union[str, None]:
259
260
  """
260
261
  Returns the argument after the command.
261
262
 
telebot/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # Versions should comply with PEP440.
2
2
  # This line is parsed in setup.py:
3
- __version__ = '4.27.0'
3
+ __version__ = '4.28.0'