pyTelegramBotAPI 4.24.0__py3-none-any.whl → 4.26.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.26.0.dist-info}/METADATA +5 -4
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.26.0.dist-info}/RECORD +11 -11
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.26.0.dist-info}/WHEEL +1 -1
- telebot/__init__.py +195 -2
- telebot/apihelper.py +87 -1
- telebot/async_telebot.py +188 -2
- telebot/asyncio_helper.py +82 -1
- telebot/formatting.py +1 -1
- telebot/types.py +216 -3
- telebot/version.py +1 -1
- {pytelegrambotapi-4.24.0.dist-info → pytelegrambotapi-4.26.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pyTelegramBotAPI
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.26.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
|
|
@@ -8,6 +8,7 @@ Project-URL: Repository, https://github.com/eternnoir/pyTelegramBotAPI
|
|
|
8
8
|
Project-URL: Issues, https://github.com/eternnoir/pyTelegramBotAPI/issues
|
|
9
9
|
Author-email: eternnoir <eternnoir@gmail.com>
|
|
10
10
|
License: GPL2
|
|
11
|
+
License-File: LICENSE
|
|
11
12
|
Keywords: api,bot,telegram,tools
|
|
12
13
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
14
|
Classifier: Environment :: Console
|
|
@@ -52,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
52
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>
|
|
53
54
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
54
55
|
|
|
55
|
-
## <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#january-1-2025"><img src="https://img.shields.io/badge/Bot%20API-8.2-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
56
57
|
|
|
57
58
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
58
59
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -872,7 +873,7 @@ Here are some examples of template:
|
|
|
872
873
|
* [RadRetroRobot](https://github.com/Tronikart/RadRetroRobot) by *Tronikart* - Multifunctional Telegram Bot RadRetroRobot.
|
|
873
874
|
* [League of Legends bot](https://telegram.me/League_of_Legends_bot) ([source](https://github.com/i32ropie/lol)) by *i32ropie*
|
|
874
875
|
* [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
|
|
876
|
+
* [ColorCodeBot](https://t.me/colorcodebot) ([source](https://github.com/andydecleyre/colorcodebot)) - Share code snippets as beautifully syntax-highlighted images.
|
|
876
877
|
* [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
878
|
* [proxybot](https://github.com/p-hash/proxybot) - Simple Proxy Bot for Telegram. by p-hash
|
|
878
879
|
* [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=ZQtRT7eeEcZ8PH640XvIlzqHnB3TBk5k7KjZF2U-xzs,435648
|
|
2
|
+
telebot/apihelper.py,sha256=N89dapRPfv3TfA7_YqZZpolJ5C_bTLrZRUW6klzd6J0,101613
|
|
3
|
+
telebot/async_telebot.py,sha256=IC197RbcdRLLSsgtVhkKNCEkwBZ8Yp3vBhFWc7BurCg,408733
|
|
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=HCfTkX0_o4US2Mp5xCrbb6BPEZX5cgKXxCp--1ZxYFo,102561
|
|
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=3iDuL1CBMfH7FUITdxOAa04AQwswEBKXgswUMwwacaE,475305
|
|
13
13
|
telebot/util.py,sha256=ylRtI4DI4I1BJAF2Ack7WyGbTN1cRkubUCbhLNiiPj4,21385
|
|
14
|
-
telebot/version.py,sha256=
|
|
14
|
+
telebot/version.py,sha256=PVbmIN1Rpi1DPItgqp-6XAZxaknSOoqK63cBImPFerg,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.26.0.dist-info/METADATA,sha256=74lUQzeDkW4EQE2QFlnleOTIR5y7tMFaVfZJttC6K1U,48143
|
|
39
|
+
pytelegrambotapi-4.26.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
40
|
+
pytelegrambotapi-4.26.0.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
|
|
41
|
+
pytelegrambotapi-4.26.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
|
+
:param 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,112 @@ 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,
|
|
6254
|
+
text_entities: Optional[List[types.MessageEntity]]=None, pay_for_upgrade: Optional[bool]=None) -> bool:
|
|
6255
|
+
"""
|
|
6256
|
+
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.
|
|
6257
|
+
|
|
6258
|
+
Telegram documentation: https://core.telegram.org/bots/api#sendgift
|
|
6259
|
+
|
|
6260
|
+
:param user_id: Unique identifier of the target user that will receive the gift
|
|
6261
|
+
:type user_id: :obj:`int`
|
|
6262
|
+
|
|
6263
|
+
:param gift_id: Identifier of the gift
|
|
6264
|
+
:type gift_id: :obj:`str`
|
|
6265
|
+
|
|
6266
|
+
:param pay_for_upgrade: Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
|
|
6267
|
+
:type pay_for_upgrade: :obj:`bool`
|
|
6268
|
+
|
|
6269
|
+
:param text: Text that will be shown along with the gift; 0-255 characters
|
|
6270
|
+
:type text: :obj:`str`
|
|
6271
|
+
|
|
6272
|
+
: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.
|
|
6273
|
+
:type text_parse_mode: :obj:`str`
|
|
6274
|
+
|
|
6275
|
+
: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.
|
|
6276
|
+
:type text_entities: :obj:`list` of :obj:`types.MessageEntity`
|
|
6277
|
+
|
|
6278
|
+
:return: Returns True on success.
|
|
6279
|
+
:rtype: :obj:`bool`
|
|
6280
|
+
"""
|
|
6281
|
+
return apihelper.send_gift(self.token, user_id, gift_id, text=text, text_parse_mode=text_parse_mode, text_entities=text_entities,
|
|
6282
|
+
pay_for_upgrade=pay_for_upgrade)
|
|
6283
|
+
|
|
6284
|
+
def verify_user(self, user_id: int, custom_description: Optional[str]=None) -> bool:
|
|
6285
|
+
"""
|
|
6286
|
+
Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
|
|
6287
|
+
|
|
6288
|
+
Telegram documentation: https://core.telegram.org/bots/api#verifyuser
|
|
6289
|
+
|
|
6290
|
+
:param user_id: Unique identifier of the target user
|
|
6291
|
+
:type user_id: :obj:`int`
|
|
6292
|
+
|
|
6293
|
+
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
6294
|
+
:type custom_description: :obj:`str`
|
|
6295
|
+
|
|
6296
|
+
:return: Returns True on success.
|
|
6297
|
+
:rtype: :obj:`bool`
|
|
6298
|
+
"""
|
|
6299
|
+
return apihelper.verify_user(self.token, user_id, custom_description=custom_description)
|
|
6300
|
+
|
|
6301
|
+
def verify_chat(self, chat_id: Union[int, str], custom_description: Optional[str]=None) -> bool:
|
|
6302
|
+
"""
|
|
6303
|
+
Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
|
|
6304
|
+
|
|
6305
|
+
Telegram documentation: https://core.telegram.org/bots/api#verifychat
|
|
6306
|
+
|
|
6307
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
6308
|
+
:type chat_id: :obj:`int` | :obj:`str`
|
|
6309
|
+
|
|
6310
|
+
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
6311
|
+
:type custom_description: :obj:`str`
|
|
6312
|
+
|
|
6313
|
+
:return: Returns True on success.
|
|
6314
|
+
:rtype: :obj:`bool`
|
|
6315
|
+
"""
|
|
6316
|
+
return apihelper.verify_chat(self.token, chat_id, custom_description=custom_description)
|
|
6317
|
+
|
|
6318
|
+
def remove_user_verification(self, user_id: int) -> bool:
|
|
6319
|
+
"""
|
|
6320
|
+
Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
6321
|
+
|
|
6322
|
+
Telegram documentation: https://core.telegram.org/bots/api#removeuserverification
|
|
6323
|
+
|
|
6324
|
+
:param user_id: Unique identifier of the target user
|
|
6325
|
+
:type user_id: :obj:`int`
|
|
6326
|
+
|
|
6327
|
+
:return: Returns True on success.
|
|
6328
|
+
:rtype: :obj:`bool`
|
|
6329
|
+
"""
|
|
6330
|
+
|
|
6331
|
+
return apihelper.remove_user_verification(self.token, user_id)
|
|
6332
|
+
|
|
6333
|
+
def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
|
|
6334
|
+
"""
|
|
6335
|
+
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
6336
|
+
|
|
6337
|
+
Telegram documentation: https://core.telegram.org/bots/api#removechatverification
|
|
6338
|
+
|
|
6339
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
6340
|
+
:type chat_id: :obj:`int` | :obj:`str`
|
|
6341
|
+
|
|
6342
|
+
:return: Returns True on success.
|
|
6343
|
+
:rtype: :obj:`bool`
|
|
6344
|
+
"""
|
|
6345
|
+
return apihelper.remove_chat_verification(self.token, chat_id)
|
|
6346
|
+
|
|
6347
|
+
def get_available_gifts(self) -> types.Gifts:
|
|
6348
|
+
"""
|
|
6349
|
+
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
|
|
6350
|
+
|
|
6351
|
+
Telegram documentation: https://core.telegram.org/bots/api#getavailablegifts
|
|
6352
|
+
|
|
6353
|
+
:return: On success, a Gifts object is returned.
|
|
6354
|
+
:rtype: :class:`telebot.types.Gifts`
|
|
6355
|
+
"""
|
|
6356
|
+
return types.Gifts.de_json(
|
|
6357
|
+
apihelper.get_available_gifts(self.token)
|
|
6358
|
+
)
|
|
6202
6359
|
|
|
6203
6360
|
def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, sticker: types.InputSticker) -> bool:
|
|
6204
6361
|
"""
|
|
@@ -6718,6 +6875,42 @@ class TeleBot:
|
|
|
6718
6875
|
"""
|
|
6719
6876
|
return apihelper.answer_web_app_query(self.token, web_app_query_id, result)
|
|
6720
6877
|
|
|
6878
|
+
def save_prepared_inline_message(
|
|
6879
|
+
self, user_id: int, result: types.InlineQueryResultBase, allow_user_chats: Optional[bool]=None,
|
|
6880
|
+
allow_bot_chats: Optional[bool]=None, allow_group_chats: Optional[bool]=None,
|
|
6881
|
+
allow_channel_chats: Optional[bool]=None) -> types.PreparedInlineMessage:
|
|
6882
|
+
"""
|
|
6883
|
+
Use this method to store a message that can be sent by a user of a Mini App.
|
|
6884
|
+
Returns a PreparedInlineMessage object.
|
|
6885
|
+
|
|
6886
|
+
Telegram Documentation: https://core.telegram.org/bots/api#savepreparedinlinemessage
|
|
6887
|
+
|
|
6888
|
+
:param user_id: Unique identifier of the target user that can use the prepared message
|
|
6889
|
+
:type user_id: :obj:`int`
|
|
6890
|
+
|
|
6891
|
+
:param result: A JSON-serialized object describing the message to be sent
|
|
6892
|
+
:type result: :class:`telebot.types.InlineQueryResultBase`
|
|
6893
|
+
|
|
6894
|
+
:param allow_user_chats: Pass True if the message can be sent to private chats with users
|
|
6895
|
+
:type allow_user_chats: :obj:`bool`
|
|
6896
|
+
|
|
6897
|
+
:param allow_bot_chats: Pass True if the message can be sent to private chats with bots
|
|
6898
|
+
:type allow_bot_chats: :obj:`bool`
|
|
6899
|
+
|
|
6900
|
+
:param allow_group_chats: Pass True if the message can be sent to group and supergroup chats
|
|
6901
|
+
:type allow_group_chats: :obj:`bool`
|
|
6902
|
+
|
|
6903
|
+
:param allow_channel_chats: Pass True if the message can be sent to channel chats
|
|
6904
|
+
:type allow_channel_chats: :obj:`bool`
|
|
6905
|
+
|
|
6906
|
+
:return: On success, a PreparedInlineMessage object is returned.
|
|
6907
|
+
:rtype: :class:`telebot.types.PreparedInlineMessage`
|
|
6908
|
+
"""
|
|
6909
|
+
return types.PreparedInlineMessage.de_json(
|
|
6910
|
+
apihelper.save_prepared_inline_message(
|
|
6911
|
+
self.token, user_id, result, allow_user_chats=allow_user_chats, allow_bot_chats=allow_bot_chats,
|
|
6912
|
+
allow_group_chats=allow_group_chats, allow_channel_chats=allow_channel_chats)
|
|
6913
|
+
)
|
|
6721
6914
|
|
|
6722
6915
|
def register_for_reply(self, message: types.Message, callback: Callable, *args, **kwargs) -> None:
|
|
6723
6916
|
"""
|
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,52 @@ 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, pay_for_upgrade=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
|
+
if pay_for_upgrade is not None:
|
|
1942
|
+
payload['pay_for_upgrade'] = pay_for_upgrade
|
|
1943
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
def verify_user(token, user_id, custom_description=None):
|
|
1947
|
+
method_url = 'verifyUser'
|
|
1948
|
+
payload = {'user_id': user_id}
|
|
1949
|
+
if custom_description:
|
|
1950
|
+
payload['custom_description'] = custom_description
|
|
1951
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
def verify_chat(token, chat_id, custom_description=None):
|
|
1955
|
+
method_url = 'verifyChat'
|
|
1956
|
+
payload = {'chat_id': chat_id}
|
|
1957
|
+
if custom_description:
|
|
1958
|
+
payload['custom_description'] = custom_description
|
|
1959
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1960
|
+
|
|
1961
|
+
|
|
1962
|
+
def remove_user_verification(token, user_id):
|
|
1963
|
+
method_url = 'removeUserVerification'
|
|
1964
|
+
payload = {'user_id': user_id}
|
|
1965
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1966
|
+
|
|
1967
|
+
|
|
1968
|
+
def remove_chat_verification(token, chat_id):
|
|
1969
|
+
method_url = 'removeChatVerification'
|
|
1970
|
+
payload = {'chat_id': chat_id}
|
|
1971
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
1972
|
+
|
|
1912
1973
|
def set_sticker_emoji_list(token, sticker, emoji_list):
|
|
1913
1974
|
method_url = 'setStickerEmojiList'
|
|
1914
1975
|
payload = {'sticker': sticker, 'emoji_list': json.dumps(emoji_list)}
|
|
@@ -1966,11 +2027,26 @@ def answer_web_app_query(token, web_app_query_id, result: types.InlineQueryResul
|
|
|
1966
2027
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1967
2028
|
|
|
1968
2029
|
|
|
2030
|
+
def save_prepared_inline_message(token, user_id, result: types.InlineQueryResultBase, allow_user_chats=None,
|
|
2031
|
+
allow_bot_chats=None, allow_group_chats=None, allow_channel_chats=None):
|
|
2032
|
+
method_url = 'savePreparedInlineMessage'
|
|
2033
|
+
payload = {'user_id': user_id, 'result': result.to_json()}
|
|
2034
|
+
if allow_user_chats is not None:
|
|
2035
|
+
payload['allow_user_chats'] = allow_user_chats
|
|
2036
|
+
if allow_bot_chats is not None:
|
|
2037
|
+
payload['allow_bot_chats'] = allow_bot_chats
|
|
2038
|
+
if allow_group_chats is not None:
|
|
2039
|
+
payload['allow_group_chats'] = allow_group_chats
|
|
2040
|
+
if allow_channel_chats is not None:
|
|
2041
|
+
payload['allow_channel_chats'] = allow_channel_chats
|
|
2042
|
+
return _make_request(token, method_url, params=payload, method='post')
|
|
2043
|
+
|
|
2044
|
+
|
|
1969
2045
|
def create_invoice_link(token, title, description, payload, provider_token,
|
|
1970
2046
|
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
|
|
1971
2047
|
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
|
|
1972
2048
|
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
|
|
1973
|
-
send_email_to_provider=None, is_flexible=None):
|
|
2049
|
+
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
|
|
1974
2050
|
method_url = r'createInvoiceLink'
|
|
1975
2051
|
payload = {'title': title, 'description': description, 'payload': payload,
|
|
1976
2052
|
'currency': currency, 'prices': _convert_list_json_serializable(prices)}
|
|
@@ -2004,6 +2080,10 @@ def create_invoice_link(token, title, description, payload, provider_token,
|
|
|
2004
2080
|
payload['is_flexible'] = is_flexible
|
|
2005
2081
|
if provider_token is not None:
|
|
2006
2082
|
payload['provider_token'] = provider_token
|
|
2083
|
+
if subscription_period:
|
|
2084
|
+
payload['subscription_period'] = subscription_period
|
|
2085
|
+
if business_connection_id:
|
|
2086
|
+
payload['business_connection_id'] = business_connection_id
|
|
2007
2087
|
return _make_request(token, method_url, params=payload, method='post')
|
|
2008
2088
|
|
|
2009
2089
|
|
|
@@ -2221,6 +2301,12 @@ def convert_input_media_array(array):
|
|
|
2221
2301
|
if media_dict['media'].startswith('attach://'):
|
|
2222
2302
|
key = media_dict['media'].replace('attach://', '')
|
|
2223
2303
|
files[key] = input_media.media
|
|
2304
|
+
if 'thumbnail' in media_dict:
|
|
2305
|
+
thumbnail = media_dict['thumbnail']
|
|
2306
|
+
if isinstance(thumbnail, types.InputFile):
|
|
2307
|
+
thumbnail_key = 'thumbnail_' + key
|
|
2308
|
+
files[thumbnail_key] = thumbnail
|
|
2309
|
+
media_dict['thumbnail'] = 'attach://' + thumbnail_key
|
|
2224
2310
|
media.append(media_dict)
|
|
2225
2311
|
return json.dumps(media), files
|
|
2226
2312
|
|
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
|
+
:param 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,112 @@ 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,
|
|
7711
|
+
text_entities: Optional[List[types.MessageEntity]]=None, pay_for_upgrade: Optional[bool]=None) -> bool:
|
|
7712
|
+
"""
|
|
7713
|
+
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.
|
|
7714
|
+
|
|
7715
|
+
Telegram documentation: https://core.telegram.org/bots/api#sendgift
|
|
7716
|
+
|
|
7717
|
+
:param user_id: Unique identifier of the target user that will receive the gift
|
|
7718
|
+
:type user_id: :obj:`int`
|
|
7719
|
+
|
|
7720
|
+
:param gift_id: Identifier of the gift
|
|
7721
|
+
:type gift_id: :obj:`str`
|
|
7722
|
+
|
|
7723
|
+
:param pay_for_upgrade: Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
|
|
7724
|
+
:type pay_for_upgrade: :obj:`bool`
|
|
7725
|
+
|
|
7726
|
+
:param text: Text that will be shown along with the gift; 0-255 characters
|
|
7727
|
+
:type text: :obj:`str`
|
|
7728
|
+
|
|
7729
|
+
: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.
|
|
7730
|
+
:type text_parse_mode: :obj:`str`
|
|
7731
|
+
|
|
7732
|
+
: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.
|
|
7733
|
+
:type text_entities: :obj:`list` of :obj:`types.MessageEntity`
|
|
7734
|
+
|
|
7735
|
+
:return: Returns True on success.
|
|
7736
|
+
:rtype: :obj:`bool`
|
|
7737
|
+
"""
|
|
7738
|
+
return await asyncio_helper.send_gift(self.token, user_id, gift_id, text, text_parse_mode, text_entities, pay_for_upgrade=pay_for_upgrade)
|
|
7739
|
+
|
|
7740
|
+
async def verify_user(self, user_id: int, custom_description: Optional[str]=None) -> bool:
|
|
7741
|
+
"""
|
|
7742
|
+
Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
|
|
7743
|
+
|
|
7744
|
+
Telegram documentation: https://core.telegram.org/bots/api#verifyuser
|
|
7745
|
+
|
|
7746
|
+
:param user_id: Unique identifier of the target user
|
|
7747
|
+
:type user_id: :obj:`int`
|
|
7748
|
+
|
|
7749
|
+
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
7750
|
+
:type custom_description: :obj:`str`
|
|
7751
|
+
|
|
7752
|
+
:return: Returns True on success.
|
|
7753
|
+
:rtype: :obj:`bool`
|
|
7754
|
+
"""
|
|
7755
|
+
return await asyncio_helper.verify_user(self.token, user_id, custom_description=custom_description)
|
|
7756
|
+
|
|
7757
|
+
async def verify_chat(self, chat_id: Union[int, str], custom_description: Optional[str]=None) -> bool:
|
|
7758
|
+
"""
|
|
7759
|
+
Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
|
|
7760
|
+
|
|
7761
|
+
Telegram documentation: https://core.telegram.org/bots/api#verifychat
|
|
7762
|
+
|
|
7763
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
7764
|
+
:type chat_id: :obj:`int` | :obj:`str`
|
|
7765
|
+
|
|
7766
|
+
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description.
|
|
7767
|
+
:type custom_description: :obj:`str`
|
|
7768
|
+
|
|
7769
|
+
:return: Returns True on success.
|
|
7770
|
+
:rtype: :obj:`bool`
|
|
7771
|
+
"""
|
|
7772
|
+
|
|
7773
|
+
return await asyncio_helper.verify_chat(self.token, chat_id, custom_description=custom_description)
|
|
7774
|
+
|
|
7775
|
+
async def remove_user_verification(self, user_id: int) -> bool:
|
|
7776
|
+
"""
|
|
7777
|
+
Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
7778
|
+
|
|
7779
|
+
Telegram documentation: https://core.telegram.org/bots/api#removeuserverification
|
|
7780
|
+
|
|
7781
|
+
:param user_id: Unique identifier of the target user
|
|
7782
|
+
:type user_id: :obj:`int`
|
|
7783
|
+
|
|
7784
|
+
:return: Returns True on success.
|
|
7785
|
+
:rtype: :obj:`bool`
|
|
7786
|
+
|
|
7787
|
+
"""
|
|
7788
|
+
return await asyncio_helper.remove_user_verification(self.token, user_id)
|
|
7789
|
+
|
|
7790
|
+
async def remove_chat_verification(self, chat_id: Union[int, str]) -> bool:
|
|
7791
|
+
"""
|
|
7792
|
+
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
|
|
7793
|
+
|
|
7794
|
+
Telegram documentation: https://core.telegram.org/bots/api#removechatverification
|
|
7795
|
+
|
|
7796
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
7797
|
+
:type chat_id: :obj:`int` | :obj:`str`
|
|
7798
|
+
|
|
7799
|
+
:return: Returns True on success.
|
|
7800
|
+
:rtype: :obj:`bool`
|
|
7801
|
+
"""
|
|
7802
|
+
return await asyncio_helper.remove_chat_verification(self.token, chat_id)
|
|
7803
|
+
|
|
7804
|
+
async def get_available_gifts(self) -> types.Gifts:
|
|
7805
|
+
"""
|
|
7806
|
+
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
|
|
7807
|
+
|
|
7808
|
+
Telegram documentation: https://core.telegram.org/bots/api#getavailablegifts
|
|
7809
|
+
|
|
7810
|
+
:return: On success, a Gifts object is returned.
|
|
7811
|
+
:rtype: :class:`telebot.types.Gifts`
|
|
7812
|
+
"""
|
|
7813
|
+
|
|
7814
|
+
return types.Gifts.de_json(await asyncio_helper.get_available_gifts(self.token))
|
|
7629
7815
|
|
|
7630
7816
|
async def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, sticker: types.InputSticker) -> bool:
|
|
7631
7817
|
"""
|
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,47 @@ 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, pay_for_upgrade=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
|
+
if pay_for_upgrade is not None:
|
|
1929
|
+
payload['pay_for_upgrade'] = pay_for_upgrade
|
|
1930
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1931
|
+
|
|
1932
|
+
async def verify_user(token, user_id, custom_description=None):
|
|
1933
|
+
method_url = 'verifyUser'
|
|
1934
|
+
payload = {'user_id': user_id}
|
|
1935
|
+
if custom_description:
|
|
1936
|
+
payload['custom_description'] = custom_description
|
|
1937
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1938
|
+
|
|
1939
|
+
async def verify_chat(token, chat_id, custom_description=None):
|
|
1940
|
+
method_url = 'verifyChat'
|
|
1941
|
+
payload = {'chat_id': chat_id}
|
|
1942
|
+
if custom_description:
|
|
1943
|
+
payload['custom_description'] = custom_description
|
|
1944
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1945
|
+
|
|
1946
|
+
async def remove_user_verification(token, user_id):
|
|
1947
|
+
method_url = 'removeUserVerification'
|
|
1948
|
+
payload = {'user_id': user_id}
|
|
1949
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1950
|
+
|
|
1951
|
+
async def remove_chat_verification(token, chat_id):
|
|
1952
|
+
method_url = 'removeChatVerification'
|
|
1953
|
+
payload = {'chat_id': chat_id}
|
|
1954
|
+
return await _process_request(token, method_url, params=payload, method='post')
|
|
1955
|
+
|
|
1956
|
+
async def get_available_gifts(token):
|
|
1957
|
+
method_url = 'getAvailableGifts'
|
|
1958
|
+
return await _process_request(token, method_url)
|
|
1959
|
+
|
|
1889
1960
|
async def set_custom_emoji_sticker_set_thumbnail(token, name, custom_emoji_id=None):
|
|
1890
1961
|
method_url = 'setCustomEmojiStickerSetThumbnail'
|
|
1891
1962
|
payload = {'name': name}
|
|
@@ -1952,7 +2023,7 @@ async def create_invoice_link(token, title, description, payload, provider_token
|
|
|
1952
2023
|
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
|
|
1953
2024
|
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
|
|
1954
2025
|
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
|
|
1955
|
-
send_email_to_provider=None, is_flexible=None):
|
|
2026
|
+
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
|
|
1956
2027
|
method_url = r'createInvoiceLink'
|
|
1957
2028
|
payload = {'title': title, 'description': description, 'payload': payload,
|
|
1958
2029
|
'currency': currency, 'prices': await _convert_list_json_serializable(prices)}
|
|
@@ -1986,6 +2057,10 @@ async def create_invoice_link(token, title, description, payload, provider_token
|
|
|
1986
2057
|
payload['is_flexible'] = is_flexible
|
|
1987
2058
|
if provider_token is not None:
|
|
1988
2059
|
payload['provider_token'] = provider_token
|
|
2060
|
+
if subscription_period:
|
|
2061
|
+
payload['subscription_period'] = subscription_period
|
|
2062
|
+
if business_connection_id:
|
|
2063
|
+
payload['business_connection_id'] = business_connection_id
|
|
1989
2064
|
return await _process_request(token, method_url, params=payload, method='post')
|
|
1990
2065
|
|
|
1991
2066
|
|
|
@@ -2194,6 +2269,12 @@ async def convert_input_media_array(array):
|
|
|
2194
2269
|
if media_dict['media'].startswith('attach://'):
|
|
2195
2270
|
key = media_dict['media'].replace('attach://', '')
|
|
2196
2271
|
files[key] = input_media.media
|
|
2272
|
+
if 'thumbnail' in media_dict:
|
|
2273
|
+
thumbnail = media_dict['thumbnail']
|
|
2274
|
+
if isinstance(thumbnail, types.InputFile):
|
|
2275
|
+
thumbnail_key = 'thumbnail_' + key
|
|
2276
|
+
files[thumbnail_key] = thumbnail
|
|
2277
|
+
media_dict['thumbnail'] = 'attach://' + thumbnail_key
|
|
2197
2278
|
media.append(media_dict)
|
|
2198
2279
|
return json.dumps(media), files
|
|
2199
2280
|
|
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
|
@@ -4449,6 +4449,10 @@ class InlineQueryResultArticle(InlineQueryResultBase):
|
|
|
4449
4449
|
self.thumbnail_width: Optional[int] = thumbnail_width
|
|
4450
4450
|
self.thumbnail_height: Optional[int] = thumbnail_height
|
|
4451
4451
|
|
|
4452
|
+
if hide_url:
|
|
4453
|
+
log_deprecation_warning('The parameter "hide_url" is deprecated. Pass an empty string as url instead.')
|
|
4454
|
+
self.url = ''
|
|
4455
|
+
|
|
4452
4456
|
|
|
4453
4457
|
@property
|
|
4454
4458
|
def thumb_url(self) -> str:
|
|
@@ -6318,6 +6322,15 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6318
6322
|
:param invoice_payload: Bot specified invoice payload
|
|
6319
6323
|
:type invoice_payload: :obj:`str`
|
|
6320
6324
|
|
|
6325
|
+
:param subscription_expiration_date: Optional. Expiration date of the subscription, in Unix time; for recurring payments only
|
|
6326
|
+
:type subscription_expiration_date: :obj:`int`
|
|
6327
|
+
|
|
6328
|
+
:param is_recurring: Optional. True, if the payment is a recurring payment, false otherwise
|
|
6329
|
+
:type is_recurring: :obj:`bool`
|
|
6330
|
+
|
|
6331
|
+
:param is_first_recurring: Optional. True, if the payment is the first payment for a subscription
|
|
6332
|
+
:type is_first_recurring: :obj:`bool`
|
|
6333
|
+
|
|
6321
6334
|
:param shipping_option_id: Optional. Identifier of the shipping option chosen by the user
|
|
6322
6335
|
:type shipping_option_id: :obj:`str`
|
|
6323
6336
|
|
|
@@ -6341,7 +6354,8 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6341
6354
|
return cls(**obj)
|
|
6342
6355
|
|
|
6343
6356
|
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,
|
|
6357
|
+
telegram_payment_charge_id=None, provider_payment_charge_id=None,
|
|
6358
|
+
subscription_expiration_date=None, is_recurring=None, is_first_recurring=None, **kwargs):
|
|
6345
6359
|
self.currency: str = currency
|
|
6346
6360
|
self.total_amount: int = total_amount
|
|
6347
6361
|
self.invoice_payload: str = invoice_payload
|
|
@@ -6349,6 +6363,9 @@ class SuccessfulPayment(JsonDeserializable):
|
|
|
6349
6363
|
self.order_info: OrderInfo = order_info
|
|
6350
6364
|
self.telegram_payment_charge_id: str = telegram_payment_charge_id
|
|
6351
6365
|
self.provider_payment_charge_id: str = provider_payment_charge_id
|
|
6366
|
+
self.subscription_expiration_date: Optional[int] = subscription_expiration_date
|
|
6367
|
+
self.is_recurring: Optional[bool] = is_recurring
|
|
6368
|
+
self.is_first_recurring: Optional[bool] = is_first_recurring
|
|
6352
6369
|
|
|
6353
6370
|
|
|
6354
6371
|
# noinspection PyShadowingBuiltins
|
|
@@ -10398,6 +10415,8 @@ class TransactionPartner(JsonDeserializable):
|
|
|
10398
10415
|
return TransactionPartnerTelegramAds.de_json(obj)
|
|
10399
10416
|
elif obj["type"] == "telegram_api":
|
|
10400
10417
|
return TransactionPartnerTelegramApi.de_json(obj)
|
|
10418
|
+
elif obj["type"] == "affiliate_program":
|
|
10419
|
+
return TransactionPartnerAffiliateProgram.de_json(obj)
|
|
10401
10420
|
elif obj["type"] == "other":
|
|
10402
10421
|
return TransactionPartnerOther.de_json(obj)
|
|
10403
10422
|
|
|
@@ -10473,21 +10492,34 @@ class TransactionPartnerUser(TransactionPartner):
|
|
|
10473
10492
|
:param user: Information about the user
|
|
10474
10493
|
:type user: :class:`User`
|
|
10475
10494
|
|
|
10495
|
+
:param affiliate: Optional. Information about the affiliate that received a commission via this transaction
|
|
10496
|
+
:type affiliate: :class:`AffiliateInfo`
|
|
10497
|
+
|
|
10476
10498
|
:param invoice_payload: Optional, Bot-specified invoice payload
|
|
10477
10499
|
:type invoice_payload: :obj:`str`
|
|
10478
10500
|
|
|
10501
|
+
:param subscription_period: Optional. The duration of the paid subscription
|
|
10502
|
+
:type subscription_period: :obj:`int`
|
|
10503
|
+
|
|
10479
10504
|
:param paid_media: Optional. Information about the paid media bought by the user
|
|
10480
10505
|
:type paid_media: :obj:`list` of :class:`PaidMedia`
|
|
10481
10506
|
|
|
10507
|
+
:param gift: Optional. The gift sent to the user by the bot
|
|
10508
|
+
:type gift: :class:`Gift`
|
|
10509
|
+
|
|
10482
10510
|
:return: Instance of the class
|
|
10483
10511
|
:rtype: :class:`TransactionPartnerUser`
|
|
10484
10512
|
"""
|
|
10485
10513
|
|
|
10486
|
-
def __init__(self, type, user, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
|
|
10514
|
+
def __init__(self, type, user, affiliate=None, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
|
|
10515
|
+
subscription_period=None, gift: Optional[Gift] = None, **kwargs):
|
|
10487
10516
|
self.type: str = type
|
|
10488
10517
|
self.user: User = user
|
|
10518
|
+
self.affiliate: Optional[AffiliateInfo] = affiliate
|
|
10489
10519
|
self.invoice_payload: Optional[str] = invoice_payload
|
|
10490
10520
|
self.paid_media: Optional[List[PaidMedia]] = paid_media
|
|
10521
|
+
self.subscription_period: Optional[int] = subscription_period
|
|
10522
|
+
self.gift: Optional[Gift] = gift
|
|
10491
10523
|
|
|
10492
10524
|
@classmethod
|
|
10493
10525
|
def de_json(cls, json_string):
|
|
@@ -10496,6 +10528,10 @@ class TransactionPartnerUser(TransactionPartner):
|
|
|
10496
10528
|
obj['user'] = User.de_json(obj['user'])
|
|
10497
10529
|
if 'paid_media' in obj:
|
|
10498
10530
|
obj['paid_media'] = [PaidMedia.de_json(media) for media in obj['paid_media']]
|
|
10531
|
+
if 'gift' in obj:
|
|
10532
|
+
obj['gift'] = Gift.de_json(obj['gift'])
|
|
10533
|
+
if 'affiliate' in obj:
|
|
10534
|
+
obj['affiliate'] = AffiliateInfo.de_json(obj['affiliate'])
|
|
10499
10535
|
return cls(**obj)
|
|
10500
10536
|
|
|
10501
10537
|
|
|
@@ -10560,6 +10596,9 @@ class StarTransaction(JsonDeserializable):
|
|
|
10560
10596
|
:param amount: Number of Telegram Stars transferred by the transaction
|
|
10561
10597
|
:type amount: :obj:`int`
|
|
10562
10598
|
|
|
10599
|
+
:param nanostar_amount: Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
|
|
10600
|
+
:type nanostar_amount: :obj:`int`
|
|
10601
|
+
|
|
10563
10602
|
:param date: Date the transaction was created in Unix time
|
|
10564
10603
|
:type date: :obj:`int`
|
|
10565
10604
|
|
|
@@ -10583,12 +10622,13 @@ class StarTransaction(JsonDeserializable):
|
|
|
10583
10622
|
obj['receiver'] = TransactionPartner.de_json(obj['receiver'])
|
|
10584
10623
|
return cls(**obj)
|
|
10585
10624
|
|
|
10586
|
-
def __init__(self, id, amount, date, source=None, receiver=None, **kwargs):
|
|
10625
|
+
def __init__(self, id, amount, date, source=None, receiver=None, nanostar_amount=None, **kwargs):
|
|
10587
10626
|
self.id: str = id
|
|
10588
10627
|
self.amount: int = amount
|
|
10589
10628
|
self.date: int = date
|
|
10590
10629
|
self.source: Optional[TransactionPartner] = source
|
|
10591
10630
|
self.receiver: Optional[TransactionPartner] = receiver
|
|
10631
|
+
self.nanostar_amount: Optional[int] = nanostar_amount
|
|
10592
10632
|
|
|
10593
10633
|
|
|
10594
10634
|
class StarTransactions(JsonDeserializable):
|
|
@@ -10979,3 +11019,176 @@ class CopyTextButton(JsonSerializable, JsonDeserializable):
|
|
|
10979
11019
|
if json_string is None: return None
|
|
10980
11020
|
obj = cls.check_json(json_string)
|
|
10981
11021
|
return cls(**obj)
|
|
11022
|
+
|
|
11023
|
+
|
|
11024
|
+
class PreparedInlineMessage(JsonDeserializable):
|
|
11025
|
+
"""
|
|
11026
|
+
Describes an inline message to be sent by a user of a Mini App.
|
|
11027
|
+
|
|
11028
|
+
Telegram documentation: https://core.telegram.org/bots/api#preparedinlinemessage
|
|
11029
|
+
|
|
11030
|
+
:param id: Unique identifier of the prepared message
|
|
11031
|
+
:type id: :obj:`str`
|
|
11032
|
+
|
|
11033
|
+
:param expiration_date: Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used
|
|
11034
|
+
:type expiration_date: :obj:`int`
|
|
11035
|
+
|
|
11036
|
+
:return: Instance of the class
|
|
11037
|
+
:rtype: :class:`PreparedInlineMessage`
|
|
11038
|
+
"""
|
|
11039
|
+
|
|
11040
|
+
def __init__(self, id, expiration_date, **kwargs):
|
|
11041
|
+
self.id: str = id
|
|
11042
|
+
self.expiration_date: int = expiration_date
|
|
11043
|
+
|
|
11044
|
+
@classmethod
|
|
11045
|
+
def de_json(cls, json_string):
|
|
11046
|
+
if json_string is None: return None
|
|
11047
|
+
obj = cls.check_json(json_string)
|
|
11048
|
+
return cls(**obj)
|
|
11049
|
+
|
|
11050
|
+
|
|
11051
|
+
class Gift(JsonDeserializable):
|
|
11052
|
+
"""
|
|
11053
|
+
This object represents a gift that can be sent by the bot.
|
|
11054
|
+
|
|
11055
|
+
Telegram documentation: https://core.telegram.org/bots/api#gift
|
|
11056
|
+
|
|
11057
|
+
:param id: Unique identifier of the gift
|
|
11058
|
+
:type id: :obj:`str`
|
|
11059
|
+
|
|
11060
|
+
:param sticker: The sticker that represents the gift
|
|
11061
|
+
:type sticker: :class:`Sticker`
|
|
11062
|
+
|
|
11063
|
+
:param star_count: The number of Telegram Stars that must be paid to send the sticker
|
|
11064
|
+
:type star_count: :obj:`int`
|
|
11065
|
+
|
|
11066
|
+
:param upgrade_star_count: Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one
|
|
11067
|
+
:type upgrade_star_count: :obj:`int`
|
|
11068
|
+
|
|
11069
|
+
:param total_count: Optional. The total number of the gifts of this type that can be sent; for limited gifts only
|
|
11070
|
+
:type total_count: :obj:`int`
|
|
11071
|
+
|
|
11072
|
+
:param remaining_count: Optional. The number of remaining gifts of this type that can be sent; for limited gifts only
|
|
11073
|
+
:type remaining_count: :obj:`int`
|
|
11074
|
+
|
|
11075
|
+
:return: Instance of the class
|
|
11076
|
+
:rtype: :class:`Gift`
|
|
11077
|
+
"""
|
|
11078
|
+
|
|
11079
|
+
def __init__(self, id, sticker, star_count, total_count=None, remaining_count=None, upgrade_star_count=None, **kwargs):
|
|
11080
|
+
self.id: str = id
|
|
11081
|
+
self.sticker: Sticker = sticker
|
|
11082
|
+
self.star_count: int = star_count
|
|
11083
|
+
self.total_count: Optional[int] = total_count
|
|
11084
|
+
self.remaining_count: Optional[int] = remaining_count
|
|
11085
|
+
self.upgrade_star_count: Optional[int] = upgrade_star_count
|
|
11086
|
+
|
|
11087
|
+
@classmethod
|
|
11088
|
+
def de_json(cls, json_string):
|
|
11089
|
+
if json_string is None: return None
|
|
11090
|
+
obj = cls.check_json(json_string)
|
|
11091
|
+
obj['sticker'] = Sticker.de_json(obj['sticker'])
|
|
11092
|
+
return cls(**obj)
|
|
11093
|
+
|
|
11094
|
+
class Gifts(JsonDeserializable):
|
|
11095
|
+
"""
|
|
11096
|
+
This object represent a list of gifts.
|
|
11097
|
+
|
|
11098
|
+
Telegram documentation: https://core.telegram.org/bots/api#gifts
|
|
11099
|
+
|
|
11100
|
+
:param gifts: The list of gifts
|
|
11101
|
+
:type gifts: :obj:`list` of :class:`Gift`
|
|
11102
|
+
|
|
11103
|
+
:return: Instance of the class
|
|
11104
|
+
:rtype: :class:`Gifts`
|
|
11105
|
+
"""
|
|
11106
|
+
|
|
11107
|
+
def __init__(self, gifts, **kwargs):
|
|
11108
|
+
self.gifts: List[Gift] = gifts
|
|
11109
|
+
|
|
11110
|
+
@classmethod
|
|
11111
|
+
def de_json(cls, json_string):
|
|
11112
|
+
if json_string is None: return None
|
|
11113
|
+
obj = cls.check_json(json_string)
|
|
11114
|
+
obj['gifts'] = [Gift.de_json(gift) for gift in obj['gifts']]
|
|
11115
|
+
return cls(**obj)
|
|
11116
|
+
|
|
11117
|
+
|
|
11118
|
+
class TransactionPartnerAffiliateProgram(TransactionPartner):
|
|
11119
|
+
"""
|
|
11120
|
+
Describes the affiliate program that issued the affiliate commission received via this transaction.
|
|
11121
|
+
|
|
11122
|
+
Telegram documentation: https://core.telegram.org/bots/api#transactionpartneraffiliateprogram
|
|
11123
|
+
|
|
11124
|
+
:param type: Type of the transaction partner, always “affiliate_program”
|
|
11125
|
+
:type type: :obj:`str`
|
|
11126
|
+
|
|
11127
|
+
:param sponsor_user: Optional. Information about the bot that sponsored the affiliate program
|
|
11128
|
+
:type sponsor_user: :class:`User`
|
|
11129
|
+
|
|
11130
|
+
: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
|
|
11131
|
+
:type commission_per_mille: :obj:`int`
|
|
11132
|
+
|
|
11133
|
+
:return: Instance of the class
|
|
11134
|
+
:rtype: :class:`TransactionPartnerAffiliateProgram`
|
|
11135
|
+
"""
|
|
11136
|
+
|
|
11137
|
+
def __init__(self, type, commission_per_mille, sponsor_user=None, **kwargs):
|
|
11138
|
+
self.type: str = type
|
|
11139
|
+
self.sponsor_user: Optional[User] = sponsor_user
|
|
11140
|
+
self.commission_per_mille: int = commission_per_mille
|
|
11141
|
+
|
|
11142
|
+
@classmethod
|
|
11143
|
+
def de_json(cls, json_string):
|
|
11144
|
+
if json_string is None: return None
|
|
11145
|
+
obj = cls.check_json(json_string)
|
|
11146
|
+
if 'sponsor_user' in obj:
|
|
11147
|
+
obj['sponsor_user'] = User.de_json(obj['sponsor_user'])
|
|
11148
|
+
|
|
11149
|
+
return cls(**obj)
|
|
11150
|
+
|
|
11151
|
+
|
|
11152
|
+
class AffiliateInfo(JsonDeserializable):
|
|
11153
|
+
"""
|
|
11154
|
+
Contains information about the affiliate that received a commission via this transaction.
|
|
11155
|
+
|
|
11156
|
+
Telegram documentation: https://core.telegram.org/bots/api#affiliateinfo
|
|
11157
|
+
|
|
11158
|
+
:param affiliate_user: Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
|
|
11159
|
+
:type affiliate_user: :class:`User`
|
|
11160
|
+
|
|
11161
|
+
:param affiliate_chat: Optional. The chat that received an affiliate commission if it was received by a chat
|
|
11162
|
+
:type affiliate_chat: :class:`Chat`
|
|
11163
|
+
|
|
11164
|
+
: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
|
|
11165
|
+
:type commission_per_mille: :obj:`int`
|
|
11166
|
+
|
|
11167
|
+
:param amount: Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
|
|
11168
|
+
:type amount: :obj:`int`
|
|
11169
|
+
|
|
11170
|
+
: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
|
|
11171
|
+
:type nanostar_amount: :obj:`int`
|
|
11172
|
+
|
|
11173
|
+
:return: Instance of the class
|
|
11174
|
+
:rtype: :class:`AffiliateInfo`
|
|
11175
|
+
"""
|
|
11176
|
+
|
|
11177
|
+
def __init__(self, commission_per_mille, amount, affiliate_user=None, affiliate_chat=None, nanostar_amount=None, **kwargs):
|
|
11178
|
+
self.affiliate_user: Optional[User] = affiliate_user
|
|
11179
|
+
self.affiliate_chat: Optional[Chat] = affiliate_chat
|
|
11180
|
+
self.commission_per_mille: int = commission_per_mille
|
|
11181
|
+
self.amount: int = amount
|
|
11182
|
+
self.nanostar_amount: Optional[int] = nanostar_amount
|
|
11183
|
+
|
|
11184
|
+
@classmethod
|
|
11185
|
+
def de_json(cls, json_string):
|
|
11186
|
+
if json_string is None: return None
|
|
11187
|
+
obj = cls.check_json(json_string)
|
|
11188
|
+
if 'affiliate_user' in obj:
|
|
11189
|
+
obj['affiliate_user'] = User.de_json(obj['affiliate_user'])
|
|
11190
|
+
if 'affiliate_chat' in obj:
|
|
11191
|
+
obj['affiliate_chat'] = Chat.de_json(obj['affiliate_chat'])
|
|
11192
|
+
return cls(**obj)
|
|
11193
|
+
|
|
11194
|
+
|
telebot/version.py
CHANGED
|
File without changes
|