pyTelegramBotAPI 4.21.0__py3-none-any.whl → 4.22.1__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.21.0.dist-info → pytelegrambotapi-4.22.1.dist-info}/METADATA +2 -4
- pytelegrambotapi-4.22.1.dist-info/RECORD +41 -0
- telebot/__init__.py +142 -27
- telebot/apihelper.py +6 -2
- telebot/async_telebot.py +145 -29
- telebot/asyncio_filters.py +450 -454
- telebot/asyncio_handler_backends.py +98 -137
- telebot/asyncio_helper.py +6 -2
- telebot/asyncio_storage/__init__.py +13 -13
- telebot/asyncio_storage/base_storage.py +123 -68
- telebot/asyncio_storage/memory_storage.py +225 -66
- telebot/asyncio_storage/pickle_storage.py +274 -110
- telebot/asyncio_storage/redis_storage.py +339 -179
- telebot/custom_filters.py +21 -28
- telebot/formatting.py +474 -463
- telebot/handler_backends.py +258 -295
- telebot/states/__init__.py +128 -0
- telebot/states/asyncio/__init__.py +7 -0
- telebot/states/asyncio/context.py +153 -0
- telebot/states/asyncio/middleware.py +21 -0
- telebot/states/sync/__init__.py +7 -0
- telebot/states/sync/context.py +143 -0
- telebot/states/sync/middleware.py +21 -0
- telebot/storage/__init__.py +13 -13
- telebot/storage/base_storage.py +118 -68
- telebot/storage/memory_storage.py +225 -69
- telebot/storage/pickle_storage.py +263 -116
- telebot/storage/redis_storage.py +324 -183
- telebot/types.py +670 -589
- telebot/util.py +720 -700
- telebot/version.py +1 -1
- pytelegrambotapi-4.21.0.dist-info/RECORD +0 -34
- {pytelegrambotapi-4.21.0.dist-info → pytelegrambotapi-4.22.1.dist-info}/WHEEL +0 -0
- {pytelegrambotapi-4.21.0.dist-info → pytelegrambotapi-4.22.1.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.22.1
|
|
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
|
|
@@ -23,8 +23,6 @@ Requires-Python: >=3.8
|
|
|
23
23
|
Requires-Dist: requests
|
|
24
24
|
Provides-Extra: aiohttp
|
|
25
25
|
Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
26
|
-
Provides-Extra: aioredis
|
|
27
|
-
Requires-Dist: aioredis; extra == 'aioredis'
|
|
28
26
|
Provides-Extra: coloredlogs
|
|
29
27
|
Requires-Dist: coloredlogs; extra == 'coloredlogs'
|
|
30
28
|
Provides-Extra: fastapi
|
|
@@ -55,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
55
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>
|
|
56
54
|
<p align="center">Both synchronous and asynchronous.</p>
|
|
57
55
|
|
|
58
|
-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#july-
|
|
56
|
+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api-changelog#july-31-2024"><img src="https://img.shields.io/badge/Bot%20API-7.8-blue?logo=telegram" alt="Supported Bot API version"></a>
|
|
59
57
|
|
|
60
58
|
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
|
|
61
59
|
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
telebot/__init__.py,sha256=ty7WzdASNMWG_cqdg4o3A-kagN9aVIGkc0j93R9reT4,412119
|
|
2
|
+
telebot/apihelper.py,sha256=FJwcuzZXK54GqNmUiziobpbgrN5pwk_LcPBbkhlINf4,94286
|
|
3
|
+
telebot/async_telebot.py,sha256=N5vCHak84CCjxZJCehus8eRt1TaSmUlRyzzAw_ONqYk,385225
|
|
4
|
+
telebot/asyncio_filters.py,sha256=0bnF-CPOX-IZUIjViTk5lxa5OR_UxB8Z5ng0kfDq5nM,12856
|
|
5
|
+
telebot/asyncio_handler_backends.py,sha256=BWS7zr93FJNZJmPHBoXo4i_PIHGlmrEoWy1miXax9aI,2785
|
|
6
|
+
telebot/asyncio_helper.py,sha256=Wvd8i8KFqGizkyaL7xZfb4Woan1yphoQGFYHvdErKyw,95049
|
|
7
|
+
telebot/callback_data.py,sha256=k4Rz3lAONG5J2M9TESKMIjqXoBNJMfEy9nnrmJAyi3Q,5358
|
|
8
|
+
telebot/custom_filters.py,sha256=0NX8hR5EMGjOnl11sLPYwl9gwIxd9APTsxqBhxCASLM,12977
|
|
9
|
+
telebot/formatting.py,sha256=_y8M5KOv9UOXfF9z7Et4fPVgh9JnzI1cr4un9sfdlc0,15176
|
|
10
|
+
telebot/handler_backends.py,sha256=lyKu0PaH2c4y5FfyQS3M9tOyBJ8ATjxHZkATzu01XpE,7969
|
|
11
|
+
telebot/service_utils.py,sha256=xLmlZLTVs34UOdQtMvwduor8hnLxQCx8iJ92wDGl2Mw,2053
|
|
12
|
+
telebot/types.py,sha256=KiKe3WnBAGCN_65Uxe104IGG77cvpUthTzlEjwnc0r4,459391
|
|
13
|
+
telebot/util.py,sha256=YLSNl9LYEmj7PxNgZN5OO3IvtR5YESvVfTsReuxZ9Zw,21361
|
|
14
|
+
telebot/version.py,sha256=dvJgb3UnEA3MSfEPGopCGapphKRx6FGNQqRhsbEch3o,99
|
|
15
|
+
telebot/asyncio_storage/__init__.py,sha256=fraOWJby1ddJmPAXf1oXWmZJXRodSpING17MF875NPI,433
|
|
16
|
+
telebot/asyncio_storage/base_storage.py,sha256=I-NII9ZMCxCHStPc-73qSyQhjBtkhNzb2IcZPhjR1Eg,3243
|
|
17
|
+
telebot/asyncio_storage/memory_storage.py,sha256=h8yc2xpfLmbcBjPmKkqNhZtUtpNQ7EuKIfMGue61e7w,5849
|
|
18
|
+
telebot/asyncio_storage/pickle_storage.py,sha256=3uaQGw6jF1kF7x-qLq1VIGjya2hcEY1J9HAouDuXH4U,7647
|
|
19
|
+
telebot/asyncio_storage/redis_storage.py,sha256=ruhh1jPUf0YHQWfg_QAHPEn8Vm9cvBwkybD5R7GSUDw,9897
|
|
20
|
+
telebot/ext/__init__.py,sha256=_mSeNU1cib3cWSZ6Kb6nKy9znEYwEzGNRCYZsD61rLk,66
|
|
21
|
+
telebot/ext/reloader.py,sha256=vzmJxCsA_COHF-bpmyddDuUXroxNih051IYRMiR21LY,826
|
|
22
|
+
telebot/ext/aio/__init__.py,sha256=2yi7jtvEIH1DqAseFevfujNYi7ZSh5aPMOKGrxIgqsw,143
|
|
23
|
+
telebot/ext/aio/webhooks.py,sha256=tf4DMXkKWvM_Uko_lpLRc0uDwttyZGvsvDLNNbwmO_Y,3788
|
|
24
|
+
telebot/ext/sync/__init__.py,sha256=Lj-15dj1TYkf11d0vY14_2mssnoFR5Uk320huWa_rGc,140
|
|
25
|
+
telebot/ext/sync/webhooks.py,sha256=XMMhXnDuFs7CWJ7iDi11H0dwf6fRA4pbAjFjNgNJ18Y,3513
|
|
26
|
+
telebot/states/__init__.py,sha256=ggLBEJyMoh3i_IDpUE_jvtP7NiC7IwIR4QJXmI1BFGc,4401
|
|
27
|
+
telebot/states/asyncio/__init__.py,sha256=vomgAmaY590Ul0U-oovN7-Vjf6CwrchmjAZS8PX-lqY,132
|
|
28
|
+
telebot/states/asyncio/context.py,sha256=LeH1uD3NSkQ6EJ-rsSfJfA1SaQ_FnoPRWg746SwOhFI,4952
|
|
29
|
+
telebot/states/asyncio/middleware.py,sha256=UZgd4Ty8JwOcj50zdI8eJ0tfPCmgiymxyaX-dR2tpVg,730
|
|
30
|
+
telebot/states/sync/__init__.py,sha256=FqxubuunwknusMEAkaUwgFdIBmTZtEhRUaRZE18bzzs,131
|
|
31
|
+
telebot/states/sync/context.py,sha256=mw19DPMSqPsg8e-i3ZVsp-YxZSfHfn1rpisn5smvfrM,4731
|
|
32
|
+
telebot/states/sync/middleware.py,sha256=7mGC0xEQt7vjfCgmJWOKn7BXHxjQyLFoyZ1rL0blm4Q,680
|
|
33
|
+
telebot/storage/__init__.py,sha256=Uagoo-sNYA0PX-hICKSaXtr4YRUOp2GPwlK1vlap9O8,401
|
|
34
|
+
telebot/storage/base_storage.py,sha256=WzGgSflKzcn2ENsgz1Q-D_v-ZKCtnMOURGOHIwNJ0WU,2986
|
|
35
|
+
telebot/storage/memory_storage.py,sha256=-r1vuIt1YHq9btkr6E7BCu4Do-wUDlNcttG22SSgEYo,5799
|
|
36
|
+
telebot/storage/pickle_storage.py,sha256=dqw7syOJuTWyU0KK8XwbJvQ9PMyDHhZQG-MevZImEak,7121
|
|
37
|
+
telebot/storage/redis_storage.py,sha256=DReU2lc8cI0f3XMIT1N9-suGZ6jE8H9I_mapK3A-lyE,9450
|
|
38
|
+
pytelegrambotapi-4.22.1.dist-info/METADATA,sha256=ECBI-3IKxlXtRMzbmXv11FBTUOlP67NghcrAvQArhTk,48162
|
|
39
|
+
pytelegrambotapi-4.22.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
40
|
+
pytelegrambotapi-4.22.1.dist-info/licenses/LICENSE,sha256=qz_jTTxi4zSAFaTdASiwml2iAk0UZ6R4MRADNzwYo_A,18387
|
|
41
|
+
pytelegrambotapi-4.22.1.dist-info/RECORD,,
|
telebot/__init__.py
CHANGED
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
import threading
|
|
8
8
|
import time
|
|
9
9
|
import traceback
|
|
10
|
-
from typing import Any, Callable, List, Optional, Union
|
|
10
|
+
from typing import Any, Callable, List, Optional, Union, Dict
|
|
11
11
|
|
|
12
12
|
# these imports are used to avoid circular import error
|
|
13
13
|
import telebot.util
|
|
@@ -152,9 +152,14 @@ class TeleBot:
|
|
|
152
152
|
:param allow_sending_without_reply: Default value for allow_sending_without_reply, defaults to None
|
|
153
153
|
:type allow_sending_without_reply: :obj:`bool`, optional
|
|
154
154
|
|
|
155
|
-
|
|
156
155
|
:param colorful_logs: Outputs colorful logs
|
|
157
156
|
:type colorful_logs: :obj:`bool`, optional
|
|
157
|
+
|
|
158
|
+
:param validate_token: Validate token, defaults to True;
|
|
159
|
+
:type validate_token: :obj:`bool`, optional
|
|
160
|
+
|
|
161
|
+
:raises ImportError: If coloredlogs module is not installed and colorful_logs is True
|
|
162
|
+
:raises ValueError: If token is invalid
|
|
158
163
|
"""
|
|
159
164
|
|
|
160
165
|
def __init__(
|
|
@@ -168,7 +173,8 @@ class TeleBot:
|
|
|
168
173
|
disable_notification: Optional[bool]=None,
|
|
169
174
|
protect_content: Optional[bool]=None,
|
|
170
175
|
allow_sending_without_reply: Optional[bool]=None,
|
|
171
|
-
colorful_logs: Optional[bool]=False
|
|
176
|
+
colorful_logs: Optional[bool]=False,
|
|
177
|
+
validate_token: Optional[bool]=True
|
|
172
178
|
):
|
|
173
179
|
|
|
174
180
|
# update-related
|
|
@@ -186,6 +192,11 @@ class TeleBot:
|
|
|
186
192
|
self.webhook_listener = None
|
|
187
193
|
self._user = None
|
|
188
194
|
|
|
195
|
+
if validate_token:
|
|
196
|
+
util.validate_token(self.token)
|
|
197
|
+
|
|
198
|
+
self.bot_id: Union[int, None] = util.extract_bot_id(self.token) # subject to change in future, unspecified
|
|
199
|
+
|
|
189
200
|
# logs-related
|
|
190
201
|
if colorful_logs:
|
|
191
202
|
try:
|
|
@@ -280,7 +291,7 @@ class TeleBot:
|
|
|
280
291
|
self.threaded = threaded
|
|
281
292
|
if self.threaded:
|
|
282
293
|
self.worker_pool = util.ThreadPool(self, num_threads=num_threads)
|
|
283
|
-
|
|
294
|
+
|
|
284
295
|
@property
|
|
285
296
|
def user(self) -> types.User:
|
|
286
297
|
"""
|
|
@@ -4640,7 +4651,7 @@ class TeleBot:
|
|
|
4640
4651
|
|
|
4641
4652
|
def pin_chat_message(
|
|
4642
4653
|
self, chat_id: Union[int, str], message_id: int,
|
|
4643
|
-
disable_notification: Optional[bool]=False) -> bool:
|
|
4654
|
+
disable_notification: Optional[bool]=False, business_connection_id: Optional[str]=None) -> bool:
|
|
4644
4655
|
"""
|
|
4645
4656
|
Use this method to pin a message in a supergroup.
|
|
4646
4657
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
|
@@ -4659,15 +4670,19 @@ class TeleBot:
|
|
|
4659
4670
|
to all group members about the new pinned message
|
|
4660
4671
|
:type disable_notification: :obj:`bool`
|
|
4661
4672
|
|
|
4673
|
+
:param business_connection_id: Unique identifier of the business connection
|
|
4674
|
+
:type business_connection_id: :obj:`str`
|
|
4675
|
+
|
|
4662
4676
|
:return: True on success.
|
|
4663
4677
|
:rtype: :obj:`bool`
|
|
4664
4678
|
"""
|
|
4665
4679
|
disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
|
|
4666
4680
|
|
|
4667
|
-
return apihelper.pin_chat_message(self.token, chat_id, message_id, disable_notification=disable_notification
|
|
4681
|
+
return apihelper.pin_chat_message(self.token, chat_id, message_id, disable_notification=disable_notification,
|
|
4682
|
+
business_connection_id=business_connection_id)
|
|
4668
4683
|
|
|
4669
4684
|
|
|
4670
|
-
def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None) -> bool:
|
|
4685
|
+
def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None, business_connection_id: Optional[str]=None) -> bool:
|
|
4671
4686
|
"""
|
|
4672
4687
|
Use this method to unpin specific pinned message in a supergroup chat.
|
|
4673
4688
|
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
|
@@ -4682,10 +4697,13 @@ class TeleBot:
|
|
|
4682
4697
|
:param message_id: Int: Identifier of a message to unpin
|
|
4683
4698
|
:type message_id: :obj:`int`
|
|
4684
4699
|
|
|
4700
|
+
:param business_connection_id: Unique identifier of the business connection
|
|
4701
|
+
:type business_connection_id: :obj:`str`
|
|
4702
|
+
|
|
4685
4703
|
:return: True on success.
|
|
4686
4704
|
:rtype: :obj:`bool`
|
|
4687
4705
|
"""
|
|
4688
|
-
return apihelper.unpin_chat_message(self.token, chat_id, message_id)
|
|
4706
|
+
return apihelper.unpin_chat_message(self.token, chat_id, message_id, business_connection_id=business_connection_id)
|
|
4689
4707
|
|
|
4690
4708
|
|
|
4691
4709
|
def unpin_all_chat_messages(self, chat_id: Union[int, str]) -> bool:
|
|
@@ -6634,7 +6652,9 @@ class TeleBot:
|
|
|
6634
6652
|
self.middlewares.append(middleware)
|
|
6635
6653
|
|
|
6636
6654
|
|
|
6637
|
-
def set_state(self, user_id: int, state: Union[
|
|
6655
|
+
def set_state(self, user_id: int, state: Union[str, State], chat_id: Optional[int]=None,
|
|
6656
|
+
business_connection_id: Optional[str]=None, message_thread_id: Optional[int]=None,
|
|
6657
|
+
bot_id: Optional[int]=None) -> bool:
|
|
6638
6658
|
"""
|
|
6639
6659
|
Sets a new state of a user.
|
|
6640
6660
|
|
|
@@ -6644,25 +6664,49 @@ class TeleBot:
|
|
|
6644
6664
|
Otherwise, if you only set user_id, chat_id will equal to user_id, this means that
|
|
6645
6665
|
state will be set for the user in his private chat with a bot.
|
|
6646
6666
|
|
|
6667
|
+
.. versionchanged:: 4.23.0
|
|
6668
|
+
|
|
6669
|
+
Added additional parameters to support topics, business connections, and message threads.
|
|
6670
|
+
|
|
6671
|
+
.. seealso::
|
|
6672
|
+
|
|
6673
|
+
For more details, visit the `custom_states.py example <https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/custom_states.py>`_.
|
|
6674
|
+
|
|
6647
6675
|
:param user_id: User's identifier
|
|
6648
6676
|
:type user_id: :obj:`int`
|
|
6649
6677
|
|
|
6650
|
-
:param state: new state. can be string,
|
|
6678
|
+
:param state: new state. can be string, or :class:`telebot.types.State`
|
|
6651
6679
|
:type state: :obj:`int` or :obj:`str` or :class:`telebot.types.State`
|
|
6652
6680
|
|
|
6653
6681
|
:param chat_id: Chat's identifier
|
|
6654
6682
|
:type chat_id: :obj:`int`
|
|
6655
6683
|
|
|
6656
|
-
:
|
|
6684
|
+
:param bot_id: Bot's identifier, defaults to current bot id
|
|
6685
|
+
:type bot_id: :obj:`int`
|
|
6686
|
+
|
|
6687
|
+
:param business_connection_id: Business identifier
|
|
6688
|
+
:type business_connection_id: :obj:`str`
|
|
6689
|
+
|
|
6690
|
+
:param message_thread_id: Identifier of the message thread
|
|
6691
|
+
:type message_thread_id: :obj:`int`
|
|
6692
|
+
|
|
6693
|
+
:return: True on success
|
|
6694
|
+
:rtype: :obj:`bool`
|
|
6657
6695
|
"""
|
|
6658
6696
|
if chat_id is None:
|
|
6659
6697
|
chat_id = user_id
|
|
6660
|
-
|
|
6698
|
+
if bot_id is None:
|
|
6699
|
+
bot_id = self.bot_id
|
|
6700
|
+
return self.current_states.set_state(
|
|
6701
|
+
chat_id=chat_id, user_id=user_id, state=state, bot_id=bot_id,
|
|
6702
|
+
business_connection_id=business_connection_id, message_thread_id=message_thread_id)
|
|
6661
6703
|
|
|
6662
6704
|
|
|
6663
|
-
def reset_data(self, user_id: int, chat_id: Optional[int]=None
|
|
6705
|
+
def reset_data(self, user_id: int, chat_id: Optional[int]=None,
|
|
6706
|
+
business_connection_id: Optional[str]=None,
|
|
6707
|
+
message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> bool:
|
|
6664
6708
|
"""
|
|
6665
|
-
Reset data for a user in chat.
|
|
6709
|
+
Reset data for a user in chat: sets the 'data' field to an empty dictionary.
|
|
6666
6710
|
|
|
6667
6711
|
:param user_id: User's identifier
|
|
6668
6712
|
:type user_id: :obj:`int`
|
|
@@ -6670,16 +6714,34 @@ class TeleBot:
|
|
|
6670
6714
|
:param chat_id: Chat's identifier
|
|
6671
6715
|
:type chat_id: :obj:`int`
|
|
6672
6716
|
|
|
6673
|
-
:
|
|
6717
|
+
:param bot_id: Bot's identifier, defaults to current bot id
|
|
6718
|
+
:type bot_id: :obj:`int`
|
|
6719
|
+
|
|
6720
|
+
:param business_connection_id: Business identifier
|
|
6721
|
+
:type business_connection_id: :obj:`str`
|
|
6722
|
+
|
|
6723
|
+
:param message_thread_id: Identifier of the message thread
|
|
6724
|
+
:type message_thread_id: :obj:`int`
|
|
6725
|
+
|
|
6726
|
+
:return: True on success
|
|
6727
|
+
:rtype: :obj:`bool`
|
|
6674
6728
|
"""
|
|
6675
6729
|
if chat_id is None:
|
|
6676
6730
|
chat_id = user_id
|
|
6677
|
-
|
|
6731
|
+
if bot_id is None:
|
|
6732
|
+
bot_id = self.bot_id
|
|
6733
|
+
return self.current_states.reset_data(chat_id=chat_id, user_id=user_id, bot_id=bot_id,
|
|
6734
|
+
business_connection_id=business_connection_id, message_thread_id=message_thread_id)
|
|
6678
6735
|
|
|
6679
6736
|
|
|
6680
|
-
def delete_state(self, user_id: int, chat_id: Optional[int]=None
|
|
6737
|
+
def delete_state(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None,
|
|
6738
|
+
message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> bool:
|
|
6681
6739
|
"""
|
|
6682
|
-
|
|
6740
|
+
Fully deletes the storage record of a user in chat.
|
|
6741
|
+
|
|
6742
|
+
.. warning::
|
|
6743
|
+
|
|
6744
|
+
This does NOT set state to None, but deletes the object from storage.
|
|
6683
6745
|
|
|
6684
6746
|
:param user_id: User's identifier
|
|
6685
6747
|
:type user_id: :obj:`int`
|
|
@@ -6687,14 +6749,19 @@ class TeleBot:
|
|
|
6687
6749
|
:param chat_id: Chat's identifier
|
|
6688
6750
|
:type chat_id: :obj:`int`
|
|
6689
6751
|
|
|
6690
|
-
:return:
|
|
6752
|
+
:return: True on success
|
|
6753
|
+
:rtype: :obj:`bool`
|
|
6691
6754
|
"""
|
|
6692
6755
|
if chat_id is None:
|
|
6693
6756
|
chat_id = user_id
|
|
6694
|
-
|
|
6757
|
+
if bot_id is None:
|
|
6758
|
+
bot_id = self.bot_id
|
|
6759
|
+
return self.current_states.delete_state(chat_id=chat_id, user_id=user_id, bot_id=bot_id,
|
|
6760
|
+
business_connection_id=business_connection_id, message_thread_id=message_thread_id)
|
|
6695
6761
|
|
|
6696
6762
|
|
|
6697
|
-
def retrieve_data(self, user_id: int, chat_id: Optional[int]=None
|
|
6763
|
+
def retrieve_data(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None,
|
|
6764
|
+
message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> Optional[Dict[str, Any]]:
|
|
6698
6765
|
"""
|
|
6699
6766
|
Returns context manager with data for a user in chat.
|
|
6700
6767
|
|
|
@@ -6704,34 +6771,70 @@ class TeleBot:
|
|
|
6704
6771
|
:param chat_id: Chat's unique identifier, defaults to user_id
|
|
6705
6772
|
:type chat_id: int, optional
|
|
6706
6773
|
|
|
6774
|
+
:param bot_id: Bot's identifier, defaults to current bot id
|
|
6775
|
+
:type bot_id: int, optional
|
|
6776
|
+
|
|
6777
|
+
:param business_connection_id: Business identifier
|
|
6778
|
+
:type business_connection_id: str, optional
|
|
6779
|
+
|
|
6780
|
+
:param message_thread_id: Identifier of the message thread
|
|
6781
|
+
:type message_thread_id: int, optional
|
|
6782
|
+
|
|
6707
6783
|
:return: Context manager with data for a user in chat
|
|
6708
6784
|
:rtype: Optional[Any]
|
|
6709
6785
|
"""
|
|
6710
6786
|
if chat_id is None:
|
|
6711
6787
|
chat_id = user_id
|
|
6712
|
-
|
|
6788
|
+
if bot_id is None:
|
|
6789
|
+
bot_id = self.bot_id
|
|
6790
|
+
return self.current_states.get_interactive_data(chat_id=chat_id, user_id=user_id, bot_id=bot_id,
|
|
6791
|
+
business_connection_id=business_connection_id,
|
|
6792
|
+
message_thread_id=message_thread_id)
|
|
6713
6793
|
|
|
6714
6794
|
|
|
6715
|
-
def get_state(self, user_id: int, chat_id: Optional[int]=None
|
|
6795
|
+
def get_state(self, user_id: int, chat_id: Optional[int]=None,
|
|
6796
|
+
business_connection_id: Optional[str]=None,
|
|
6797
|
+
message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> str:
|
|
6716
6798
|
"""
|
|
6717
6799
|
Gets current state of a user.
|
|
6718
6800
|
Not recommended to use this method. But it is ok for debugging.
|
|
6719
6801
|
|
|
6802
|
+
.. warning::
|
|
6803
|
+
|
|
6804
|
+
Even if you are using :class:`telebot.types.State`, this method will return a string.
|
|
6805
|
+
When comparing(not recommended), you should compare this string with :class:`telebot.types.State`.name
|
|
6806
|
+
|
|
6720
6807
|
:param user_id: User's identifier
|
|
6721
6808
|
:type user_id: :obj:`int`
|
|
6722
6809
|
|
|
6723
6810
|
:param chat_id: Chat's identifier
|
|
6724
6811
|
:type chat_id: :obj:`int`
|
|
6725
6812
|
|
|
6813
|
+
:param bot_id: Bot's identifier, defaults to current bot id
|
|
6814
|
+
:type bot_id: :obj:`int`
|
|
6815
|
+
|
|
6816
|
+
:param business_connection_id: Business identifier
|
|
6817
|
+
:type business_connection_id: :obj:`str`
|
|
6818
|
+
|
|
6819
|
+
:param message_thread_id: Identifier of the message thread
|
|
6820
|
+
:type message_thread_id: :obj:`int`
|
|
6821
|
+
|
|
6726
6822
|
:return: state of a user
|
|
6727
6823
|
:rtype: :obj:`int` or :obj:`str` or :class:`telebot.types.State`
|
|
6728
6824
|
"""
|
|
6729
6825
|
if chat_id is None:
|
|
6730
6826
|
chat_id = user_id
|
|
6731
|
-
|
|
6827
|
+
if bot_id is None:
|
|
6828
|
+
bot_id = self.bot_id
|
|
6829
|
+
return self.current_states.get_state(chat_id=chat_id, user_id=user_id, bot_id=bot_id,
|
|
6830
|
+
business_connection_id=business_connection_id, message_thread_id=message_thread_id)
|
|
6732
6831
|
|
|
6733
6832
|
|
|
6734
|
-
def add_data(self, user_id: int, chat_id: Optional[int]=None,
|
|
6833
|
+
def add_data(self, user_id: int, chat_id: Optional[int]=None,
|
|
6834
|
+
business_connection_id: Optional[str]=None,
|
|
6835
|
+
message_thread_id: Optional[int]=None,
|
|
6836
|
+
bot_id: Optional[int]=None,
|
|
6837
|
+
**kwargs) -> None:
|
|
6735
6838
|
"""
|
|
6736
6839
|
Add data to states.
|
|
6737
6840
|
|
|
@@ -6741,13 +6844,25 @@ class TeleBot:
|
|
|
6741
6844
|
:param chat_id: Chat's identifier
|
|
6742
6845
|
:type chat_id: :obj:`int`
|
|
6743
6846
|
|
|
6847
|
+
:param bot_id: Bot's identifier, defaults to current bot id
|
|
6848
|
+
:type bot_id: :obj:`int`
|
|
6849
|
+
|
|
6850
|
+
:param business_connection_id: Business identifier
|
|
6851
|
+
:type business_connection_id: :obj:`str`
|
|
6852
|
+
|
|
6853
|
+
:param message_thread_id: Identifier of the message thread
|
|
6854
|
+
:type message_thread_id: :obj:`int`
|
|
6855
|
+
|
|
6744
6856
|
:param kwargs: Data to add
|
|
6745
6857
|
:return: None
|
|
6746
6858
|
"""
|
|
6747
6859
|
if chat_id is None:
|
|
6748
6860
|
chat_id = user_id
|
|
6861
|
+
if bot_id is None:
|
|
6862
|
+
bot_id = self.bot_id
|
|
6749
6863
|
for key, value in kwargs.items():
|
|
6750
|
-
self.current_states.set_data(chat_id, user_id, key, value
|
|
6864
|
+
self.current_states.set_data(chat_id=chat_id, user_id=user_id, key=key, value=value, bot_id=bot_id,
|
|
6865
|
+
business_connection_id=business_connection_id, message_thread_id=message_thread_id)
|
|
6751
6866
|
|
|
6752
6867
|
|
|
6753
6868
|
def register_next_step_handler_by_chat_id(
|
|
@@ -7700,7 +7815,7 @@ class TeleBot:
|
|
|
7700
7815
|
self.add_chosen_inline_handler(handler_dict)
|
|
7701
7816
|
|
|
7702
7817
|
|
|
7703
|
-
def callback_query_handler(self, func, **kwargs):
|
|
7818
|
+
def callback_query_handler(self, func=None, **kwargs):
|
|
7704
7819
|
"""
|
|
7705
7820
|
Handles new incoming callback query.
|
|
7706
7821
|
As a parameter to the decorator function, it passes :class:`telebot.types.CallbackQuery` object.
|
telebot/apihelper.py
CHANGED
|
@@ -1386,19 +1386,23 @@ def set_chat_description(token, chat_id, description):
|
|
|
1386
1386
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1387
1387
|
|
|
1388
1388
|
|
|
1389
|
-
def pin_chat_message(token, chat_id, message_id, disable_notification=None):
|
|
1389
|
+
def pin_chat_message(token, chat_id, message_id, disable_notification=None, business_connection_id=None):
|
|
1390
1390
|
method_url = 'pinChatMessage'
|
|
1391
1391
|
payload = {'chat_id': chat_id, 'message_id': message_id}
|
|
1392
1392
|
if disable_notification is not None:
|
|
1393
1393
|
payload['disable_notification'] = disable_notification
|
|
1394
|
+
if business_connection_id:
|
|
1395
|
+
payload['business_connection_id'] = business_connection_id
|
|
1394
1396
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1395
1397
|
|
|
1396
1398
|
|
|
1397
|
-
def unpin_chat_message(token, chat_id, message_id):
|
|
1399
|
+
def unpin_chat_message(token, chat_id, message_id, business_connection_id=None):
|
|
1398
1400
|
method_url = 'unpinChatMessage'
|
|
1399
1401
|
payload = {'chat_id': chat_id}
|
|
1400
1402
|
if message_id:
|
|
1401
1403
|
payload['message_id'] = message_id
|
|
1404
|
+
if business_connection_id:
|
|
1405
|
+
payload['business_connection_id'] = business_connection_id
|
|
1402
1406
|
return _make_request(token, method_url, params=payload, method='post')
|
|
1403
1407
|
|
|
1404
1408
|
|