pyTelegramBotAPI 4.22.1__py3-none-any.whl → 4.23.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.
- {pytelegrambotapi-4.22.1.dist-info → pytelegrambotapi-4.23.0.dist-info}/METADATA +2 -2
- {pytelegrambotapi-4.22.1.dist-info → pytelegrambotapi-4.23.0.dist-info}/RECORD +13 -13
- telebot/__init__.py +130 -7
- telebot/apihelper.py +36 -11
- telebot/async_telebot.py +132 -5
- telebot/asyncio_filters.py +1 -1
- telebot/asyncio_helper.py +41 -12
- telebot/custom_filters.py +1 -1
- telebot/types.py +143 -41
- telebot/util.py +1 -1
- telebot/version.py +1 -1
- {pytelegrambotapi-4.22.1.dist-info → pytelegrambotapi-4.23.0.dist-info}/WHEEL +0 -0
- {pytelegrambotapi-4.22.1.dist-info → pytelegrambotapi-4.23.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pyTelegramBotAPI
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.23.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
|
|
@@ -53,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
53
53
|
<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
54
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
55
55
|
|
|
56
|
-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api
|
|
56
|
+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#september-6-2024"><img src="https://img.shields.io/badge/Bot%20API-7.10-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
57
57
|
|
|
58
58
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
59
59
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
telebot/__init__.py,sha256=
|
|
2
|
-
telebot/apihelper.py,sha256=
|
|
3
|
-
telebot/async_telebot.py,sha256=
|
|
4
|
-
telebot/asyncio_filters.py,sha256=
|
|
1
|
+
telebot/__init__.py,sha256=b0LIGG4qK94pnwefptKq0KVNwxR6NgAedzCdiUcGrfc,417917
|
|
2
|
+
telebot/apihelper.py,sha256=dI1K74azMPqwBwEs4UvWQ4shW36JJKAn2ptFQo-j3ss,95267
|
|
3
|
+
telebot/async_telebot.py,sha256=tksz1f9UfU6oyU1CZ_PRTtDm4k5J82uosXgBrJHrbOA,391043
|
|
4
|
+
telebot/asyncio_filters.py,sha256=w63xFjFnXtr4oo3Kqx1Fs485vQxNCgXZs1ukdkNcnEA,12854
|
|
5
5
|
telebot/asyncio_handler_backends.py,sha256=BWS7zr93FJNZJmPHBoXo4i_PIHGlmrEoWy1miXax9aI,2785
|
|
6
|
-
telebot/asyncio_helper.py,sha256=
|
|
6
|
+
telebot/asyncio_helper.py,sha256=veOPbLDag2HwlJ0CYQbIkmEHmz1ek2uk72NzNs7PdL0,96125
|
|
7
7
|
telebot/callback_data.py,sha256=k4Rz3lAONG5J2M9TESKMIjqXoBNJMfEy9nnrmJAyi3Q,5358
|
|
8
|
-
telebot/custom_filters.py,sha256=
|
|
8
|
+
telebot/custom_filters.py,sha256=ncF8_zwlSqkuATI46Xc6HQ5Y1ZoQ1fO6AlcRbs7bO3U,12975
|
|
9
9
|
telebot/formatting.py,sha256=_y8M5KOv9UOXfF9z7Et4fPVgh9JnzI1cr4un9sfdlc0,15176
|
|
10
10
|
telebot/handler_backends.py,sha256=lyKu0PaH2c4y5FfyQS3M9tOyBJ8ATjxHZkATzu01XpE,7969
|
|
11
11
|
telebot/service_utils.py,sha256=xLmlZLTVs34UOdQtMvwduor8hnLxQCx8iJ92wDGl2Mw,2053
|
|
12
|
-
telebot/types.py,sha256=
|
|
13
|
-
telebot/util.py,sha256=
|
|
14
|
-
telebot/version.py,sha256=
|
|
12
|
+
telebot/types.py,sha256=rHHkagvfWgtqxGsXvwVR_GD9EWujzn1_lm9AYnxkc40,463667
|
|
13
|
+
telebot/util.py,sha256=ylRtI4DI4I1BJAF2Ack7WyGbTN1cRkubUCbhLNiiPj4,21385
|
|
14
|
+
telebot/version.py,sha256=33cH7PM7w-P3rSAYZ0ykyw3QddU6BsFL5Asu9RL52qA,99
|
|
15
15
|
telebot/asyncio_storage/__init__.py,sha256=fraOWJby1ddJmPAXf1oXWmZJXRodSpING17MF875NPI,433
|
|
16
16
|
telebot/asyncio_storage/base_storage.py,sha256=I-NII9ZMCxCHStPc-73qSyQhjBtkhNzb2IcZPhjR1Eg,3243
|
|
17
17
|
telebot/asyncio_storage/memory_storage.py,sha256=h8yc2xpfLmbcBjPmKkqNhZtUtpNQ7EuKIfMGue61e7w,5849
|
|
@@ -35,7 +35,7 @@ telebot/storage/base_storage.py,sha256=WzGgSflKzcn2ENsgz1Q-D_v-ZKCtnMOURGOHIwNJ0
|
|
|
35
35
|
telebot/storage/memory_storage.py,sha256=-r1vuIt1YHq9btkr6E7BCu4Do-wUDlNcttG22SSgEYo,5799
|
|
36
36
|
telebot/storage/pickle_storage.py,sha256=dqw7syOJuTWyU0KK8XwbJvQ9PMyDHhZQG-MevZImEak,7121
|
|
37
37
|
telebot/storage/redis_storage.py,sha256=DReU2lc8cI0f3XMIT1N9-suGZ6jE8H9I_mapK3A-lyE,9450
|
|
38
|
-
pytelegrambotapi-4.
|
|
39
|
-
pytelegrambotapi-4.
|
|
40
|
-
pytelegrambotapi-4.
|
|
41
|
-
pytelegrambotapi-4.
|
|
38
|
+
pytelegrambotapi-4.23.0.dist-info/METADATA,sha256=7DjRELqoR1X4QlXm6oojq1e6IIt3pxX7J_5PjoLz59c,48157
|
|
39
|
+
pytelegrambotapi-4.23.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
40
|
+
pytelegrambotapi-4.23.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
|
|
41
|
+
pytelegrambotapi-4.23.0.dist-info/RECORD,,
|
telebot/__init__.py
CHANGED
|
@@ -248,6 +248,7 @@ class TeleBot:
|
|
|
248
248
|
self.business_message_handlers = []
|
|
249
249
|
self.edited_business_message_handlers = []
|
|
250
250
|
self.deleted_business_messages_handlers = []
|
|
251
|
+
self.purchased_paid_media_handlers = []
|
|
251
252
|
|
|
252
253
|
self.custom_filters = {}
|
|
253
254
|
self.state_handlers = []
|
|
@@ -724,6 +725,7 @@ class TeleBot:
|
|
|
724
725
|
new_business_messages = None
|
|
725
726
|
new_edited_business_messages = None
|
|
726
727
|
new_deleted_business_messages = None
|
|
728
|
+
new_purchased_paid_media = None
|
|
727
729
|
|
|
728
730
|
for update in updates:
|
|
729
731
|
if apihelper.ENABLE_MIDDLEWARE and not self.use_class_middlewares:
|
|
@@ -805,8 +807,10 @@ class TeleBot:
|
|
|
805
807
|
if update.deleted_business_messages:
|
|
806
808
|
if new_deleted_business_messages is None: new_deleted_business_messages = []
|
|
807
809
|
new_deleted_business_messages.append(update.deleted_business_messages)
|
|
808
|
-
|
|
809
|
-
|
|
810
|
+
if update.purchased_paid_media:
|
|
811
|
+
if new_purchased_paid_media is None: new_purchased_paid_media = []
|
|
812
|
+
new_purchased_paid_media.append(update.purchased_paid_media)
|
|
813
|
+
|
|
810
814
|
if new_messages:
|
|
811
815
|
self.process_new_messages(new_messages)
|
|
812
816
|
if new_edited_messages:
|
|
@@ -851,6 +855,8 @@ class TeleBot:
|
|
|
851
855
|
self.process_new_edited_business_message(new_edited_business_messages)
|
|
852
856
|
if new_deleted_business_messages:
|
|
853
857
|
self.process_new_deleted_business_messages(new_deleted_business_messages)
|
|
858
|
+
if new_purchased_paid_media:
|
|
859
|
+
self.process_new_purchased_paid_media(new_purchased_paid_media)
|
|
854
860
|
|
|
855
861
|
def process_new_messages(self, new_messages):
|
|
856
862
|
"""
|
|
@@ -987,8 +993,11 @@ class TeleBot:
|
|
|
987
993
|
"""
|
|
988
994
|
self._notify_command_handlers(self.deleted_business_messages_handlers, new_deleted_business_messages, 'deleted_business_messages')
|
|
989
995
|
|
|
990
|
-
|
|
991
|
-
|
|
996
|
+
def process_new_purchased_paid_media(self, new_purchased_paid_media):
|
|
997
|
+
"""
|
|
998
|
+
:meta private:
|
|
999
|
+
"""
|
|
1000
|
+
self._notify_command_handlers(self.purchased_paid_media_handlers, new_purchased_paid_media, 'purchased_paid_media')
|
|
992
1001
|
|
|
993
1002
|
def process_middlewares(self, update):
|
|
994
1003
|
"""
|
|
@@ -3136,7 +3145,9 @@ class TeleBot:
|
|
|
3136
3145
|
caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None,
|
|
3137
3146
|
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
|
|
3138
3147
|
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
|
|
3139
|
-
reply_markup: Optional[REPLY_MARKUP_TYPES]=None
|
|
3148
|
+
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
|
|
3149
|
+
payload: Optional[str]=None
|
|
3150
|
+
) -> types.Message:
|
|
3140
3151
|
"""
|
|
3141
3152
|
Use this method to send paid media to channel chats. On success, the sent Message is returned.
|
|
3142
3153
|
|
|
@@ -3175,6 +3186,12 @@ class TeleBot:
|
|
|
3175
3186
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
3176
3187
|
:type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` or :class:`telebot.types.ReplyKeyboardMarkup` or :class:`telebot.types.ReplyKeyboardRemove` or :class:`telebot.types.ForceReply`
|
|
3177
3188
|
|
|
3189
|
+
:param business_connection_id: Identifier of a business connection, in which the message will be sent
|
|
3190
|
+
:type business_connection_id: :obj:`str`
|
|
3191
|
+
|
|
3192
|
+
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
3193
|
+
:type payload: :obj:`str`
|
|
3194
|
+
|
|
3178
3195
|
:return: On success, the sent Message is returned.
|
|
3179
3196
|
:rtype: :class:`telebot.types.Message`
|
|
3180
3197
|
"""
|
|
@@ -3183,7 +3200,8 @@ class TeleBot:
|
|
|
3183
3200
|
self.token, chat_id, star_count, media, caption=caption, parse_mode=parse_mode,
|
|
3184
3201
|
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
|
|
3185
3202
|
disable_notification=disable_notification, protect_content=protect_content,
|
|
3186
|
-
reply_parameters=reply_parameters, reply_markup=reply_markup
|
|
3203
|
+
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
|
|
3204
|
+
payload=payload)
|
|
3187
3205
|
)
|
|
3188
3206
|
|
|
3189
3207
|
|
|
@@ -4195,6 +4213,62 @@ class TeleBot:
|
|
|
4195
4213
|
apihelper.edit_chat_invite_link(self.token, chat_id, invite_link, name, expire_date, member_limit, creates_join_request)
|
|
4196
4214
|
)
|
|
4197
4215
|
|
|
4216
|
+
def create_chat_subscription_invite_link(
|
|
4217
|
+
self, chat_id: Union[int, str], subscription_period: int, subscription_price: int,
|
|
4218
|
+
name: Optional[str]=None) -> types.ChatInviteLink:
|
|
4219
|
+
"""
|
|
4220
|
+
Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights.
|
|
4221
|
+
The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink.
|
|
4222
|
+
Returns the new invite link as a ChatInviteLink object.
|
|
4223
|
+
|
|
4224
|
+
Telegram documentation: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
4225
|
+
|
|
4226
|
+
:param chat_id: Unique identifier for the target channel chat or username of the target channel
|
|
4227
|
+
(in the format @channelusername)
|
|
4228
|
+
:type chat_id: :obj:`int` or :obj:`str`
|
|
4229
|
+
|
|
4230
|
+
:param name: Invite link name; 0-32 characters
|
|
4231
|
+
:type name: :obj:`str`
|
|
4232
|
+
|
|
4233
|
+
:param subscription_period: The number of seconds the subscription will be active for before the next payment.
|
|
4234
|
+
Currently, it must always be 2592000 (30 days).
|
|
4235
|
+
:type subscription_period: :obj:`int`
|
|
4236
|
+
|
|
4237
|
+
:param subscription_price: The amount of Telegram Stars a user must pay initially and after each subsequent
|
|
4238
|
+
subscription period to be a member of the chat; 1-2500
|
|
4239
|
+
:type subscription_price: :obj:`int`
|
|
4240
|
+
|
|
4241
|
+
:return: Returns the new invite link as a ChatInviteLink object.
|
|
4242
|
+
:rtype: :class:`telebot.types.ChatInviteLink`
|
|
4243
|
+
"""
|
|
4244
|
+
return types.ChatInviteLink.de_json(
|
|
4245
|
+
apihelper.create_chat_subscription_invite_link(self.token, chat_id, subscription_period, subscription_price, name=name)
|
|
4246
|
+
)
|
|
4247
|
+
|
|
4248
|
+
def edit_chat_subscription_invite_link(
|
|
4249
|
+
self, chat_id: Union[int, str], invite_link: str, name: Optional[str]=None) -> types.ChatInviteLink:
|
|
4250
|
+
"""
|
|
4251
|
+
Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights.
|
|
4252
|
+
Returns the edited invite link as a ChatInviteLink object.
|
|
4253
|
+
|
|
4254
|
+
Telegram documentation: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
4255
|
+
|
|
4256
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel
|
|
4257
|
+
(in the format @channelusername)
|
|
4258
|
+
:type chat_id: :obj:`int` or :obj:`str`
|
|
4259
|
+
|
|
4260
|
+
:param invite_link: The invite link to edit
|
|
4261
|
+
:type invite_link: :obj:`str`
|
|
4262
|
+
|
|
4263
|
+
:param name: Invite link name; 0-32 characters
|
|
4264
|
+
:type name: :obj:`str`
|
|
4265
|
+
|
|
4266
|
+
:return: Returns the edited invite link as a ChatInviteLink object.
|
|
4267
|
+
:rtype: :class:`telebot.types.ChatInviteLink`
|
|
4268
|
+
"""
|
|
4269
|
+
return types.ChatInviteLink.de_json(
|
|
4270
|
+
apihelper.edit_chat_subscription_invite_link(self.token, chat_id, invite_link, name=name)
|
|
4271
|
+
)
|
|
4198
4272
|
|
|
4199
4273
|
def revoke_chat_invite_link(
|
|
4200
4274
|
self, chat_id: Union[int, str], invite_link: str) -> types.ChatInviteLink:
|
|
@@ -5567,7 +5641,7 @@ class TeleBot:
|
|
|
5567
5641
|
|
|
5568
5642
|
|
|
5569
5643
|
def answer_pre_checkout_query(
|
|
5570
|
-
self, pre_checkout_query_id:
|
|
5644
|
+
self, pre_checkout_query_id: str, ok: bool,
|
|
5571
5645
|
error_message: Optional[str]=None) -> bool:
|
|
5572
5646
|
"""
|
|
5573
5647
|
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the
|
|
@@ -7975,6 +8049,55 @@ class TeleBot:
|
|
|
7975
8049
|
handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
|
|
7976
8050
|
self.add_pre_checkout_query_handler(handler_dict)
|
|
7977
8051
|
|
|
8052
|
+
def purchased_paid_media_handler(self, func=None, **kwargs):
|
|
8053
|
+
"""
|
|
8054
|
+
Handles new incoming purchased paid media.
|
|
8055
|
+
|
|
8056
|
+
:param func: Function executed as a filter
|
|
8057
|
+
:type func: :obj:`function`
|
|
8058
|
+
|
|
8059
|
+
:param kwargs: Optional keyword arguments(custom filters)
|
|
8060
|
+
|
|
8061
|
+
:return: None
|
|
8062
|
+
"""
|
|
8063
|
+
def decorator(handler):
|
|
8064
|
+
handler_dict = self._build_handler_dict(handler, func=func, **kwargs)
|
|
8065
|
+
self.add_purchased_paid_media_handler(handler_dict)
|
|
8066
|
+
return handler
|
|
8067
|
+
|
|
8068
|
+
return decorator
|
|
8069
|
+
|
|
8070
|
+
def add_purchased_paid_media_handler(self, handler_dict):
|
|
8071
|
+
"""
|
|
8072
|
+
Adds a purchased paid media handler
|
|
8073
|
+
Note that you should use register_purchased_paid_media_handler to add purchased_paid_media_handler to the bot.
|
|
8074
|
+
|
|
8075
|
+
:meta private:
|
|
8076
|
+
|
|
8077
|
+
:param handler_dict:
|
|
8078
|
+
:return:
|
|
8079
|
+
"""
|
|
8080
|
+
self.purchased_paid_media_handlers.append(handler_dict)
|
|
8081
|
+
|
|
8082
|
+
def register_purchased_paid_media_handler(self, callback: Callable, func: Callable, pass_bot: Optional[bool]=False, **kwargs):
|
|
8083
|
+
"""
|
|
8084
|
+
Registers purchased paid media handler.
|
|
8085
|
+
|
|
8086
|
+
:param callback: function to be called
|
|
8087
|
+
:type callback: :obj:`function`
|
|
8088
|
+
|
|
8089
|
+
:param func: Function executed as a filter
|
|
8090
|
+
:type func: :obj:`function`
|
|
8091
|
+
|
|
8092
|
+
:param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files)
|
|
8093
|
+
:type pass_bot: :obj:`bool`
|
|
8094
|
+
|
|
8095
|
+
:param kwargs: Optional keyword arguments(custom filters)
|
|
8096
|
+
|
|
8097
|
+
:return: None
|
|
8098
|
+
"""
|
|
8099
|
+
handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
|
|
8100
|
+
self.add_purchased_paid_media_handler(handler_dict)
|
|
7978
8101
|
|
|
7979
8102
|
def poll_handler(self, func, **kwargs):
|
|
7980
8103
|
"""
|
telebot/apihelper.py
CHANGED
|
@@ -529,28 +529,33 @@ def send_photo(
|
|
|
529
529
|
def send_paid_media(
|
|
530
530
|
token, chat_id, star_count, media,
|
|
531
531
|
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
|
|
532
|
-
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None
|
|
532
|
+
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
|
|
533
|
+
business_connection_id=None, payload=None):
|
|
533
534
|
method_url = r'sendPaidMedia'
|
|
534
535
|
media_json, files = convert_input_media_array(media)
|
|
535
|
-
|
|
536
|
+
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
|
|
536
537
|
if caption:
|
|
537
|
-
|
|
538
|
+
_payload['caption'] = caption
|
|
538
539
|
if parse_mode:
|
|
539
|
-
|
|
540
|
+
_payload['parse_mode'] = parse_mode
|
|
540
541
|
if caption_entities:
|
|
541
|
-
|
|
542
|
+
_payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
|
542
543
|
if show_caption_above_media is not None:
|
|
543
|
-
|
|
544
|
+
_payload['show_caption_above_media'] = show_caption_above_media
|
|
544
545
|
if disable_notification is not None:
|
|
545
|
-
|
|
546
|
+
_payload['disable_notification'] = disable_notification
|
|
546
547
|
if protect_content is not None:
|
|
547
|
-
|
|
548
|
+
_payload['protect_content'] = protect_content
|
|
548
549
|
if reply_parameters is not None:
|
|
549
|
-
|
|
550
|
+
_payload['reply_parameters'] = reply_parameters.to_json()
|
|
550
551
|
if reply_markup:
|
|
551
|
-
|
|
552
|
+
_payload['reply_markup'] = _convert_markup(reply_markup)
|
|
553
|
+
if business_connection_id:
|
|
554
|
+
_payload['business_connection_id'] = business_connection_id
|
|
555
|
+
if payload:
|
|
556
|
+
_payload['payload'] = payload
|
|
552
557
|
return _make_request(
|
|
553
|
-
token, method_url, params=
|
|
558
|
+
token, method_url, params=_payload,
|
|
554
559
|
method='post' if files else 'get',
|
|
555
560
|
files=files if files else None)
|
|
556
561
|
|
|
@@ -1202,6 +1207,26 @@ def edit_chat_invite_link(token, chat_id, invite_link, name, expire_date, member
|
|
|
1202
1207
|
|
|
1203
1208
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1204
1209
|
|
|
1210
|
+
def create_chat_subscription_invite_link(token, chat_id, subscription_period, subscription_price, name=None):
|
|
1211
|
+
method_url = 'createChatSubscriptionInviteLink'
|
|
1212
|
+
payload = {
|
|
1213
|
+
'chat_id': chat_id,
|
|
1214
|
+
'subscription_period': subscription_period,
|
|
1215
|
+
'subscription_price': subscription_price
|
|
1216
|
+
}
|
|
1217
|
+
if name:
|
|
1218
|
+
payload['name'] = name
|
|
1219
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1220
|
+
|
|
1221
|
+
def edit_chat_subscription_invite_link(token, chat_id, invite_link, name=None):
|
|
1222
|
+
method_url = 'editChatSubscriptionInviteLink'
|
|
1223
|
+
payload = {
|
|
1224
|
+
'chat_id': chat_id,
|
|
1225
|
+
'invite_link': invite_link
|
|
1226
|
+
}
|
|
1227
|
+
if name:
|
|
1228
|
+
payload['name'] = name
|
|
1229
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1205
1230
|
|
|
1206
1231
|
def revoke_chat_invite_link(token, chat_id, invite_link):
|
|
1207
1232
|
method_url = 'revokeChatInviteLink'
|
telebot/async_telebot.py
CHANGED
|
@@ -183,6 +183,7 @@ class AsyncTeleBot:
|
|
|
183
183
|
self.business_message_handlers = []
|
|
184
184
|
self.edited_business_message_handlers = []
|
|
185
185
|
self.deleted_business_messages_handlers = []
|
|
186
|
+
self.purchased_paid_media_handlers = []
|
|
186
187
|
|
|
187
188
|
self.custom_filters = {}
|
|
188
189
|
self.state_handlers = []
|
|
@@ -636,6 +637,7 @@ class AsyncTeleBot:
|
|
|
636
637
|
new_business_messages = None
|
|
637
638
|
new_edited_business_messages = None
|
|
638
639
|
new_deleted_business_messages = None
|
|
640
|
+
new_purchased_paid_media = None
|
|
639
641
|
|
|
640
642
|
|
|
641
643
|
for update in updates:
|
|
@@ -706,6 +708,9 @@ class AsyncTeleBot:
|
|
|
706
708
|
if update.deleted_business_messages:
|
|
707
709
|
if new_deleted_business_messages is None: new_deleted_business_messages = []
|
|
708
710
|
new_deleted_business_messages.append(update.deleted_business_messages)
|
|
711
|
+
if update.purchased_paid_media:
|
|
712
|
+
if new_purchased_paid_media is None: new_purchased_paid_media = []
|
|
713
|
+
new_purchased_paid_media.append(update.purchased_paid_media)
|
|
709
714
|
|
|
710
715
|
|
|
711
716
|
if new_messages:
|
|
@@ -750,6 +755,8 @@ class AsyncTeleBot:
|
|
|
750
755
|
await self.process_new_edited_business_message(new_edited_business_messages)
|
|
751
756
|
if new_deleted_business_messages:
|
|
752
757
|
await self.process_new_deleted_business_messages(new_deleted_business_messages)
|
|
758
|
+
if new_purchased_paid_media:
|
|
759
|
+
await self.process_new_purchased_paid_media(new_purchased_paid_media)
|
|
753
760
|
|
|
754
761
|
async def process_new_messages(self, new_messages):
|
|
755
762
|
"""
|
|
@@ -884,6 +891,12 @@ class AsyncTeleBot:
|
|
|
884
891
|
"""
|
|
885
892
|
await self._process_updates(self.deleted_business_messages_handlers, new_deleted_business_messages, 'deleted_business_messages')
|
|
886
893
|
|
|
894
|
+
async def process_new_purchased_paid_media(self, new_purchased_paid_media):
|
|
895
|
+
"""
|
|
896
|
+
:meta private:
|
|
897
|
+
"""
|
|
898
|
+
await self._process_updates(self.purchased_paid_media_handlers, new_purchased_paid_media, 'purchased_paid_media')
|
|
899
|
+
|
|
887
900
|
async def _get_middlewares(self, update_type):
|
|
888
901
|
"""
|
|
889
902
|
:meta private:
|
|
@@ -1867,6 +1880,56 @@ class AsyncTeleBot:
|
|
|
1867
1880
|
handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
|
|
1868
1881
|
self.add_pre_checkout_query_handler(handler_dict)
|
|
1869
1882
|
|
|
1883
|
+
def purchased_paid_media_handler(self, func=None, **kwargs):
|
|
1884
|
+
"""
|
|
1885
|
+
Handles new incoming purchased paid media.
|
|
1886
|
+
|
|
1887
|
+
:param func: Function executed as a filter
|
|
1888
|
+
:type func: :obj:`function`
|
|
1889
|
+
|
|
1890
|
+
:param kwargs: Optional keyword arguments(custom filters)
|
|
1891
|
+
|
|
1892
|
+
:return: None
|
|
1893
|
+
"""
|
|
1894
|
+
def decorator(handler):
|
|
1895
|
+
handler_dict = self._build_handler_dict(handler, func=func, **kwargs)
|
|
1896
|
+
self.add_purchased_paid_media_handler(handler_dict)
|
|
1897
|
+
return handler
|
|
1898
|
+
|
|
1899
|
+
return decorator
|
|
1900
|
+
|
|
1901
|
+
def add_purchased_paid_media_handler(self, handler_dict):
|
|
1902
|
+
"""
|
|
1903
|
+
Adds a purchased paid media handler
|
|
1904
|
+
Note that you should use register_purchased_paid_media_handler to add purchased_paid_media_handler to the bot.
|
|
1905
|
+
|
|
1906
|
+
:meta private:
|
|
1907
|
+
|
|
1908
|
+
:param handler_dict:
|
|
1909
|
+
:return:
|
|
1910
|
+
"""
|
|
1911
|
+
self.purchased_paid_media_handlers.append(handler_dict)
|
|
1912
|
+
|
|
1913
|
+
def register_purchased_paid_media_handler(self, callback: Callable, func: Callable, pass_bot: Optional[bool]=False, **kwargs):
|
|
1914
|
+
"""
|
|
1915
|
+
Registers purchased paid media handler.
|
|
1916
|
+
|
|
1917
|
+
:param callback: function to be called
|
|
1918
|
+
:type callback: :obj:`function`
|
|
1919
|
+
|
|
1920
|
+
:param func: Function executed as a filter
|
|
1921
|
+
:type func: :obj:`function`
|
|
1922
|
+
|
|
1923
|
+
:param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files)
|
|
1924
|
+
:type pass_bot: :obj:`bool`
|
|
1925
|
+
|
|
1926
|
+
:param kwargs: Optional keyword arguments(custom filters)
|
|
1927
|
+
|
|
1928
|
+
:return: None
|
|
1929
|
+
"""
|
|
1930
|
+
handler_dict = self._build_handler_dict(callback, func=func, pass_bot=pass_bot, **kwargs)
|
|
1931
|
+
self.add_purchased_paid_media_handler(handler_dict)
|
|
1932
|
+
|
|
1870
1933
|
def poll_handler(self, func, **kwargs):
|
|
1871
1934
|
"""
|
|
1872
1935
|
Handles new state of a poll. Bots receive only updates about stopped polls and polls, which are sent by the bot
|
|
@@ -3439,7 +3502,7 @@ class AsyncTeleBot:
|
|
|
3439
3502
|
|
|
3440
3503
|
disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
|
|
3441
3504
|
protect_content = self.protect_content if (protect_content is None) else protect_content
|
|
3442
|
-
result = await asyncio_helper.forward_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification,
|
|
3505
|
+
result = await asyncio_helper.forward_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id, protect_content)
|
|
3443
3506
|
return [types.MessageID.de_json(message_id) for message_id in result]
|
|
3444
3507
|
|
|
3445
3508
|
async def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int],
|
|
@@ -4564,7 +4627,8 @@ class AsyncTeleBot:
|
|
|
4564
4627
|
caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None,
|
|
4565
4628
|
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
|
|
4566
4629
|
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
|
|
4567
|
-
reply_markup: Optional[REPLY_MARKUP_TYPES]=None
|
|
4630
|
+
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
|
|
4631
|
+
payload: Optional[str]=None) -> types.Message:
|
|
4568
4632
|
"""
|
|
4569
4633
|
Use this method to send paid media to channel chats. On success, the sent Message is returned.
|
|
4570
4634
|
|
|
@@ -4603,6 +4667,12 @@ class AsyncTeleBot:
|
|
|
4603
4667
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
|
|
4604
4668
|
:type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` or :class:`telebot.types.ReplyKeyboardMarkup` or :class:`telebot.types.ReplyKeyboardRemove` or :class:`telebot.types.ForceReply`
|
|
4605
4669
|
|
|
4670
|
+
:param business_connection_id: Identifier of a business connection, in which the message will be sent
|
|
4671
|
+
:type business_connection_id: :obj:`str`
|
|
4672
|
+
|
|
4673
|
+
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
|
|
4674
|
+
:type payload: :obj:`str`
|
|
4675
|
+
|
|
4606
4676
|
:return: On success, the sent Message is returned.
|
|
4607
4677
|
:rtype: :class:`telebot.types.Message`
|
|
4608
4678
|
"""
|
|
@@ -4611,8 +4681,8 @@ class AsyncTeleBot:
|
|
|
4611
4681
|
self.token, chat_id, star_count, media, caption=caption, parse_mode=parse_mode,
|
|
4612
4682
|
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
|
|
4613
4683
|
disable_notification=disable_notification, protect_content=protect_content,
|
|
4614
|
-
reply_parameters=reply_parameters, reply_markup=reply_markup
|
|
4615
|
-
|
|
4684
|
+
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
|
|
4685
|
+
payload=payload))
|
|
4616
4686
|
|
|
4617
4687
|
async def send_media_group(
|
|
4618
4688
|
self, chat_id: Union[int, str],
|
|
@@ -5603,6 +5673,63 @@ class AsyncTeleBot:
|
|
|
5603
5673
|
return types.ChatInviteLink.de_json(
|
|
5604
5674
|
await asyncio_helper.edit_chat_invite_link(self.token, chat_id, invite_link, name, expire_date, member_limit, creates_join_request)
|
|
5605
5675
|
)
|
|
5676
|
+
|
|
5677
|
+
async def create_chat_subscription_invite_link(
|
|
5678
|
+
self, chat_id: Union[int, str], subscription_period: int, subscription_price: int,
|
|
5679
|
+
name: Optional[str]=None) -> types.ChatInviteLink:
|
|
5680
|
+
"""
|
|
5681
|
+
Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights.
|
|
5682
|
+
The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink.
|
|
5683
|
+
Returns the new invite link as a ChatInviteLink object.
|
|
5684
|
+
|
|
5685
|
+
Telegram documentation: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
5686
|
+
|
|
5687
|
+
:param chat_id: Unique identifier for the target channel chat or username of the target channel
|
|
5688
|
+
(in the format @channelusername)
|
|
5689
|
+
:type chat_id: :obj:`int` or :obj:`str`
|
|
5690
|
+
|
|
5691
|
+
:param name: Invite link name; 0-32 characters
|
|
5692
|
+
:type name: :obj:`str`
|
|
5693
|
+
|
|
5694
|
+
:param subscription_period: The number of seconds the subscription will be active for before the next payment.
|
|
5695
|
+
Currently, it must always be 2592000 (30 days).
|
|
5696
|
+
:type subscription_period: :obj:`int`
|
|
5697
|
+
|
|
5698
|
+
:param subscription_price: The amount of Telegram Stars a user must pay initially and after each subsequent
|
|
5699
|
+
subscription period to be a member of the chat; 1-2500
|
|
5700
|
+
:type subscription_price: :obj:`int`
|
|
5701
|
+
|
|
5702
|
+
:return: Returns the new invite link as a ChatInviteLink object.
|
|
5703
|
+
:rtype: :class:`telebot.types.ChatInviteLink`
|
|
5704
|
+
"""
|
|
5705
|
+
return types.ChatInviteLink.de_json(
|
|
5706
|
+
await asyncio_helper.create_chat_subscription_invite_link(self.token, chat_id, subscription_period, subscription_price, name=name)
|
|
5707
|
+
)
|
|
5708
|
+
|
|
5709
|
+
async def edit_chat_subscription_invite_link(
|
|
5710
|
+
self, chat_id: Union[int, str], invite_link: str, name: Optional[str]=None) -> types.ChatInviteLink:
|
|
5711
|
+
"""
|
|
5712
|
+
Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights.
|
|
5713
|
+
Returns the edited invite link as a ChatInviteLink object.
|
|
5714
|
+
|
|
5715
|
+
Telegram documentation: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
5716
|
+
|
|
5717
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel
|
|
5718
|
+
(in the format @channelusername)
|
|
5719
|
+
:type chat_id: :obj:`int` or :obj:`str`
|
|
5720
|
+
|
|
5721
|
+
:param invite_link: The invite link to edit
|
|
5722
|
+
:type invite_link: :obj:`str`
|
|
5723
|
+
|
|
5724
|
+
:param name: Invite link name; 0-32 characters
|
|
5725
|
+
:type name: :obj:`str`
|
|
5726
|
+
|
|
5727
|
+
:return: Returns the edited invite link as a ChatInviteLink object.
|
|
5728
|
+
:rtype: :class:`telebot.types.ChatInviteLink`
|
|
5729
|
+
"""
|
|
5730
|
+
return types.ChatInviteLink.de_json(
|
|
5731
|
+
await asyncio_helper.edit_chat_subscription_invite_link(self.token, chat_id, invite_link, name=name)
|
|
5732
|
+
)
|
|
5606
5733
|
|
|
5607
5734
|
async def revoke_chat_invite_link(
|
|
5608
5735
|
self, chat_id: Union[int, str], invite_link: str) -> types.ChatInviteLink:
|
|
@@ -6918,7 +7045,7 @@ class AsyncTeleBot:
|
|
|
6918
7045
|
return await asyncio_helper.answer_shipping_query(self.token, shipping_query_id, ok, shipping_options, error_message)
|
|
6919
7046
|
|
|
6920
7047
|
async def answer_pre_checkout_query(
|
|
6921
|
-
self, pre_checkout_query_id:
|
|
7048
|
+
self, pre_checkout_query_id: str, ok: bool,
|
|
6922
7049
|
error_message: Optional[str]=None) -> bool:
|
|
6923
7050
|
"""
|
|
6924
7051
|
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the
|
telebot/asyncio_filters.py
CHANGED
|
@@ -398,7 +398,7 @@ class StateFilter(AdvancedCustomFilter):
|
|
|
398
398
|
:meta private:
|
|
399
399
|
"""
|
|
400
400
|
|
|
401
|
-
chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(message, self.bot.
|
|
401
|
+
chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(message, self.bot.bot_id)
|
|
402
402
|
|
|
403
403
|
if chat_id is None:
|
|
404
404
|
chat_id = user_id # May change in future
|
telebot/asyncio_helper.py
CHANGED
|
@@ -309,7 +309,7 @@ async def send_message(
|
|
|
309
309
|
if message_effect_id:
|
|
310
310
|
params['message_effect_id'] = message_effect_id
|
|
311
311
|
|
|
312
|
-
return await _process_request(token, method_name, params=params)
|
|
312
|
+
return await _process_request(token, method_name, params=params, method='post')
|
|
313
313
|
|
|
314
314
|
# methods
|
|
315
315
|
|
|
@@ -519,28 +519,35 @@ async def send_photo(
|
|
|
519
519
|
async def send_paid_media(
|
|
520
520
|
token, chat_id, star_count, media,
|
|
521
521
|
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
|
|
522
|
-
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None
|
|
522
|
+
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
|
|
523
|
+
business_connection_id=None, payload=None):
|
|
523
524
|
method_url = r'sendPaidMedia'
|
|
524
525
|
media_json, files = convert_input_media_array(media)
|
|
525
|
-
|
|
526
|
+
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
|
|
527
|
+
# USE _payload for request payload
|
|
526
528
|
if caption:
|
|
527
|
-
|
|
529
|
+
_payload['caption'] = caption
|
|
528
530
|
if parse_mode:
|
|
529
|
-
|
|
531
|
+
_payload['parse_mode'] = parse_mode
|
|
530
532
|
if caption_entities:
|
|
531
|
-
|
|
533
|
+
_payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
|
532
534
|
if show_caption_above_media is not None:
|
|
533
|
-
|
|
535
|
+
_payload['show_caption_above_media'] = show_caption_above_media
|
|
534
536
|
if disable_notification is not None:
|
|
535
|
-
|
|
537
|
+
_payload['disable_notification'] = disable_notification
|
|
536
538
|
if protect_content is not None:
|
|
537
|
-
|
|
539
|
+
_payload['protect_content'] = protect_content
|
|
538
540
|
if reply_parameters is not None:
|
|
539
|
-
|
|
541
|
+
_payload['reply_parameters'] = reply_parameters.to_json()
|
|
540
542
|
if reply_markup:
|
|
541
|
-
|
|
543
|
+
_payload['reply_markup'] = _convert_markup(reply_markup)
|
|
544
|
+
if business_connection_id:
|
|
545
|
+
_payload['business_connection_id'] = business_connection_id
|
|
546
|
+
if payload:
|
|
547
|
+
_payload['payload'] = payload
|
|
548
|
+
|
|
542
549
|
return await _process_request(
|
|
543
|
-
token, method_url, params=
|
|
550
|
+
token, method_url, params=_payload,
|
|
544
551
|
method='post' if files else 'get',
|
|
545
552
|
files=files if files else None)
|
|
546
553
|
|
|
@@ -1182,6 +1189,28 @@ async def edit_chat_invite_link(token, chat_id, invite_link, name, expire_date,
|
|
|
1182
1189
|
|
|
1183
1190
|
return await _process_request(token, method_url, params=payload, method='post')
|
|
1184
1191
|
|
|
1192
|
+
async def create_chat_subscription_invite_link(token, chat_id, subscription_period, subscription_price, name=None):
|
|
1193
|
+
method_url = 'createChatSubscriptionInviteLink'
|
|
1194
|
+
payload = {
|
|
1195
|
+
'chat_id': chat_id,
|
|
1196
|
+
'subscription_period': subscription_period,
|
|
1197
|
+
'subscription_price': subscription_price
|
|
1198
|
+
}
|
|
1199
|
+
if name:
|
|
1200
|
+
payload['name'] = name
|
|
1201
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1202
|
+
|
|
1203
|
+
async def edit_chat_subscription_invite_link(token, chat_id, invite_link, name=None):
|
|
1204
|
+
method_url = 'editChatSubscriptionInviteLink'
|
|
1205
|
+
payload = {
|
|
1206
|
+
'chat_id': chat_id,
|
|
1207
|
+
'invite_link': invite_link
|
|
1208
|
+
}
|
|
1209
|
+
if name:
|
|
1210
|
+
payload['name'] = name
|
|
1211
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1212
|
+
|
|
1213
|
+
|
|
1185
1214
|
async def revoke_chat_invite_link(token, chat_id, invite_link):
|
|
1186
1215
|
method_url = 'revokeChatInviteLink'
|
|
1187
1216
|
payload = {
|
telebot/custom_filters.py
CHANGED
|
@@ -404,7 +404,7 @@ class StateFilter(AdvancedCustomFilter):
|
|
|
404
404
|
:meta private:
|
|
405
405
|
"""
|
|
406
406
|
|
|
407
|
-
chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(message, self.bot.
|
|
407
|
+
chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(message, self.bot.bot_id)
|
|
408
408
|
|
|
409
409
|
if chat_id is None:
|
|
410
410
|
chat_id = user_id # May change in future
|
telebot/types.py
CHANGED
|
@@ -153,6 +153,9 @@ class Update(JsonDeserializable):
|
|
|
153
153
|
checkout
|
|
154
154
|
:type pre_checkout_query: :class:`telebot.types.PreCheckoutQuery`
|
|
155
155
|
|
|
156
|
+
:purchased_paid_media: Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
|
|
157
|
+
:type purchased_paid_media: :class:`telebot.types.PaidMediaPurchased`
|
|
158
|
+
|
|
156
159
|
:param poll: Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the
|
|
157
160
|
bot
|
|
158
161
|
:type poll: :class:`telebot.types.Poll`
|
|
@@ -222,18 +225,19 @@ class Update(JsonDeserializable):
|
|
|
222
225
|
business_message = Message.de_json(obj.get('business_message'))
|
|
223
226
|
edited_business_message = Message.de_json(obj.get('edited_business_message'))
|
|
224
227
|
deleted_business_messages = BusinessMessagesDeleted.de_json(obj.get('deleted_business_messages'))
|
|
228
|
+
purchased_paid_media = PaidMediaPurchased.de_json(obj.get('purchased_paid_media'))
|
|
225
229
|
|
|
226
230
|
return cls(update_id, message, edited_message, channel_post, edited_channel_post, inline_query,
|
|
227
231
|
chosen_inline_result, callback_query, shipping_query, pre_checkout_query, poll, poll_answer,
|
|
228
232
|
my_chat_member, chat_member, chat_join_request, message_reaction, message_reaction_count,
|
|
229
233
|
removed_chat_boost, chat_boost, business_connection, business_message, edited_business_message,
|
|
230
|
-
deleted_business_messages)
|
|
234
|
+
deleted_business_messages, purchased_paid_media)
|
|
231
235
|
|
|
232
236
|
def __init__(self, update_id, message, edited_message, channel_post, edited_channel_post, inline_query,
|
|
233
237
|
chosen_inline_result, callback_query, shipping_query, pre_checkout_query, poll, poll_answer,
|
|
234
238
|
my_chat_member, chat_member, chat_join_request, message_reaction, message_reaction_count,
|
|
235
239
|
removed_chat_boost, chat_boost, business_connection, business_message, edited_business_message,
|
|
236
|
-
deleted_business_messages,
|
|
240
|
+
deleted_business_messages, purchased_paid_media):
|
|
237
241
|
self.update_id: int = update_id
|
|
238
242
|
self.message: Optional[Message] = message
|
|
239
243
|
self.edited_message: Optional[Message] = edited_message
|
|
@@ -257,6 +261,7 @@ class Update(JsonDeserializable):
|
|
|
257
261
|
self.business_message: Optional[Message] = business_message
|
|
258
262
|
self.edited_business_message: Optional[Message] = edited_business_message
|
|
259
263
|
self.deleted_business_messages: Optional[BusinessMessagesDeleted] = deleted_business_messages
|
|
264
|
+
self.purchased_paid_media: Optional[PaidMediaPurchased] = purchased_paid_media
|
|
260
265
|
|
|
261
266
|
|
|
262
267
|
|
|
@@ -1525,7 +1530,7 @@ class Message(JsonDeserializable):
|
|
|
1525
1530
|
self.json = json_string
|
|
1526
1531
|
|
|
1527
1532
|
@property
|
|
1528
|
-
def html_text(self) -> str:
|
|
1533
|
+
def html_text(self) -> Optional[str]:
|
|
1529
1534
|
"""
|
|
1530
1535
|
Returns html-rendered text.
|
|
1531
1536
|
"""
|
|
@@ -1534,7 +1539,7 @@ class Message(JsonDeserializable):
|
|
|
1534
1539
|
return apply_html_entities(self.text, self.entities, getattr(self, "custom_subs", None))
|
|
1535
1540
|
|
|
1536
1541
|
@property
|
|
1537
|
-
def html_caption(self) -> str:
|
|
1542
|
+
def html_caption(self) -> Optional[str]:
|
|
1538
1543
|
"""
|
|
1539
1544
|
Returns html-rendered caption.
|
|
1540
1545
|
"""
|
|
@@ -1618,6 +1623,14 @@ class Message(JsonDeserializable):
|
|
|
1618
1623
|
logger.warning('The parameter "user_shared" is deprecated, use "users_shared" instead')
|
|
1619
1624
|
return self.users_shared
|
|
1620
1625
|
|
|
1626
|
+
@property
|
|
1627
|
+
def any_text(self) -> Optional[str]:
|
|
1628
|
+
return self.caption if (self.caption is not None) else self.text
|
|
1629
|
+
|
|
1630
|
+
@property
|
|
1631
|
+
def any_entities(self) -> Optional[List[MessageEntity]]:
|
|
1632
|
+
return self.caption_entities if (self.caption_entities is not None) else self.entities
|
|
1633
|
+
|
|
1621
1634
|
|
|
1622
1635
|
# noinspection PyShadowingBuiltins
|
|
1623
1636
|
class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable):
|
|
@@ -2553,13 +2566,13 @@ class KeyboardButtonRequestUsers(Dictionaryable):
|
|
|
2553
2566
|
"""
|
|
2554
2567
|
def __init__(
|
|
2555
2568
|
self, request_id: int, user_is_bot: Optional[bool]=None, user_is_premium: Optional[bool]=None,
|
|
2556
|
-
max_quantity: Optional[int]=None, request_name: Optional[
|
|
2569
|
+
max_quantity: Optional[int]=None, request_name: Optional[bool]=None, request_username: Optional[bool]=None,
|
|
2557
2570
|
request_photo: Optional[bool]=None) -> None:
|
|
2558
2571
|
self.request_id: int = request_id
|
|
2559
2572
|
self.user_is_bot: Optional[bool] = user_is_bot
|
|
2560
2573
|
self.user_is_premium: Optional[bool] = user_is_premium
|
|
2561
2574
|
self.max_quantity: Optional[int] = max_quantity
|
|
2562
|
-
self.request_name: Optional[
|
|
2575
|
+
self.request_name: Optional[bool] = request_name
|
|
2563
2576
|
self.request_username: Optional[bool] = request_username
|
|
2564
2577
|
self.request_photo: Optional[bool] = request_photo
|
|
2565
2578
|
|
|
@@ -2734,6 +2747,7 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
|
|
|
2734
2747
|
if request_user is not None:
|
|
2735
2748
|
logger.warning('The parameter "request_user" is deprecated, use "request_users" instead')
|
|
2736
2749
|
if self.request_users is None:
|
|
2750
|
+
# noinspection PyTypeChecker
|
|
2737
2751
|
self.request_users = request_user
|
|
2738
2752
|
|
|
2739
2753
|
|
|
@@ -4268,6 +4282,7 @@ class ChosenInlineResult(JsonDeserializable):
|
|
|
4268
4282
|
self.query: str = query
|
|
4269
4283
|
|
|
4270
4284
|
|
|
4285
|
+
# noinspection PyShadowingBuiltins
|
|
4271
4286
|
class InlineQueryResultBase(ABC, Dictionaryable, JsonSerializable):
|
|
4272
4287
|
"""
|
|
4273
4288
|
This object represents one result of an inline query. Telegram clients currently support results of the following 20 types:
|
|
@@ -5407,8 +5422,8 @@ class InlineQueryResultCachedBase(ABC, JsonSerializable):
|
|
|
5407
5422
|
Base class of all InlineQueryResultCached* classes.
|
|
5408
5423
|
"""
|
|
5409
5424
|
def __init__(self):
|
|
5410
|
-
self.type: str =
|
|
5411
|
-
self.id: str =
|
|
5425
|
+
self.type: str = ""
|
|
5426
|
+
self.id: str = ""
|
|
5412
5427
|
self.title: Optional[str] = None
|
|
5413
5428
|
self.description: Optional[str] = None
|
|
5414
5429
|
self.caption: Optional[str] = None
|
|
@@ -5416,6 +5431,7 @@ class InlineQueryResultCachedBase(ABC, JsonSerializable):
|
|
|
5416
5431
|
self.input_message_content: Optional[InputMessageContent] = None
|
|
5417
5432
|
self.parse_mode: Optional[str] = None
|
|
5418
5433
|
self.caption_entities: Optional[List[MessageEntity]] = None
|
|
5434
|
+
# noinspection PyTypeChecker
|
|
5419
5435
|
self.payload_dic: Dict[str] = {}
|
|
5420
5436
|
self.show_caption_above_media: Optional[bool] = None
|
|
5421
5437
|
|
|
@@ -7104,6 +7120,7 @@ class InputPollOption(JsonSerializable):
|
|
|
7104
7120
|
return json_dict
|
|
7105
7121
|
|
|
7106
7122
|
|
|
7123
|
+
# noinspection PyShadowingBuiltins
|
|
7107
7124
|
class Poll(JsonDeserializable):
|
|
7108
7125
|
"""
|
|
7109
7126
|
This object contains information about a poll.
|
|
@@ -7586,7 +7603,7 @@ class MenuButton(JsonDeserializable, JsonSerializable, Dictionaryable):
|
|
|
7586
7603
|
raise NotImplementedError
|
|
7587
7604
|
|
|
7588
7605
|
|
|
7589
|
-
# noinspection PyUnusedLocal
|
|
7606
|
+
# noinspection PyUnusedLocal,PyShadowingBuiltins
|
|
7590
7607
|
class MenuButtonCommands(MenuButton):
|
|
7591
7608
|
"""
|
|
7592
7609
|
Represents a menu button, which opens the bot's list of commands.
|
|
@@ -7610,7 +7627,7 @@ class MenuButtonCommands(MenuButton):
|
|
|
7610
7627
|
return json.dumps(self.to_dict())
|
|
7611
7628
|
|
|
7612
7629
|
|
|
7613
|
-
# noinspection PyUnusedLocal
|
|
7630
|
+
# noinspection PyUnusedLocal,PyShadowingBuiltins
|
|
7614
7631
|
class MenuButtonWebApp(MenuButton):
|
|
7615
7632
|
"""
|
|
7616
7633
|
Represents a menu button, which launches a Web App.
|
|
@@ -7645,7 +7662,7 @@ class MenuButtonWebApp(MenuButton):
|
|
|
7645
7662
|
return json.dumps(self.to_dict())
|
|
7646
7663
|
|
|
7647
7664
|
|
|
7648
|
-
# noinspection PyUnusedLocal
|
|
7665
|
+
# noinspection PyUnusedLocal,PyShadowingBuiltins
|
|
7649
7666
|
class MenuButtonDefault(MenuButton):
|
|
7650
7667
|
"""
|
|
7651
7668
|
Describes that no specific value for the menu button was set.
|
|
@@ -8202,7 +8219,7 @@ class InputSticker(Dictionaryable, JsonSerializable):
|
|
|
8202
8219
|
def to_json(self) -> str:
|
|
8203
8220
|
return json.dumps(self.to_dict())
|
|
8204
8221
|
|
|
8205
|
-
def convert_input_sticker(self) -> Tuple[
|
|
8222
|
+
def convert_input_sticker(self) -> Tuple[str, Optional[dict]]:
|
|
8206
8223
|
if service_utils.is_string(self.sticker):
|
|
8207
8224
|
return self.to_json(), None
|
|
8208
8225
|
|
|
@@ -8343,6 +8360,7 @@ class InlineQueryResultsButton(JsonSerializable, Dictionaryable):
|
|
|
8343
8360
|
return json.dumps(self.to_dict())
|
|
8344
8361
|
|
|
8345
8362
|
|
|
8363
|
+
# noinspection PyShadowingBuiltins
|
|
8346
8364
|
class Story(JsonDeserializable):
|
|
8347
8365
|
"""
|
|
8348
8366
|
This object represents a story.
|
|
@@ -8465,6 +8483,27 @@ class ReactionTypeCustomEmoji(ReactionType):
|
|
|
8465
8483
|
return json_dict
|
|
8466
8484
|
|
|
8467
8485
|
|
|
8486
|
+
class ReactionTypePaid(ReactionType):
|
|
8487
|
+
"""
|
|
8488
|
+
This object represents a paid reaction type.
|
|
8489
|
+
|
|
8490
|
+
Telegram documentation: https://core.telegram.org/bots/api#reactiontypepaid
|
|
8491
|
+
|
|
8492
|
+
:param type: Type of the reaction, must be paid
|
|
8493
|
+
:type type: :obj:`str`
|
|
8494
|
+
|
|
8495
|
+
:return: Instance of the class
|
|
8496
|
+
:rtype: :class:`ReactionTypePaid`
|
|
8497
|
+
"""
|
|
8498
|
+
|
|
8499
|
+
def __init__(self, **kwargs) -> None:
|
|
8500
|
+
super().__init__('paid')
|
|
8501
|
+
|
|
8502
|
+
def to_dict(self) -> dict:
|
|
8503
|
+
return super().to_dict()
|
|
8504
|
+
|
|
8505
|
+
|
|
8506
|
+
|
|
8468
8507
|
class MessageReactionUpdated(JsonDeserializable):
|
|
8469
8508
|
"""
|
|
8470
8509
|
This object represents a service message about a change in the list of the current user's reactions to a message.
|
|
@@ -8955,6 +8994,9 @@ class Giveaway(JsonDeserializable):
|
|
|
8955
8994
|
:param country_codes: Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway.
|
|
8956
8995
|
:type country_codes: :obj:`list` of :obj:`str`
|
|
8957
8996
|
|
|
8997
|
+
:param prize_star_count: Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
|
|
8998
|
+
:type prize_star_count: :obj:`int`
|
|
8999
|
+
|
|
8958
9000
|
:param premium_subscription_month_count: Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
|
|
8959
9001
|
:type premium_subscription_month_count: :obj:`int`
|
|
8960
9002
|
|
|
@@ -8972,7 +9014,7 @@ class Giveaway(JsonDeserializable):
|
|
|
8972
9014
|
def __init__(self, chats: List[Chat], winners_selection_date: int, winner_count: int,
|
|
8973
9015
|
only_new_members: Optional[bool] = None, has_public_winners: Optional[bool] = None,
|
|
8974
9016
|
prize_description: Optional[str] = None, country_codes: Optional[List[str]] = None,
|
|
8975
|
-
premium_subscription_month_count: Optional[int] = None, **kwargs) -> None:
|
|
9017
|
+
premium_subscription_month_count: Optional[int] = None, prize_star_count: Optional[int] = None, **kwargs) -> None:
|
|
8976
9018
|
self.chats: List[Chat] = chats
|
|
8977
9019
|
self.winners_selection_date: int = winners_selection_date
|
|
8978
9020
|
self.winner_count: int = winner_count
|
|
@@ -8981,6 +9023,7 @@ class Giveaway(JsonDeserializable):
|
|
|
8981
9023
|
self.prize_description: Optional[str] = prize_description
|
|
8982
9024
|
self.country_codes: Optional[List[str]] = country_codes
|
|
8983
9025
|
self.premium_subscription_month_count: Optional[int] = premium_subscription_month_count
|
|
9026
|
+
self.prize_star_count: Optional[int] = prize_star_count
|
|
8984
9027
|
|
|
8985
9028
|
|
|
8986
9029
|
class GiveawayWinners(JsonDeserializable):
|
|
@@ -9022,6 +9065,9 @@ class GiveawayWinners(JsonDeserializable):
|
|
|
9022
9065
|
:param prize_description: Optional. Description of additional giveaway prize
|
|
9023
9066
|
:type prize_description: :obj:`str`
|
|
9024
9067
|
|
|
9068
|
+
:param prize_star_count: Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
|
|
9069
|
+
:type prize_star_count: :obj:`int`
|
|
9070
|
+
|
|
9025
9071
|
:return: Instance of the class
|
|
9026
9072
|
:rtype: :class:`GiveawayWinners`
|
|
9027
9073
|
"""
|
|
@@ -9038,7 +9084,7 @@ class GiveawayWinners(JsonDeserializable):
|
|
|
9038
9084
|
winners: List[User], additional_chat_count: Optional[int] = None,
|
|
9039
9085
|
premium_subscription_month_count: Optional[int] = None, unclaimed_prize_count: Optional[int] = None,
|
|
9040
9086
|
only_new_members: Optional[bool] = None, was_refunded: Optional[bool] = None,
|
|
9041
|
-
prize_description: Optional[str] = None, **kwargs) -> None:
|
|
9087
|
+
prize_description: Optional[str] = None, prize_star_count: Optional[int] = None, **kwargs) -> None:
|
|
9042
9088
|
self.chat: Chat = chat
|
|
9043
9089
|
self.giveaway_message_id: int = giveaway_message_id
|
|
9044
9090
|
self.winners_selection_date: int = winners_selection_date
|
|
@@ -9050,6 +9096,7 @@ class GiveawayWinners(JsonDeserializable):
|
|
|
9050
9096
|
self.only_new_members: Optional[bool] = only_new_members
|
|
9051
9097
|
self.was_refunded: Optional[bool] = was_refunded
|
|
9052
9098
|
self.prize_description: Optional[str] = prize_description
|
|
9099
|
+
self.prize_star_count: Optional[int] = prize_star_count
|
|
9053
9100
|
|
|
9054
9101
|
|
|
9055
9102
|
class GiveawayCompleted(JsonDeserializable):
|
|
@@ -9067,6 +9114,9 @@ class GiveawayCompleted(JsonDeserializable):
|
|
|
9067
9114
|
:param giveaway_message: Optional. Message with the giveaway that was completed, if it wasn't deleted
|
|
9068
9115
|
:type giveaway_message: :class:`Message`
|
|
9069
9116
|
|
|
9117
|
+
:param is_star_giveaway: Optional. True, if the giveaway was a Telegram Star giveaway
|
|
9118
|
+
:type is_star_giveaway: :obj:`bool`
|
|
9119
|
+
|
|
9070
9120
|
:return: Instance of the class
|
|
9071
9121
|
:rtype: :class:`GiveawayCompleted`
|
|
9072
9122
|
"""
|
|
@@ -9080,15 +9130,21 @@ class GiveawayCompleted(JsonDeserializable):
|
|
|
9080
9130
|
return cls(**obj)
|
|
9081
9131
|
|
|
9082
9132
|
def __init__(self, winner_count: int, unclaimed_prize_count: Optional[int] = None,
|
|
9083
|
-
giveaway_message: Optional[Message] = None, **kwargs) -> None:
|
|
9133
|
+
giveaway_message: Optional[Message] = None, is_star_giveaway: Optional[bool] = None, **kwargs) -> None:
|
|
9084
9134
|
self.winner_count: int = winner_count
|
|
9085
9135
|
self.unclaimed_prize_count: Optional[int] = unclaimed_prize_count
|
|
9086
9136
|
self.giveaway_message: Optional[Message] = giveaway_message
|
|
9137
|
+
self.is_star_giveaway: Optional[bool] = is_star_giveaway
|
|
9087
9138
|
|
|
9088
9139
|
|
|
9089
9140
|
class GiveawayCreated(JsonDeserializable):
|
|
9090
9141
|
"""
|
|
9091
|
-
This object represents a service message about the creation of a scheduled giveaway.
|
|
9142
|
+
This object represents a service message about the creation of a scheduled giveaway.
|
|
9143
|
+
|
|
9144
|
+
:prize_star_count: Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
|
|
9145
|
+
:type prize_star_count: :obj:`int`
|
|
9146
|
+
|
|
9147
|
+
:return: Instance of the class
|
|
9092
9148
|
"""
|
|
9093
9149
|
|
|
9094
9150
|
@classmethod
|
|
@@ -9097,8 +9153,8 @@ class GiveawayCreated(JsonDeserializable):
|
|
|
9097
9153
|
obj = cls.check_json(json_string)
|
|
9098
9154
|
return cls(**obj)
|
|
9099
9155
|
|
|
9100
|
-
def __init__(self, **kwargs) -> None:
|
|
9101
|
-
|
|
9156
|
+
def __init__(self, prize_star_count=None, **kwargs) -> None:
|
|
9157
|
+
self.prize_star_count: Optional[str] = prize_star_count
|
|
9102
9158
|
|
|
9103
9159
|
|
|
9104
9160
|
class TextQuote(JsonDeserializable):
|
|
@@ -9250,12 +9306,12 @@ class UsersShared(JsonDeserializable):
|
|
|
9250
9306
|
self.users: List[SharedUser] = users
|
|
9251
9307
|
|
|
9252
9308
|
@property
|
|
9253
|
-
def user_id(self) ->
|
|
9309
|
+
def user_id(self) -> None:
|
|
9254
9310
|
logger.warning('The parameter "user_id" is deprecated, use "user_ids" instead')
|
|
9255
9311
|
return None
|
|
9256
9312
|
|
|
9257
9313
|
@property
|
|
9258
|
-
def user_ids(self) -> List[
|
|
9314
|
+
def user_ids(self) -> List[SharedUser]:
|
|
9259
9315
|
logger.warning('The parameter "user_ids" is deprecated, use "users" instead')
|
|
9260
9316
|
return self.users
|
|
9261
9317
|
|
|
@@ -9429,6 +9485,9 @@ class ChatBoostSourceGiveaway(ChatBoostSource):
|
|
|
9429
9485
|
:param is_unclaimed: True, if the giveaway was completed, but there was no user to win the prize
|
|
9430
9486
|
:type is_unclaimed: :obj:`bool`
|
|
9431
9487
|
|
|
9488
|
+
:param prize_star_count: Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
|
|
9489
|
+
:type prize_star_count: :obj:`int`
|
|
9490
|
+
|
|
9432
9491
|
:return: Instance of the class
|
|
9433
9492
|
:rtype: :class:`ChatBoostSourceGiveaway`
|
|
9434
9493
|
"""
|
|
@@ -9440,11 +9499,12 @@ class ChatBoostSourceGiveaway(ChatBoostSource):
|
|
|
9440
9499
|
obj['user'] = User.de_json(obj.get('user'))
|
|
9441
9500
|
return cls(**obj)
|
|
9442
9501
|
|
|
9443
|
-
def __init__(self, source, giveaway_message_id, user=None, is_unclaimed=None, **kwargs):
|
|
9502
|
+
def __init__(self, source, giveaway_message_id, user=None, is_unclaimed=None, prize_star_count=None, **kwargs):
|
|
9444
9503
|
self.source: str = source
|
|
9445
9504
|
self.giveaway_message_id: int = giveaway_message_id
|
|
9446
|
-
self.user: User = user
|
|
9447
|
-
self.is_unclaimed: bool = is_unclaimed
|
|
9505
|
+
self.user: Optional[User] = user
|
|
9506
|
+
self.is_unclaimed: Optional[bool] = is_unclaimed
|
|
9507
|
+
self.prize_star_count: Optional[int] = prize_star_count
|
|
9448
9508
|
|
|
9449
9509
|
|
|
9450
9510
|
class ChatBoost(JsonDeserializable):
|
|
@@ -10217,8 +10277,9 @@ class RevenueWithdrawalState(JsonDeserializable):
|
|
|
10217
10277
|
elif obj["type"] == "failed":
|
|
10218
10278
|
return RevenueWithdrawalStateFailed.de_json(obj)
|
|
10219
10279
|
return None
|
|
10220
|
-
|
|
10221
10280
|
|
|
10281
|
+
|
|
10282
|
+
# noinspection PyShadowingBuiltins
|
|
10222
10283
|
class RevenueWithdrawalStatePending(RevenueWithdrawalState):
|
|
10223
10284
|
"""
|
|
10224
10285
|
The withdrawal is in progress.
|
|
@@ -10232,7 +10293,6 @@ class RevenueWithdrawalStatePending(RevenueWithdrawalState):
|
|
|
10232
10293
|
:rtype: :class:`RevenueWithdrawalStatePending`
|
|
10233
10294
|
"""
|
|
10234
10295
|
|
|
10235
|
-
# noinspection PyPackageRequirements
|
|
10236
10296
|
def __init__(self, type, **kwargs):
|
|
10237
10297
|
self.type: str = type
|
|
10238
10298
|
|
|
@@ -10243,6 +10303,7 @@ class RevenueWithdrawalStatePending(RevenueWithdrawalState):
|
|
|
10243
10303
|
return cls(**obj)
|
|
10244
10304
|
|
|
10245
10305
|
|
|
10306
|
+
# noinspection PyShadowingBuiltins
|
|
10246
10307
|
class RevenueWithdrawalStateSucceeded(RevenueWithdrawalState):
|
|
10247
10308
|
"""
|
|
10248
10309
|
The withdrawal succeeded.
|
|
@@ -10262,7 +10323,6 @@ class RevenueWithdrawalStateSucceeded(RevenueWithdrawalState):
|
|
|
10262
10323
|
:rtype: :class:`RevenueWithdrawalStateSucceeded`
|
|
10263
10324
|
"""
|
|
10264
10325
|
|
|
10265
|
-
# noinspection PyPackageRequirements
|
|
10266
10326
|
def __init__(self, type, date, url, **kwargs):
|
|
10267
10327
|
self.type: str = type
|
|
10268
10328
|
self.date: int = date
|
|
@@ -10273,9 +10333,9 @@ class RevenueWithdrawalStateSucceeded(RevenueWithdrawalState):
|
|
|
10273
10333
|
if json_string is None: return None
|
|
10274
10334
|
obj = cls.check_json(json_string)
|
|
10275
10335
|
return cls(**obj)
|
|
10276
|
-
|
|
10277
10336
|
|
|
10278
|
-
|
|
10337
|
+
|
|
10338
|
+
# noinspection PyShadowingBuiltins
|
|
10279
10339
|
class RevenueWithdrawalStateFailed(RevenueWithdrawalState):
|
|
10280
10340
|
"""
|
|
10281
10341
|
The withdrawal failed and the transaction was refunded.
|
|
@@ -10289,7 +10349,6 @@ class RevenueWithdrawalStateFailed(RevenueWithdrawalState):
|
|
|
10289
10349
|
:rtype: :class:`RevenueWithdrawalStateFailed`
|
|
10290
10350
|
"""
|
|
10291
10351
|
|
|
10292
|
-
# noinspection PyPackageRequirements
|
|
10293
10352
|
def __init__(self, type, **kwargs):
|
|
10294
10353
|
self.type: str = type
|
|
10295
10354
|
|
|
@@ -10329,7 +10388,9 @@ class TransactionPartner(JsonDeserializable):
|
|
|
10329
10388
|
return TransactionPartnerTelegramAds.de_json(obj)
|
|
10330
10389
|
elif obj["type"] == "other":
|
|
10331
10390
|
return TransactionPartnerOther.de_json(obj)
|
|
10332
|
-
|
|
10391
|
+
|
|
10392
|
+
|
|
10393
|
+
# noinspection PyShadowingBuiltins
|
|
10333
10394
|
class TransactionPartnerFragment(TransactionPartner):
|
|
10334
10395
|
"""
|
|
10335
10396
|
Describes a withdrawal transaction with Fragment.
|
|
@@ -10347,7 +10408,6 @@ class TransactionPartnerFragment(TransactionPartner):
|
|
|
10347
10408
|
|
|
10348
10409
|
"""
|
|
10349
10410
|
|
|
10350
|
-
# noinspection PyPackageRequirements
|
|
10351
10411
|
def __init__(self, type, withdrawal_state=None, **kwargs):
|
|
10352
10412
|
self.type: str = type
|
|
10353
10413
|
self.withdrawal_state: Optional[RevenueWithdrawalState] = withdrawal_state
|
|
@@ -10359,9 +10419,9 @@ class TransactionPartnerFragment(TransactionPartner):
|
|
|
10359
10419
|
if 'withdrawal_state' in obj:
|
|
10360
10420
|
obj['withdrawal_state'] = RevenueWithdrawalState.de_json(obj['withdrawal_state'])
|
|
10361
10421
|
return cls(**obj)
|
|
10362
|
-
|
|
10363
10422
|
|
|
10364
10423
|
|
|
10424
|
+
# noinspection PyShadowingBuiltins
|
|
10365
10425
|
class TransactionPartnerUser(TransactionPartner):
|
|
10366
10426
|
"""
|
|
10367
10427
|
Describes a transaction with a user.
|
|
@@ -10377,22 +10437,30 @@ class TransactionPartnerUser(TransactionPartner):
|
|
|
10377
10437
|
:param invoice_payload: Optional, Bot-specified invoice payload
|
|
10378
10438
|
:type invoice_payload: :obj:`str`
|
|
10379
10439
|
|
|
10440
|
+
:param paid_media: Optional. Information about the paid media bought by the user
|
|
10441
|
+
:type paid_media: :obj:`list` of :class:`PaidMedia`
|
|
10442
|
+
|
|
10380
10443
|
:return: Instance of the class
|
|
10381
10444
|
:rtype: :class:`TransactionPartnerUser`
|
|
10382
10445
|
"""
|
|
10383
10446
|
|
|
10384
|
-
def __init__(self, type, user, invoice_payload=None, **kwargs):
|
|
10447
|
+
def __init__(self, type, user, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None, **kwargs):
|
|
10385
10448
|
self.type: str = type
|
|
10386
10449
|
self.user: User = user
|
|
10387
10450
|
self.invoice_payload: Optional[str] = invoice_payload
|
|
10451
|
+
self.paid_media: Optional[List[PaidMedia]] = paid_media
|
|
10388
10452
|
|
|
10389
10453
|
@classmethod
|
|
10390
10454
|
def de_json(cls, json_string):
|
|
10391
10455
|
if json_string is None: return None
|
|
10392
10456
|
obj = cls.check_json(json_string)
|
|
10393
10457
|
obj['user'] = User.de_json(obj['user'])
|
|
10458
|
+
if 'paid_media' in obj:
|
|
10459
|
+
obj['paid_media'] = [PaidMedia.de_json(media) for media in obj['paid_media']]
|
|
10394
10460
|
return cls(**obj)
|
|
10395
|
-
|
|
10461
|
+
|
|
10462
|
+
|
|
10463
|
+
# noinspection PyShadowingBuiltins
|
|
10396
10464
|
class TransactionPartnerTelegramAds(TransactionPartner):
|
|
10397
10465
|
"""
|
|
10398
10466
|
Describes a transaction with Telegram Ads.
|
|
@@ -10413,8 +10481,10 @@ class TransactionPartnerTelegramAds(TransactionPartner):
|
|
|
10413
10481
|
def de_json(cls, json_string):
|
|
10414
10482
|
if json_string is None: return None
|
|
10415
10483
|
obj = cls.check_json(json_string)
|
|
10416
|
-
|
|
10417
|
-
|
|
10484
|
+
return obj
|
|
10485
|
+
|
|
10486
|
+
|
|
10487
|
+
# noinspection PyShadowingBuiltins
|
|
10418
10488
|
class TransactionPartnerOther(TransactionPartner):
|
|
10419
10489
|
"""
|
|
10420
10490
|
Describes a transaction with an unknown source or recipient.
|
|
@@ -10436,9 +10506,9 @@ class TransactionPartnerOther(TransactionPartner):
|
|
|
10436
10506
|
if json_string is None: return None
|
|
10437
10507
|
obj = cls.check_json(json_string)
|
|
10438
10508
|
return cls(**obj)
|
|
10439
|
-
|
|
10440
10509
|
|
|
10441
10510
|
|
|
10511
|
+
# noinspection PyShadowingBuiltins
|
|
10442
10512
|
class StarTransaction(JsonDeserializable):
|
|
10443
10513
|
"""
|
|
10444
10514
|
Describes a Telegram Star transaction.
|
|
@@ -10531,7 +10601,9 @@ class PaidMedia(JsonDeserializable):
|
|
|
10531
10601
|
return PaidMediaPhoto.de_json(obj)
|
|
10532
10602
|
elif obj["type"] == "video":
|
|
10533
10603
|
return PaidMediaVideo.de_json(obj)
|
|
10534
|
-
|
|
10604
|
+
|
|
10605
|
+
|
|
10606
|
+
# noinspection PyShadowingBuiltins
|
|
10535
10607
|
class PaidMediaPreview(PaidMedia):
|
|
10536
10608
|
"""
|
|
10537
10609
|
The paid media isn't available before the payment.
|
|
@@ -10565,8 +10637,9 @@ class PaidMediaPreview(PaidMedia):
|
|
|
10565
10637
|
if json_string is None: return None
|
|
10566
10638
|
obj = cls.check_json(json_string)
|
|
10567
10639
|
return cls(**obj)
|
|
10568
|
-
|
|
10569
10640
|
|
|
10641
|
+
|
|
10642
|
+
# noinspection PyShadowingBuiltins
|
|
10570
10643
|
class PaidMediaPhoto(PaidMedia):
|
|
10571
10644
|
"""
|
|
10572
10645
|
The paid media is a photo.
|
|
@@ -10595,8 +10668,9 @@ class PaidMediaPhoto(PaidMedia):
|
|
|
10595
10668
|
|
|
10596
10669
|
obj['photo'] = [PhotoSize.de_json(photo) for photo in obj['photo']]
|
|
10597
10670
|
return cls(**obj)
|
|
10598
|
-
|
|
10599
10671
|
|
|
10672
|
+
|
|
10673
|
+
# noinspection PyShadowingBuiltins
|
|
10600
10674
|
class PaidMediaVideo(PaidMedia):
|
|
10601
10675
|
"""
|
|
10602
10676
|
The paid media is a video.
|
|
@@ -10653,6 +10727,7 @@ class PaidMediaInfo(JsonDeserializable):
|
|
|
10653
10727
|
self.paid_media: List[PaidMedia] = paid_media
|
|
10654
10728
|
|
|
10655
10729
|
|
|
10730
|
+
# noinspection PyShadowingBuiltins
|
|
10656
10731
|
class InputPaidMedia(JsonSerializable):
|
|
10657
10732
|
"""
|
|
10658
10733
|
This object describes the paid media to be sent. Currently, it can be one of
|
|
@@ -10807,4 +10882,31 @@ class RefundedPayment(JsonDeserializable):
|
|
|
10807
10882
|
obj = cls.check_json(json_string)
|
|
10808
10883
|
return cls(**obj)
|
|
10809
10884
|
|
|
10810
|
-
|
|
10885
|
+
|
|
10886
|
+
class PaidMediaPurchased(JsonDeserializable):
|
|
10887
|
+
"""
|
|
10888
|
+
This object contains information about a paid media purchase.
|
|
10889
|
+
|
|
10890
|
+
Telegram documentation: https://core.telegram.org/bots/api#paidmediapurchased
|
|
10891
|
+
|
|
10892
|
+
:param from_user: User who purchased the media
|
|
10893
|
+
:type from_user: :class:`User`
|
|
10894
|
+
|
|
10895
|
+
:param paid_media_payload: Bot-specified paid media payload
|
|
10896
|
+
:type paid_media_payload: :obj:`str`
|
|
10897
|
+
|
|
10898
|
+
:return: Instance of the class
|
|
10899
|
+
:rtype: :class:`PaidMediaPurchased`
|
|
10900
|
+
"""
|
|
10901
|
+
|
|
10902
|
+
def __init__(self, from_user, paid_media_payload, **kwargs):
|
|
10903
|
+
self.from_user: User = from_user
|
|
10904
|
+
self.paid_media_payload: str = paid_media_payload
|
|
10905
|
+
|
|
10906
|
+
@classmethod
|
|
10907
|
+
def de_json(cls, json_string):
|
|
10908
|
+
if json_string is None: return None
|
|
10909
|
+
obj = cls.check_json(json_string)
|
|
10910
|
+
obj['from_user'] = User.de_json(obj['from_user'])
|
|
10911
|
+
return cls(**obj)
|
|
10912
|
+
|
telebot/util.py
CHANGED
|
@@ -48,7 +48,7 @@ update_types = [
|
|
|
48
48
|
"message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result",
|
|
49
49
|
"callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member",
|
|
50
50
|
"chat_join_request", "message_reaction", "message_reaction_count", "chat_boost", "removed_chat_boost",
|
|
51
|
-
"business_connection", "business_message", "edited_business_message", "deleted_business_messages"
|
|
51
|
+
"business_connection", "business_message", "edited_business_message", "deleted_business_messages", "purchased_paid_media"
|
|
52
52
|
]
|
|
53
53
|
|
|
54
54
|
|
telebot/version.py
CHANGED
|
File without changes
|
|
File without changes
|