pyTelegramBotAPI 4.24.0__py3-none-any.whl → 4.25.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.24.0.dist-info → pytelegrambotapi-4.25.0.dist-info}/METADATA +3 -3
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.25.0.dist-info}/RECORD +11 -11
- telebot/__init__.py +127 -2
- telebot/apihelper.py +51 -1
- telebot/async_telebot.py +120 -2
- telebot/asyncio_helper.py +50 -1
- telebot/formatting.py +1 -1
- telebot/types.py +208 -3
- telebot/version.py +1 -1
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.25.0.dist-info}/WHEEL +0 -0
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.25.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.25.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
|
|
@@ -52,7 +52,7 @@ Description-Content-Type: text/markdown
|
|
|
52
52
|
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
|
|
53
53
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
54
54
|
|
|
55
|
-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#
|
|
55
|
+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#november-17-2024"><img src="https://img.shields.io/badge/Bot%20API-8.1-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
56
56
|
|
|
57
57
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
58
58
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -872,7 +872,7 @@ Here are some examples of template:
|
|
|
872
872
|
* [RadRetroRobot](https://github.com/Tronikart/RadRetroRobot) by *Tronikart* - Multifunctional Telegram Bot RadRetroRobot.
|
|
873
873
|
* [League of Legends bot](https://telegram.me/League_of_Legends_bot) ([source](https://github.com/i32ropie/lol)) by *i32ropie*
|
|
874
874
|
* [NeoBot](https://github.com/neoranger/NeoBot) by [@NeoRanger](https://github.com/neoranger)
|
|
875
|
-
* [ColorCodeBot](https://t.me/colorcodebot) ([source](https://github.com/andydecleyre/colorcodebot)) - Share code snippets as beautifully syntax-highlighted
|
|
875
|
+
* [ColorCodeBot](https://t.me/colorcodebot) ([source](https://github.com/andydecleyre/colorcodebot)) - Share code snippets as beautifully syntax-highlighted images.
|
|
876
876
|
* [ComedoresUGRbot](http://telegram.me/ComedoresUGRbot) ([source](https://github.com/alejandrocq/ComedoresUGRbot)) by [*alejandrocq*](https://github.com/alejandrocq) - Telegram bot to check the menu of Universidad de Granada dining hall.
|
|
877
877
|
* [proxybot](https://github.com/p-hash/proxybot) - Simple Proxy Bot for Telegram. by p-hash
|
|
878
878
|
* [DonantesMalagaBot](https://github.com/vfranch/DonantesMalagaBot) - DonantesMalagaBot facilitates information to Malaga blood donors about the places where they can donate today or in the incoming days. It also records the date of the last donation so that it helps the donors to know when they can donate again. - by vfranch
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
telebot/__init__.py,sha256=
|
|
2
|
-
telebot/apihelper.py,sha256=
|
|
3
|
-
telebot/async_telebot.py,sha256=
|
|
1
|
+
telebot/__init__.py,sha256=a57ZJyp8GP-r-MiC5ecygZphIbWgNS8pMCOLd5TuSSM,432408
|
|
2
|
+
telebot/apihelper.py,sha256=alfT2M1viZVOmDFMHb_Mdh5JeP4EE2mzZOnlvhGpBoM,100182
|
|
3
|
+
telebot/async_telebot.py,sha256=qSENsVubvmCIXBn8-YARFLeha8IlDaNhgSDF9fVybc8,405457
|
|
4
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=SzBRMAhMr0A6gL3qnyoNJUNvOkXn28sVrytjhuRWZqM,101072
|
|
7
7
|
telebot/callback_data.py,sha256=k4Rz3lAONG5J2M9TESKMIjqXoBNJMfEy9nnrmJAyi3Q,5358
|
|
8
8
|
telebot/custom_filters.py,sha256=ncF8_zwlSqkuATI46Xc6HQ5Y1ZoQ1fO6AlcRbs7bO3U,12975
|
|
9
|
-
telebot/formatting.py,sha256=
|
|
9
|
+
telebot/formatting.py,sha256=UFZTRSX-DMcALmaQ7xztHObop8DWeCtHdKsOoGLgDY0,15172
|
|
10
10
|
telebot/handler_backends.py,sha256=lyKu0PaH2c4y5FfyQS3M9tOyBJ8ATjxHZkATzu01XpE,7969
|
|
11
11
|
telebot/service_utils.py,sha256=xLmlZLTVs34UOdQtMvwduor8hnLxQCx8iJ92wDGl2Mw,2053
|
|
12
|
-
telebot/types.py,sha256=
|
|
12
|
+
telebot/types.py,sha256=lA3JYmLYBHcjzustmFaflPSwKXj5BOLzcWdSCSt2Mbo,474882
|
|
13
13
|
telebot/util.py,sha256=ylRtI4DI4I1BJAF2Ack7WyGbTN1cRkubUCbhLNiiPj4,21385
|
|
14
|
-
telebot/version.py,sha256=
|
|
14
|
+
telebot/version.py,sha256=CFmNAe1WwcbIebAfVhERMAnvhFbYytIkUtMZMvGQQ7c,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=wjFuRxSBeCMB3h-fUqLgqe2XcZoc6-ixkN5qsm3th9I,7136
|
|
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.25.0.dist-info/METADATA,sha256=5ihfiBhE_mcs7oLTcB7-rddg33a6qyurCqj642X3Ugo,48123
|
|
39
|
+
pytelegrambotapi-4.25.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
40
|
+
pytelegrambotapi-4.25.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
|
|
41
|
+
pytelegrambotapi-4.25.0.dist-info/RECORD,,
|
telebot/__init__.py
CHANGED
|
@@ -1512,6 +1512,26 @@ class TeleBot:
|
|
|
1512
1512
|
apihelper.get_user_profile_photos(self.token, user_id, offset=offset, limit=limit)
|
|
1513
1513
|
)
|
|
1514
1514
|
|
|
1515
|
+
def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool:
|
|
1516
|
+
"""
|
|
1517
|
+
Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
|
|
1518
|
+
|
|
1519
|
+
Telegram documentation: https://core.telegram.org/bots/api#setuseremojistatus
|
|
1520
|
+
|
|
1521
|
+
:param user_id: Unique identifier of the target user
|
|
1522
|
+
:type user_id: :obj:`int`
|
|
1523
|
+
|
|
1524
|
+
:param emoji_status_custom_emoji_id: Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
|
|
1525
|
+
:type emoji_status_custom_emoji_id: :obj:`str`
|
|
1526
|
+
|
|
1527
|
+
:param emoji_status_expiration_date: Expiration date of the emoji status, if any
|
|
1528
|
+
:type emoji_status_expiration_date: :obj:`int`
|
|
1529
|
+
|
|
1530
|
+
:return: :obj:`bool`
|
|
1531
|
+
"""
|
|
1532
|
+
return apihelper.set_user_emoji_status(
|
|
1533
|
+
self.token, user_id, emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, emoji_status_expiration_date=emoji_status_expiration_date)
|
|
1534
|
+
|
|
1515
1535
|
|
|
1516
1536
|
def get_chat(self, chat_id: Union[int, str]) -> types.ChatFullInfo:
|
|
1517
1537
|
"""
|
|
@@ -5418,7 +5438,9 @@ class TeleBot:
|
|
|
5418
5438
|
need_shipping_address: Optional[bool]=None,
|
|
5419
5439
|
send_phone_number_to_provider: Optional[bool]=None,
|
|
5420
5440
|
send_email_to_provider: Optional[bool]=None,
|
|
5421
|
-
is_flexible: Optional[bool]=None
|
|
5441
|
+
is_flexible: Optional[bool]=None,
|
|
5442
|
+
subscription_period: Optional[int]=None,
|
|
5443
|
+
business_connection_id: Optional[str]=None) -> str:
|
|
5422
5444
|
|
|
5423
5445
|
"""
|
|
5424
5446
|
Use this method to create a link for an invoice.
|
|
@@ -5427,6 +5449,9 @@ class TeleBot:
|
|
|
5427
5449
|
Telegram documentation:
|
|
5428
5450
|
https://core.telegram.org/bots/api#createinvoicelink
|
|
5429
5451
|
|
|
5452
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created
|
|
5453
|
+
:type business_connection_id: :obj:`str`
|
|
5454
|
+
|
|
5430
5455
|
:param title: Product name, 1-32 characters
|
|
5431
5456
|
:type title: :obj:`str`
|
|
5432
5457
|
|
|
@@ -5449,6 +5474,11 @@ class TeleBot:
|
|
|
5449
5474
|
(e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
|
5450
5475
|
:type prices: :obj:`list` of :obj:`types.LabeledPrice`
|
|
5451
5476
|
|
|
5477
|
+
:subscription_period: The number of seconds the subscription will be active for before the next payment.
|
|
5478
|
+
The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always
|
|
5479
|
+
be 2592000 (30 days) if specified.
|
|
5480
|
+
:type subscription_period: :obj:`int`
|
|
5481
|
+
|
|
5452
5482
|
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
|
5453
5483
|
:type max_tip_amount: :obj:`int`
|
|
5454
5484
|
|
|
@@ -5505,7 +5535,8 @@ class TeleBot:
|
|
|
5505
5535
|
photo_width=photo_width, photo_height=photo_height, need_name=need_name,
|
|
5506
5536
|
need_phone_number=need_phone_number, need_email=need_email,
|
|
5507
5537
|
need_shipping_address=need_shipping_address, send_phone_number_to_provider=send_phone_number_to_provider,
|
|
5508
|
-
send_email_to_provider=send_email_to_provider, is_flexible=is_flexible
|
|
5538
|
+
send_email_to_provider=send_email_to_provider, is_flexible=is_flexible ,subscription_period=subscription_period,
|
|
5539
|
+
business_connection_id=business_connection_id)
|
|
5509
5540
|
|
|
5510
5541
|
|
|
5511
5542
|
# noinspection PyShadowingBuiltins
|
|
@@ -5803,6 +5834,26 @@ class TeleBot:
|
|
|
5803
5834
|
"""
|
|
5804
5835
|
return apihelper.refund_star_payment(self.token, user_id, telegram_payment_charge_id)
|
|
5805
5836
|
|
|
5837
|
+
def edit_user_star_subscription(self, user_id: int, telegram_payment_charge_id: str, is_canceled: bool) -> bool:
|
|
5838
|
+
"""
|
|
5839
|
+
Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
|
|
5840
|
+
|
|
5841
|
+
Telegram documentation: https://core.telegram.org/bots/api#edituserstarsubscription
|
|
5842
|
+
|
|
5843
|
+
:param user_id: Identifier of the user whose subscription will be edited
|
|
5844
|
+
:type user_id: :obj:`int`
|
|
5845
|
+
|
|
5846
|
+
:param telegram_payment_charge_id: Telegram payment identifier for the subscription
|
|
5847
|
+
:type telegram_payment_charge_id: :obj:`str`
|
|
5848
|
+
|
|
5849
|
+
:param is_canceled: Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.
|
|
5850
|
+
:type is_canceled: :obj:`bool`
|
|
5851
|
+
|
|
5852
|
+
:return: On success, True is returned.
|
|
5853
|
+
:rtype: :obj:`bool`
|
|
5854
|
+
"""
|
|
5855
|
+
return apihelper.edit_user_star_subscription(self.token, user_id, telegram_payment_charge_id, is_canceled)
|
|
5856
|
+
|
|
5806
5857
|
def edit_message_caption(
|
|
5807
5858
|
self, caption: str, chat_id: Optional[Union[int, str]]=None,
|
|
5808
5859
|
message_id: Optional[int]=None,
|
|
@@ -6199,6 +6250,44 @@ class TeleBot:
|
|
|
6199
6250
|
"""
|
|
6200
6251
|
return apihelper.delete_sticker_set(self.token, name)
|
|
6201
6252
|
|
|
6253
|
+
def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, text_parse_mode: Optional[str]=None, text_entities: Optional[List[types.MessageEntity]]=None) -> bool:
|
|
6254
|
+
"""
|
|
6255
|
+
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.
|
|
6256
|
+
|
|
6257
|
+
Telegram documentation: https://core.telegram.org/bots/api#sendgift
|
|
6258
|
+
|
|
6259
|
+
:param user_id: Unique identifier of the target user that will receive the gift
|
|
6260
|
+
:type user_id: :obj:`int`
|
|
6261
|
+
|
|
6262
|
+
:param gift_id: Identifier of the gift
|
|
6263
|
+
:type gift_id: :obj:`str`
|
|
6264
|
+
|
|
6265
|
+
:param text: Text that will be shown along with the gift; 0-255 characters
|
|
6266
|
+
:type text: :obj:`str`
|
|
6267
|
+
|
|
6268
|
+
:param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
|
|
6269
|
+
:type text_parse_mode: :obj:`str`
|
|
6270
|
+
|
|
6271
|
+
:param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
|
|
6272
|
+
:type text_entities: :obj:`list` of :obj:`types.MessageEntity`
|
|
6273
|
+
|
|
6274
|
+
:return: Returns True on success.
|
|
6275
|
+
:rtype: :obj:`bool`
|
|
6276
|
+
"""
|
|
6277
|
+
return apihelper.send_gift(self.token, user_id, gift_id, text=text, text_parse_mode=text_parse_mode, text_entities=text_entities)
|
|
6278
|
+
|
|
6279
|
+
def get_available_gifts(self) -> types.Gifts:
|
|
6280
|
+
"""
|
|
6281
|
+
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
|
|
6282
|
+
|
|
6283
|
+
Telegram documentation: https://core.telegram.org/bots/api#getavailablegifts
|
|
6284
|
+
|
|
6285
|
+
:return: On success, a Gifts object is returned.
|
|
6286
|
+
:rtype: :class:`telebot.types.Gifts`
|
|
6287
|
+
"""
|
|
6288
|
+
return types.Gifts.de_json(
|
|
6289
|
+
apihelper.get_available_gifts(self.token)
|
|
6290
|
+
)
|
|
6202
6291
|
|
|
6203
6292
|
def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, sticker: types.InputSticker) -> bool:
|
|
6204
6293
|
"""
|
|
@@ -6718,6 +6807,42 @@ class TeleBot:
|
|
|
6718
6807
|
"""
|
|
6719
6808
|
return apihelper.answer_web_app_query(self.token, web_app_query_id, result)
|
|
6720
6809
|
|
|
6810
|
+
def save_prepared_inline_message(
|
|
6811
|
+
self, user_id: int, result: types.InlineQueryResultBase, allow_user_chats: Optional[bool]=None,
|
|
6812
|
+
allow_bot_chats: Optional[bool]=None, allow_group_chats: Optional[bool]=None,
|
|
6813
|
+
allow_channel_chats: Optional[bool]=None) -> types.PreparedInlineMessage:
|
|
6814
|
+
"""
|
|
6815
|
+
Use this method to store a message that can be sent by a user of a Mini App.
|
|
6816
|
+
Returns a PreparedInlineMessage object.
|
|
6817
|
+
|
|
6818
|
+
Telegram Documentation: https://core.telegram.org/bots/api#savepreparedinlinemessage
|
|
6819
|
+
|
|
6820
|
+
:param user_id: Unique identifier of the target user that can use the prepared message
|
|
6821
|
+
:type user_id: :obj:`int`
|
|
6822
|
+
|
|
6823
|
+
:param result: A JSON-serialized object describing the message to be sent
|
|
6824
|
+
:type result: :class:`telebot.types.InlineQueryResultBase`
|
|
6825
|
+
|
|
6826
|
+
:param allow_user_chats: Pass True if the message can be sent to private chats with users
|
|
6827
|
+
:type allow_user_chats: :obj:`bool`
|
|
6828
|
+
|
|
6829
|
+
:param allow_bot_chats: Pass True if the message can be sent to private chats with bots
|
|
6830
|
+
:type allow_bot_chats: :obj:`bool`
|
|
6831
|
+
|
|
6832
|
+
:param allow_group_chats: Pass True if the message can be sent to group and supergroup chats
|
|
6833
|
+
:type allow_group_chats: :obj:`bool`
|
|
6834
|
+
|
|
6835
|
+
:param allow_channel_chats: Pass True if the message can be sent to channel chats
|
|
6836
|
+
:type allow_channel_chats: :obj:`bool`
|
|
6837
|
+
|
|
6838
|
+
:return: On success, a PreparedInlineMessage object is returned.
|
|
6839
|
+
:rtype: :class:`telebot.types.PreparedInlineMessage`
|
|
6840
|
+
"""
|
|
6841
|
+
return types.PreparedInlineMessage.de_json(
|
|
6842
|
+
apihelper.save_prepared_inline_message(
|
|
6843
|
+
self.token, user_id, result, allow_user_chats=allow_user_chats, allow_bot_chats=allow_bot_chats,
|
|
6844
|
+
allow_group_chats=allow_group_chats, allow_channel_chats=allow_channel_chats)
|
|
6845
|
+
)
|
|
6721
6846
|
|
|
6722
6847
|
def register_for_reply(self, message: types.Message, callback: Callable, *args, **kwargs) -> None:
|
|
6723
6848
|
"""
|
telebot/apihelper.py
CHANGED
|
@@ -341,6 +341,16 @@ def get_user_profile_photos(token, user_id, offset=None, limit=None):
|
|
|
341
341
|
payload['limit'] = limit
|
|
342
342
|
return _make_request(token, method_url, params=payload)
|
|
343
343
|
|
|
344
|
+
|
|
345
|
+
def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
|
|
346
|
+
method_url = r'setUserEmojiStatus'
|
|
347
|
+
payload = {'user_id': user_id}
|
|
348
|
+
if emoji_status_custom_emoji_id:
|
|
349
|
+
payload['emoji_status_custom_emoji_id'] = emoji_status_custom_emoji_id
|
|
350
|
+
if emoji_status_expiration_date:
|
|
351
|
+
payload['emoji_status_expiration_date'] = emoji_status_expiration_date
|
|
352
|
+
return _make_request(token, method_url, params=payload)
|
|
353
|
+
|
|
344
354
|
def set_message_reaction(token, chat_id, message_id, reaction=None, is_big=None):
|
|
345
355
|
method_url = r'setMessageReaction'
|
|
346
356
|
payload = {'chat_id': chat_id, 'message_id': message_id}
|
|
@@ -1805,6 +1815,11 @@ def refund_star_payment(token, user_id, telegram_payment_charge_id):
|
|
|
1805
1815
|
payload = {'user_id': user_id, 'telegram_payment_charge_id': telegram_payment_charge_id}
|
|
1806
1816
|
return _make_request(token, method_url, params=payload)
|
|
1807
1817
|
|
|
1818
|
+
def edit_user_star_subscription(token, user_id, telegram_payment_charge_id, is_canceled):
|
|
1819
|
+
method_url = 'editUserStarSubscription'
|
|
1820
|
+
payload = {'user_id': user_id, 'telegram_payment_charge_id': telegram_payment_charge_id, 'is_canceled': is_canceled}
|
|
1821
|
+
return _make_request(token, method_url, params=payload)
|
|
1822
|
+
|
|
1808
1823
|
|
|
1809
1824
|
def unpin_all_general_forum_topic_messages(token, chat_id):
|
|
1810
1825
|
method_url = 'unpinAllGeneralForumTopicMessages'
|
|
@@ -1909,6 +1924,22 @@ def delete_sticker_set(token, name):
|
|
|
1909
1924
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1910
1925
|
|
|
1911
1926
|
|
|
1927
|
+
def get_available_gifts(token):
|
|
1928
|
+
method_url = 'getAvailableGifts'
|
|
1929
|
+
return _make_request(token, method_url)
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
def send_gift(token, user_id, gift_id, text=None, text_parse_mode=None, text_entities=None):
|
|
1933
|
+
method_url = 'sendGift'
|
|
1934
|
+
payload = {'user_id': user_id, 'gift_id': gift_id}
|
|
1935
|
+
if text:
|
|
1936
|
+
payload['text'] = text
|
|
1937
|
+
if text_parse_mode:
|
|
1938
|
+
payload['text_parse_mode'] = text_parse_mode
|
|
1939
|
+
if text_entities:
|
|
1940
|
+
payload['text_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(text_entities))
|
|
1941
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1942
|
+
|
|
1912
1943
|
def set_sticker_emoji_list(token, sticker, emoji_list):
|
|
1913
1944
|
method_url = 'setStickerEmojiList'
|
|
1914
1945
|
payload = {'sticker': sticker, 'emoji_list': json.dumps(emoji_list)}
|
|
@@ -1966,11 +1997,26 @@ def answer_web_app_query(token, web_app_query_id, result: types.InlineQueryResul
|
|
|
1966
1997
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1967
1998
|
|
|
1968
1999
|
|
|
2000
|
+
def save_prepared_inline_message(token, user_id, result: types.InlineQueryResultBase, allow_user_chats=None,
|
|
2001
|
+
allow_bot_chats=None, allow_group_chats=None, allow_channel_chats=None):
|
|
2002
|
+
method_url = 'savePreparedInlineMessage'
|
|
2003
|
+
payload = {'user_id': user_id, 'result': result.to_json()}
|
|
2004
|
+
if allow_user_chats is not None:
|
|
2005
|
+
payload['allow_user_chats'] = allow_user_chats
|
|
2006
|
+
if allow_bot_chats is not None:
|
|
2007
|
+
payload['allow_bot_chats'] = allow_bot_chats
|
|
2008
|
+
if allow_group_chats is not None:
|
|
2009
|
+
payload['allow_group_chats'] = allow_group_chats
|
|
2010
|
+
if allow_channel_chats is not None:
|
|
2011
|
+
payload['allow_channel_chats'] = allow_channel_chats
|
|
2012
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
2013
|
+
|
|
2014
|
+
|
|
1969
2015
|
def create_invoice_link(token, title, description, payload, provider_token,
|
|
1970
2016
|
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
|
|
1971
2017
|
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
|
|
1972
2018
|
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
|
|
1973
|
-
send_email_to_provider=None, is_flexible=None):
|
|
2019
|
+
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
|
|
1974
2020
|
method_url = r'createInvoiceLink'
|
|
1975
2021
|
payload = {'title': title, 'description': description, 'payload': payload,
|
|
1976
2022
|
'currency': currency, 'prices': _convert_list_json_serializable(prices)}
|
|
@@ -2004,6 +2050,10 @@ def create_invoice_link(token, title, description, payload, provider_token,
|
|
|
2004
2050
|
payload['is_flexible'] = is_flexible
|
|
2005
2051
|
if provider_token is not None:
|
|
2006
2052
|
payload['provider_token'] = provider_token
|
|
2053
|
+
if subscription_period:
|
|
2054
|
+
payload['subscription_period'] = subscription_period
|
|
2055
|
+
if business_connection_id:
|
|
2056
|
+
payload['business_connection_id'] = business_connection_id
|
|
2007
2057
|
return _make_request(token, method_url, params=payload, method='post')
|
|
2008
2058
|
|
|
2009
2059
|
|
telebot/async_telebot.py
CHANGED
|
@@ -2987,6 +2987,26 @@ class AsyncTeleBot:
|
|
|
2987
2987
|
"""
|
|
2988
2988
|
result = await asyncio_helper.get_user_profile_photos(self.token, user_id, offset, limit)
|
|
2989
2989
|
return types.UserProfilePhotos.de_json(result)
|
|
2990
|
+
|
|
2991
|
+
async def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool:
|
|
2992
|
+
"""
|
|
2993
|
+
Use this method to change the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess.
|
|
2994
|
+
|
|
2995
|
+
Telegram documentation: https://core.telegram.org/bots/api#setuseremojistatus
|
|
2996
|
+
|
|
2997
|
+
:param user_id: Unique identifier of the target user
|
|
2998
|
+
:type user_id: :obj:`int`
|
|
2999
|
+
|
|
3000
|
+
:param emoji_status_custom_emoji_id: Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
|
|
3001
|
+
:type emoji_status_custom_emoji_id: :obj:`str`, optional
|
|
3002
|
+
|
|
3003
|
+
:param emoji_status_expiration_date: Expiration date of the emoji status, if any
|
|
3004
|
+
:type emoji_status_expiration_date: :obj:`int`, optional
|
|
3005
|
+
|
|
3006
|
+
:return: :obj:`bool`
|
|
3007
|
+
"""
|
|
3008
|
+
result = await asyncio_helper.set_user_emoji_status(self.token, user_id, emoji_status_custom_emoji_id, emoji_status_expiration_date)
|
|
3009
|
+
return result
|
|
2990
3010
|
|
|
2991
3011
|
async def get_chat(self, chat_id: Union[int, str]) -> types.ChatFullInfo:
|
|
2992
3012
|
"""
|
|
@@ -3128,6 +3148,36 @@ class AsyncTeleBot:
|
|
|
3128
3148
|
|
|
3129
3149
|
return await asyncio_helper.answer_web_app_query(self.token, web_app_query_id, result)
|
|
3130
3150
|
|
|
3151
|
+
async def save_prepared_inline_message(self, user_id: int, result: types.InlineQueryResultBase, allow_user_chats: Optional[bool]=None,
|
|
3152
|
+
allow_bot_chats: Optional[bool]=None, allow_group_chats: Optional[bool]=None, allow_channel_chats: Optional[bool]=None) -> types.PreparedInlineMessage:
|
|
3153
|
+
"""
|
|
3154
|
+
Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
|
|
3155
|
+
|
|
3156
|
+
Telegram Documentation: https://core.telegram.org/bots/api#savepreparedinlinemessage
|
|
3157
|
+
|
|
3158
|
+
:param user_id: Unique identifier of the target user that can use the prepared message
|
|
3159
|
+
:type user_id: :obj:`int`
|
|
3160
|
+
|
|
3161
|
+
:param result: A JSON-serialized object describing the message to be sent
|
|
3162
|
+
:type result: :class:`telebot.types.InlineQueryResultBase`
|
|
3163
|
+
|
|
3164
|
+
:param allow_user_chats: Pass True if the message can be sent to private chats with users
|
|
3165
|
+
:type allow_user_chats: :obj:`bool`, optional
|
|
3166
|
+
|
|
3167
|
+
:param allow_bot_chats: Pass True if the message can be sent to private chats with bots
|
|
3168
|
+
:type allow_bot_chats: :obj:`bool`, optional
|
|
3169
|
+
|
|
3170
|
+
:param allow_group_chats: Pass True if the message can be sent to group and supergroup chats
|
|
3171
|
+
:type allow_group_chats: :obj:`bool`, optional
|
|
3172
|
+
|
|
3173
|
+
:param allow_channel_chats: Pass True if the message can be sent to channel chats
|
|
3174
|
+
:type allow_channel_chats: :obj:`bool`, optional
|
|
3175
|
+
|
|
3176
|
+
:return: :class:`telebot.types.PreparedInlineMessage`
|
|
3177
|
+
"""
|
|
3178
|
+
result = await asyncio_helper.save_prepared_inline_message(self.token, user_id, result, allow_user_chats, allow_bot_chats, allow_group_chats, allow_channel_chats)
|
|
3179
|
+
return types.PreparedInlineMessage.de_json(result)
|
|
3180
|
+
|
|
3131
3181
|
async def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types.ChatMember:
|
|
3132
3182
|
"""
|
|
3133
3183
|
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
@@ -6836,7 +6886,9 @@ class AsyncTeleBot:
|
|
|
6836
6886
|
need_shipping_address: Optional[bool]=None,
|
|
6837
6887
|
send_phone_number_to_provider: Optional[bool]=None,
|
|
6838
6888
|
send_email_to_provider: Optional[bool]=None,
|
|
6839
|
-
is_flexible: Optional[bool]=None
|
|
6889
|
+
is_flexible: Optional[bool]=None,
|
|
6890
|
+
subscription_period: Optional[int]=None,
|
|
6891
|
+
business_connection_id: Optional[str]=None) -> str:
|
|
6840
6892
|
|
|
6841
6893
|
"""
|
|
6842
6894
|
Use this method to create a link for an invoice.
|
|
@@ -6844,6 +6896,9 @@ class AsyncTeleBot:
|
|
|
6844
6896
|
|
|
6845
6897
|
Telegram documentation:
|
|
6846
6898
|
https://core.telegram.org/bots/api#createinvoicelink
|
|
6899
|
+
|
|
6900
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created
|
|
6901
|
+
:type business_connection_id: :obj:`str`
|
|
6847
6902
|
|
|
6848
6903
|
:param title: Product name, 1-32 characters
|
|
6849
6904
|
:type title: :obj:`str`
|
|
@@ -6867,6 +6922,11 @@ class AsyncTeleBot:
|
|
|
6867
6922
|
(e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
|
6868
6923
|
:type prices: :obj:`list` of :obj:`types.LabeledPrice`
|
|
6869
6924
|
|
|
6925
|
+
:subscription_period: The number of seconds the subscription will be active for before the next payment.
|
|
6926
|
+
The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always
|
|
6927
|
+
be 2592000 (30 days) if specified.
|
|
6928
|
+
:type subscription_period: :obj:`int`
|
|
6929
|
+
|
|
6870
6930
|
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
|
6871
6931
|
:type max_tip_amount: :obj:`int`
|
|
6872
6932
|
|
|
@@ -6921,7 +6981,7 @@ class AsyncTeleBot:
|
|
|
6921
6981
|
currency, prices, max_tip_amount, suggested_tip_amounts, provider_data,
|
|
6922
6982
|
photo_url, photo_size, photo_width, photo_height, need_name, need_phone_number,
|
|
6923
6983
|
need_email, need_shipping_address, send_phone_number_to_provider,
|
|
6924
|
-
send_email_to_provider, is_flexible)
|
|
6984
|
+
send_email_to_provider, is_flexible, subscription_period=subscription_period, business_connection_id=business_connection_id)
|
|
6925
6985
|
return result
|
|
6926
6986
|
|
|
6927
6987
|
# noinspection PyShadowingBuiltins
|
|
@@ -7210,6 +7270,26 @@ class AsyncTeleBot:
|
|
|
7210
7270
|
"""
|
|
7211
7271
|
return await asyncio_helper.refund_star_payment(self.token, user_id, telegram_payment_charge_id)
|
|
7212
7272
|
|
|
7273
|
+
async def edit_user_star_subscription(self, user_id: int, telegram_payment_charge_id: str, is_canceled: bool) -> bool:
|
|
7274
|
+
"""
|
|
7275
|
+
Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
|
|
7276
|
+
|
|
7277
|
+
Telegram documentation: https://core.telegram.org/bots/api#edituserstarsubscription
|
|
7278
|
+
|
|
7279
|
+
:param user_id: Identifier of the user whose subscription will be edited
|
|
7280
|
+
:type user_id: :obj:`int`
|
|
7281
|
+
|
|
7282
|
+
:param telegram_payment_charge_id: Telegram payment identifier for the subscription
|
|
7283
|
+
:type telegram_payment_charge_id: :obj:`str`
|
|
7284
|
+
|
|
7285
|
+
:param is_canceled: Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.
|
|
7286
|
+
:type is_canceled: :obj:`bool`
|
|
7287
|
+
|
|
7288
|
+
:return: On success, True is returned.
|
|
7289
|
+
:rtype: :obj:`bool`
|
|
7290
|
+
"""
|
|
7291
|
+
return await asyncio_helper.edit_user_star_subscription(self.token, user_id, telegram_payment_charge_id, is_canceled)
|
|
7292
|
+
|
|
7213
7293
|
async def edit_message_caption(
|
|
7214
7294
|
self, caption: str, chat_id: Optional[Union[int, str]]=None,
|
|
7215
7295
|
message_id: Optional[int]=None,
|
|
@@ -7626,6 +7706,44 @@ class AsyncTeleBot:
|
|
|
7626
7706
|
"""
|
|
7627
7707
|
|
|
7628
7708
|
return await asyncio_helper.delete_sticker_set(self.token, name)
|
|
7709
|
+
|
|
7710
|
+
async def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, text_parse_mode: Optional[str]=None, text_entities: Optional[List[types.MessageEntity]]=None) -> bool:
|
|
7711
|
+
"""
|
|
7712
|
+
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.
|
|
7713
|
+
|
|
7714
|
+
Telegram documentation: https://core.telegram.org/bots/api#sendgift
|
|
7715
|
+
|
|
7716
|
+
:param user_id: Unique identifier of the target user that will receive the gift
|
|
7717
|
+
:type user_id: :obj:`int`
|
|
7718
|
+
|
|
7719
|
+
:param gift_id: Identifier of the gift
|
|
7720
|
+
:type gift_id: :obj:`str`
|
|
7721
|
+
|
|
7722
|
+
:param text: Text that will be shown along with the gift; 0-255 characters
|
|
7723
|
+
:type text: :obj:`str`
|
|
7724
|
+
|
|
7725
|
+
:param text_parse_mode: Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
|
|
7726
|
+
:type text_parse_mode: :obj:`str`
|
|
7727
|
+
|
|
7728
|
+
:param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
|
|
7729
|
+
:type text_entities: :obj:`list` of :obj:`types.MessageEntity`
|
|
7730
|
+
|
|
7731
|
+
:return: Returns True on success.
|
|
7732
|
+
:rtype: :obj:`bool`
|
|
7733
|
+
"""
|
|
7734
|
+
return await asyncio_helper.send_gift(self.token, user_id, gift_id, text, text_parse_mode, text_entities)
|
|
7735
|
+
|
|
7736
|
+
async def get_available_gifts(self) -> types.Gifts:
|
|
7737
|
+
"""
|
|
7738
|
+
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
|
|
7739
|
+
|
|
7740
|
+
Telegram documentation: https://core.telegram.org/bots/api#getavailablegifts
|
|
7741
|
+
|
|
7742
|
+
:return: On success, a Gifts object is returned.
|
|
7743
|
+
:rtype: :class:`telebot.types.Gifts`
|
|
7744
|
+
"""
|
|
7745
|
+
|
|
7746
|
+
return types.Gifts.de_json(await asyncio_helper.get_available_gifts(self.token))
|
|
7629
7747
|
|
|
7630
7748
|
async def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, sticker: types.InputSticker) -> bool:
|
|
7631
7749
|
"""
|
telebot/asyncio_helper.py
CHANGED
|
@@ -325,6 +325,16 @@ async def get_user_profile_photos(token, user_id, offset=None, limit=None):
|
|
|
325
325
|
payload['limit'] = limit
|
|
326
326
|
return await _process_request(token, method_url, params=payload)
|
|
327
327
|
|
|
328
|
+
|
|
329
|
+
async def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
|
|
330
|
+
method_url = r'setUserEmojiStatus'
|
|
331
|
+
payload = {'user_id': user_id}
|
|
332
|
+
if emoji_status_custom_emoji_id:
|
|
333
|
+
payload['emoji_status_custom_emoji_id'] = emoji_status_custom_emoji_id
|
|
334
|
+
if emoji_status_expiration_date:
|
|
335
|
+
payload['emoji_status_expiration_date'] = emoji_status_expiration_date
|
|
336
|
+
return await _process_request(token, method_url, params=payload)
|
|
337
|
+
|
|
328
338
|
async def set_message_reaction(token, chat_id, message_id, reaction=None, is_big=None):
|
|
329
339
|
method_url = r'setMessageReaction'
|
|
330
340
|
payload = {'chat_id': chat_id, 'message_id': message_id}
|
|
@@ -396,6 +406,20 @@ async def answer_web_app_query(token, web_app_query_id, result: types.InlineQuer
|
|
|
396
406
|
return await _process_request(token, method_url, params=payload, method='post')
|
|
397
407
|
|
|
398
408
|
|
|
409
|
+
async def save_prepared_inline_message(token, user_id, result: types.InlineQueryResultBase, allow_user_chats=None, allow_bot_chats=None, allow_group_chats=None, allow_channel_chats=None):
|
|
410
|
+
method_url = r'savePreparedInlineMessage'
|
|
411
|
+
payload = {'user_id': user_id, 'result': result.to_json()}
|
|
412
|
+
if allow_user_chats is not None:
|
|
413
|
+
payload['allow_user_chats'] = allow_user_chats
|
|
414
|
+
if allow_bot_chats is not None:
|
|
415
|
+
payload['allow_bot_chats'] = allow_bot_chats
|
|
416
|
+
if allow_group_chats is not None:
|
|
417
|
+
payload['allow_group_chats'] = allow_group_chats
|
|
418
|
+
if allow_channel_chats is not None:
|
|
419
|
+
payload['allow_channel_chats'] = allow_channel_chats
|
|
420
|
+
return await _process_request(token, method_url, params=payload)
|
|
421
|
+
|
|
422
|
+
|
|
399
423
|
async def get_chat_member(token, chat_id, user_id):
|
|
400
424
|
method_url = r'getChatMember'
|
|
401
425
|
payload = {'chat_id': chat_id, 'user_id': user_id}
|
|
@@ -1793,6 +1817,12 @@ async def refund_star_payment(token, user_id, telegram_payment_charge_id):
|
|
|
1793
1817
|
return await _process_request(token, method_url, params=payload)
|
|
1794
1818
|
|
|
1795
1819
|
|
|
1820
|
+
async def edit_user_star_subscription(token, user_id, telegram_payment_charge_id, is_canceled):
|
|
1821
|
+
method_url = 'editUserStarSubscription'
|
|
1822
|
+
payload = {'user_id': user_id, 'telegram_payment_charge_id': telegram_payment_charge_id, 'is_canceled': is_canceled}
|
|
1823
|
+
return await _process_request(token, method_url, params=payload)
|
|
1824
|
+
|
|
1825
|
+
|
|
1796
1826
|
async def unpin_all_general_forum_topic_messages(token, chat_id):
|
|
1797
1827
|
method_url = 'unpinAllGeneralForumTopicMessages'
|
|
1798
1828
|
payload = {'chat_id': chat_id}
|
|
@@ -1886,6 +1916,21 @@ async def delete_sticker_set(token, name):
|
|
|
1886
1916
|
payload = {'name': name}
|
|
1887
1917
|
return await _process_request(token, method_url, params=payload, method='post')
|
|
1888
1918
|
|
|
1919
|
+
async def send_gift(token, user_id, gift_id, text=None, text_parse_mode=None, text_entities=None):
|
|
1920
|
+
method_url = 'sendGift'
|
|
1921
|
+
payload = {'user_id': user_id, 'gift_id': gift_id}
|
|
1922
|
+
if text:
|
|
1923
|
+
payload['text'] = text
|
|
1924
|
+
if text_parse_mode:
|
|
1925
|
+
payload['text_parse_mode'] = text_parse_mode
|
|
1926
|
+
if text_entities:
|
|
1927
|
+
payload['text_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(text_entities))
|
|
1928
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1929
|
+
|
|
1930
|
+
async def get_available_gifts(token):
|
|
1931
|
+
method_url = 'getAvailableGifts'
|
|
1932
|
+
return await _process_request(token, method_url)
|
|
1933
|
+
|
|
1889
1934
|
async def set_custom_emoji_sticker_set_thumbnail(token, name, custom_emoji_id=None):
|
|
1890
1935
|
method_url = 'setCustomEmojiStickerSetThumbnail'
|
|
1891
1936
|
payload = {'name': name}
|
|
@@ -1952,7 +1997,7 @@ async def create_invoice_link(token, title, description, payload, provider_token
|
|
|
1952
1997
|
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
|
|
1953
1998
|
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
|
|
1954
1999
|
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
|
|
1955
|
-
send_email_to_provider=None, is_flexible=None):
|
|
2000
|
+
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
|
|
1956
2001
|
method_url = r'createInvoiceLink'
|
|
1957
2002
|
payload = {'title': title, 'description': description, 'payload': payload,
|
|
1958
2003
|
'currency': currency, 'prices': await _convert_list_json_serializable(prices)}
|
|
@@ -1986,6 +2031,10 @@ async def create_invoice_link(token, title, description, payload, provider_token
|
|
|
1986
2031
|
payload['is_flexible'] = is_flexible
|
|
1987
2032
|
if provider_token is not None:
|
|
1988
2033
|
payload['provider_token'] = provider_token
|
|
2034
|
+
if subscription_period:
|
|
2035
|
+
payload['subscription_period'] = subscription_period
|
|
2036
|
+
if business_connection_id:
|
|
2037
|
+
payload['business_connection_id'] = business_connection_id
|
|
1989
2038
|
return await _process_request(token, method_url, params=payload, method='post')
|
|
1990
2039
|
|
|
1991
2040
|
|
telebot/formatting.py
CHANGED
|
@@ -240,7 +240,7 @@ def mlink(content: str, url: str, escape: Optional[bool]=True) -> str:
|
|
|
240
240
|
:return: The formatted string.
|
|
241
241
|
:rtype: :obj:`str`
|
|
242
242
|
"""
|
|
243
|
-
return '[{}]({})'.format(escape_markdown(content), escape_markdown(url) if escape else
|
|
243
|
+
return '[{}]({})'.format(escape_markdown(content), escape_markdown(url) if escape else url)
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
def hlink(content: str, url: str, escape: Optional[bool]=True) -> str:
|
telebot/types.py
CHANGED
|
@@ -6318,6 +6318,15 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6318
6318
|
:param invoice_payload: Bot specified invoice payload
|
|
6319
6319
|
:type invoice_payload: :obj:`str`
|
|
6320
6320
|
|
|
6321
|
+
:param subscription_expiration_date: Optional. Expiration date of the subscription, in Unix time; for recurring payments only
|
|
6322
|
+
:type subscription_expiration_date: :obj:`int`
|
|
6323
|
+
|
|
6324
|
+
:param is_recurring: Optional. True, if the payment is a recurring payment, false otherwise
|
|
6325
|
+
:type is_recurring: :obj:`bool`
|
|
6326
|
+
|
|
6327
|
+
:param is_first_recurring: Optional. True, if the payment is the first payment for a subscription
|
|
6328
|
+
:type is_first_recurring: :obj:`bool`
|
|
6329
|
+
|
|
6321
6330
|
:param shipping_option_id: Optional. Identifier of the shipping option chosen by the user
|
|
6322
6331
|
:type shipping_option_id: :obj:`str`
|
|
6323
6332
|
|
|
@@ -6341,7 +6350,8 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6341
6350
|
return cls(**obj)
|
|
6342
6351
|
|
|
6343
6352
|
def __init__(self, currency, total_amount, invoice_payload, shipping_option_id=None, order_info=None,
|
|
6344
|
-
telegram_payment_charge_id=None, provider_payment_charge_id=None,
|
|
6353
|
+
telegram_payment_charge_id=None, provider_payment_charge_id=None,
|
|
6354
|
+
subscription_expiration_date=None, is_recurring=None, is_first_recurring=None, **kwargs):
|
|
6345
6355
|
self.currency: str = currency
|
|
6346
6356
|
self.total_amount: int = total_amount
|
|
6347
6357
|
self.invoice_payload: str = invoice_payload
|
|
@@ -6349,6 +6359,9 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6349
6359
|
self.order_info: OrderInfo = order_info
|
|
6350
6360
|
self.telegram_payment_charge_id: str = telegram_payment_charge_id
|
|
6351
6361
|
self.provider_payment_charge_id: str = provider_payment_charge_id
|
|
6362
|
+
self.subscription_expiration_date: Optional[int] = subscription_expiration_date
|
|
6363
|
+
self.is_recurring: Optional[bool] = is_recurring
|
|
6364
|
+
self.is_first_recurring: Optional[bool] = is_first_recurring
|
|
6352
6365
|
|
|
6353
6366
|
|
|
6354
6367
|
# noinspection PyShadowingBuiltins
|
|
@@ -10398,6 +10411,8 @@ class TransactionPartner(JsonDeserializable):
|
|
|
10398
10411
|
return TransactionPartnerTelegramAds.de_json(obj)
|
|
10399
10412
|
elif obj["type"] == "telegram_api":
|
|
10400
10413
|
return TransactionPartnerTelegramApi.de_json(obj)
|
|
10414
|
+
elif obj["type"] == "affiliate_program":
|
|
10415
|
+
return TransactionPartnerAffiliateProgram.de_json(obj)
|
|
10401
10416
|
elif obj["type"] == "other":
|
|
10402
10417
|
return TransactionPartnerOther.de_json(obj)
|
|
10403
10418
|
|
|
@@ -10473,21 +10488,34 @@ class TransactionPartnerUser(TransactionPartner):
|
|
|
10473
10488
|
:param user: Information about the user
|
|
10474
10489
|
:type user: :class:`User`
|
|
10475
10490
|
|
|
10491
|
+
:param affiliate: Optional. Information about the affiliate that received a commission via this transaction
|
|
10492
|
+
:type affiliate: :class:`AffiliateInfo`
|
|
10493
|
+
|
|
10476
10494
|
:param invoice_payload: Optional, Bot-specified invoice payload
|
|
10477
10495
|
:type invoice_payload: :obj:`str`
|
|
10478
10496
|
|
|
10497
|
+
:param subscription_period: Optional. The duration of the paid subscription
|
|
10498
|
+
:type subscription_period: :obj:`int`
|
|
10499
|
+
|
|
10479
10500
|
:param paid_media: Optional. Information about the paid media bought by the user
|
|
10480
10501
|
:type paid_media: :obj:`list` of :class:`PaidMedia`
|
|
10481
10502
|
|
|
10503
|
+
:param gift: Optional. The gift sent to the user by the bot
|
|
10504
|
+
:type gift: :class:`Gift`
|
|
10505
|
+
|
|
10482
10506
|
:return: Instance of the class
|
|
10483
10507
|
:rtype: :class:`TransactionPartnerUser`
|
|
10484
10508
|
"""
|
|
10485
10509
|
|
|
10486
|
-
def __init__(self, type, user, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
|
|
10510
|
+
def __init__(self, type, user, affiliate=None, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
|
|
10511
|
+
subscription_period=None, gift: Optional[Gift] = None, **kwargs):
|
|
10487
10512
|
self.type: str = type
|
|
10488
10513
|
self.user: User = user
|
|
10514
|
+
self.affiliate: Optional[AffiliateInfo] = affiliate
|
|
10489
10515
|
self.invoice_payload: Optional[str] = invoice_payload
|
|
10490
10516
|
self.paid_media: Optional[List[PaidMedia]] = paid_media
|
|
10517
|
+
self.subscription_period: Optional[int] = subscription_period
|
|
10518
|
+
self.gift: Optional[Gift] = gift
|
|
10491
10519
|
|
|
10492
10520
|
@classmethod
|
|
10493
10521
|
def de_json(cls, json_string):
|
|
@@ -10496,6 +10524,10 @@ class TransactionPartnerUser(TransactionPartner):
|
|
|
10496
10524
|
obj['user'] = User.de_json(obj['user'])
|
|
10497
10525
|
if 'paid_media' in obj:
|
|
10498
10526
|
obj['paid_media'] = [PaidMedia.de_json(media) for media in obj['paid_media']]
|
|
10527
|
+
if 'gift' in obj:
|
|
10528
|
+
obj['gift'] = Gift.de_json(obj['gift'])
|
|
10529
|
+
if 'affiliate' in obj:
|
|
10530
|
+
obj['affiliate'] = AffiliateInfo.de_json(obj['affiliate'])
|
|
10499
10531
|
return cls(**obj)
|
|
10500
10532
|
|
|
10501
10533
|
|
|
@@ -10560,6 +10592,9 @@ class StarTransaction(JsonDeserializable):
|
|
|
10560
10592
|
:param amount: Number of Telegram Stars transferred by the transaction
|
|
10561
10593
|
:type amount: :obj:`int`
|
|
10562
10594
|
|
|
10595
|
+
:param nanostar_amount: Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
|
|
10596
|
+
:type nanostar_amount: :obj:`int`
|
|
10597
|
+
|
|
10563
10598
|
:param date: Date the transaction was created in Unix time
|
|
10564
10599
|
:type date: :obj:`int`
|
|
10565
10600
|
|
|
@@ -10583,12 +10618,13 @@ class StarTransaction(JsonDeserializable):
|
|
|
10583
10618
|
obj['receiver'] = TransactionPartner.de_json(obj['receiver'])
|
|
10584
10619
|
return cls(**obj)
|
|
10585
10620
|
|
|
10586
|
-
def __init__(self, id, amount, date, source=None, receiver=None, **kwargs):
|
|
10621
|
+
def __init__(self, id, amount, date, source=None, receiver=None, nanostar_amount=None, **kwargs):
|
|
10587
10622
|
self.id: str = id
|
|
10588
10623
|
self.amount: int = amount
|
|
10589
10624
|
self.date: int = date
|
|
10590
10625
|
self.source: Optional[TransactionPartner] = source
|
|
10591
10626
|
self.receiver: Optional[TransactionPartner] = receiver
|
|
10627
|
+
self.nanostar_amount: Optional[int] = nanostar_amount
|
|
10592
10628
|
|
|
10593
10629
|
|
|
10594
10630
|
class StarTransactions(JsonDeserializable):
|
|
@@ -10979,3 +11015,172 @@ class CopyTextButton(JsonSerializable, JsonDeserializable):
|
|
|
10979
11015
|
if json_string is None: return None
|
|
10980
11016
|
obj = cls.check_json(json_string)
|
|
10981
11017
|
return cls(**obj)
|
|
11018
|
+
|
|
11019
|
+
|
|
11020
|
+
class PreparedInlineMessage(JsonDeserializable):
|
|
11021
|
+
"""
|
|
11022
|
+
Describes an inline message to be sent by a user of a Mini App.
|
|
11023
|
+
|
|
11024
|
+
Telegram documentation: https://core.telegram.org/bots/api#preparedinlinemessage
|
|
11025
|
+
|
|
11026
|
+
:param id: Unique identifier of the prepared message
|
|
11027
|
+
:type id: :obj:`str`
|
|
11028
|
+
|
|
11029
|
+
:param expiration_date: Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used
|
|
11030
|
+
:type expiration_date: :obj:`int`
|
|
11031
|
+
|
|
11032
|
+
:return: Instance of the class
|
|
11033
|
+
:rtype: :class:`PreparedInlineMessage`
|
|
11034
|
+
"""
|
|
11035
|
+
|
|
11036
|
+
def __init__(self, id, expiration_date, **kwargs):
|
|
11037
|
+
self.id: str = id
|
|
11038
|
+
self.expiration_date: int = expiration_date
|
|
11039
|
+
|
|
11040
|
+
@classmethod
|
|
11041
|
+
def de_json(cls, json_string):
|
|
11042
|
+
if json_string is None: return None
|
|
11043
|
+
obj = cls.check_json(json_string)
|
|
11044
|
+
return cls(**obj)
|
|
11045
|
+
|
|
11046
|
+
|
|
11047
|
+
class Gift(JsonDeserializable):
|
|
11048
|
+
"""
|
|
11049
|
+
This object represents a gift that can be sent by the bot.
|
|
11050
|
+
|
|
11051
|
+
Telegram documentation: https://core.telegram.org/bots/api#gift
|
|
11052
|
+
|
|
11053
|
+
:param id: Unique identifier of the gift
|
|
11054
|
+
:type id: :obj:`str`
|
|
11055
|
+
|
|
11056
|
+
:param sticker: The sticker that represents the gift
|
|
11057
|
+
:type sticker: :class:`Sticker`
|
|
11058
|
+
|
|
11059
|
+
:param star_count: The number of Telegram Stars that must be paid to send the sticker
|
|
11060
|
+
:type star_count: :obj:`int`
|
|
11061
|
+
|
|
11062
|
+
:param total_count: Optional. The total number of the gifts of this type that can be sent; for limited gifts only
|
|
11063
|
+
:type total_count: :obj:`int`
|
|
11064
|
+
|
|
11065
|
+
:param remaining_count: Optional. The number of remaining gifts of this type that can be sent; for limited gifts only
|
|
11066
|
+
:type remaining_count: :obj:`int`
|
|
11067
|
+
|
|
11068
|
+
:return: Instance of the class
|
|
11069
|
+
:rtype: :class:`Gift`
|
|
11070
|
+
"""
|
|
11071
|
+
|
|
11072
|
+
def __init__(self, id, sticker, star_count, total_count=None, remaining_count=None, **kwargs):
|
|
11073
|
+
self.id: str = id
|
|
11074
|
+
self.sticker: Sticker = sticker
|
|
11075
|
+
self.star_count: int = star_count
|
|
11076
|
+
self.total_count: Optional[int] = total_count
|
|
11077
|
+
self.remaining_count: Optional[int] = remaining_count
|
|
11078
|
+
|
|
11079
|
+
@classmethod
|
|
11080
|
+
def de_json(cls, json_string):
|
|
11081
|
+
if json_string is None: return None
|
|
11082
|
+
obj = cls.check_json(json_string)
|
|
11083
|
+
obj['sticker'] = Sticker.de_json(obj['sticker'])
|
|
11084
|
+
return cls(**obj)
|
|
11085
|
+
|
|
11086
|
+
class Gifts(JsonDeserializable):
|
|
11087
|
+
"""
|
|
11088
|
+
This object represent a list of gifts.
|
|
11089
|
+
|
|
11090
|
+
Telegram documentation: https://core.telegram.org/bots/api#gifts
|
|
11091
|
+
|
|
11092
|
+
:param gifts: The list of gifts
|
|
11093
|
+
:type gifts: :obj:`list` of :class:`Gift`
|
|
11094
|
+
|
|
11095
|
+
:return: Instance of the class
|
|
11096
|
+
:rtype: :class:`Gifts`
|
|
11097
|
+
"""
|
|
11098
|
+
|
|
11099
|
+
def __init__(self, gifts, **kwargs):
|
|
11100
|
+
self.gifts: List[Gift] = gifts
|
|
11101
|
+
|
|
11102
|
+
@classmethod
|
|
11103
|
+
def de_json(cls, json_string):
|
|
11104
|
+
if json_string is None: return None
|
|
11105
|
+
obj = cls.check_json(json_string)
|
|
11106
|
+
obj['gifts'] = [Gift.de_json(gift) for gift in obj['gifts']]
|
|
11107
|
+
return cls(**obj)
|
|
11108
|
+
|
|
11109
|
+
|
|
11110
|
+
class TransactionPartnerAffiliateProgram(TransactionPartner):
|
|
11111
|
+
"""
|
|
11112
|
+
Describes the affiliate program that issued the affiliate commission received via this transaction.
|
|
11113
|
+
|
|
11114
|
+
Telegram documentation: https://core.telegram.org/bots/api#transactionpartneraffiliateprogram
|
|
11115
|
+
|
|
11116
|
+
:param type: Type of the transaction partner, always “affiliate_program”
|
|
11117
|
+
:type type: :obj:`str`
|
|
11118
|
+
|
|
11119
|
+
:param sponsor_user: Optional. Information about the bot that sponsored the affiliate program
|
|
11120
|
+
:type sponsor_user: :class:`User`
|
|
11121
|
+
|
|
11122
|
+
:param commission_per_mille: The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users
|
|
11123
|
+
:type commission_per_mille: :obj:`int`
|
|
11124
|
+
|
|
11125
|
+
:return: Instance of the class
|
|
11126
|
+
:rtype: :class:`TransactionPartnerAffiliateProgram`
|
|
11127
|
+
"""
|
|
11128
|
+
|
|
11129
|
+
def __init__(self, type, commission_per_mille, sponsor_user=None, **kwargs):
|
|
11130
|
+
self.type: str = type
|
|
11131
|
+
self.sponsor_user: Optional[User] = sponsor_user
|
|
11132
|
+
self.commission_per_mille: int = commission_per_mille
|
|
11133
|
+
|
|
11134
|
+
@classmethod
|
|
11135
|
+
def de_json(cls, json_string):
|
|
11136
|
+
if json_string is None: return None
|
|
11137
|
+
obj = cls.check_json(json_string)
|
|
11138
|
+
if 'sponsor_user' in obj:
|
|
11139
|
+
obj['sponsor_user'] = User.de_json(obj['sponsor_user'])
|
|
11140
|
+
|
|
11141
|
+
return cls(**obj)
|
|
11142
|
+
|
|
11143
|
+
|
|
11144
|
+
class AffiliateInfo(JsonDeserializable):
|
|
11145
|
+
"""
|
|
11146
|
+
Contains information about the affiliate that received a commission via this transaction.
|
|
11147
|
+
|
|
11148
|
+
Telegram documentation: https://core.telegram.org/bots/api#affiliateinfo
|
|
11149
|
+
|
|
11150
|
+
:param affiliate_user: Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
|
|
11151
|
+
:type affiliate_user: :class:`User`
|
|
11152
|
+
|
|
11153
|
+
:param affiliate_chat: Optional. The chat that received an affiliate commission if it was received by a chat
|
|
11154
|
+
:type affiliate_chat: :class:`Chat`
|
|
11155
|
+
|
|
11156
|
+
:param commission_per_mille: The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users
|
|
11157
|
+
:type commission_per_mille: :obj:`int`
|
|
11158
|
+
|
|
11159
|
+
:param amount: Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
|
|
11160
|
+
:type amount: :obj:`int`
|
|
11161
|
+
|
|
11162
|
+
:param nanostar_amount: Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds
|
|
11163
|
+
:type nanostar_amount: :obj:`int`
|
|
11164
|
+
|
|
11165
|
+
:return: Instance of the class
|
|
11166
|
+
:rtype: :class:`AffiliateInfo`
|
|
11167
|
+
"""
|
|
11168
|
+
|
|
11169
|
+
def __init__(self, commission_per_mille, amount, affiliate_user=None, affiliate_chat=None, nanostar_amount=None, **kwargs):
|
|
11170
|
+
self.affiliate_user: Optional[User] = affiliate_user
|
|
11171
|
+
self.affiliate_chat: Optional[Chat] = affiliate_chat
|
|
11172
|
+
self.commission_per_mille: int = commission_per_mille
|
|
11173
|
+
self.amount: int = amount
|
|
11174
|
+
self.nanostar_amount: Optional[int] = nanostar_amount
|
|
11175
|
+
|
|
11176
|
+
@classmethod
|
|
11177
|
+
def de_json(cls, json_string):
|
|
11178
|
+
if json_string is None: return None
|
|
11179
|
+
obj = cls.check_json(json_string)
|
|
11180
|
+
if 'affiliate_user' in obj:
|
|
11181
|
+
obj['affiliate_user'] = User.de_json(obj['affiliate_user'])
|
|
11182
|
+
if 'affiliate_chat' in obj:
|
|
11183
|
+
obj['affiliate_chat'] = Chat.de_json(obj['affiliate_chat'])
|
|
11184
|
+
return cls(**obj)
|
|
11185
|
+
|
|
11186
|
+
|
telebot/version.py
CHANGED
|
File without changes
|
|
File without changes
|