Pytdbot 0.9.5.dev0__tar.gz → 0.9.6.dev0__tar.gz
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.
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/PKG-INFO +2 -2
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/Pytdbot.egg-info/PKG-INFO +2 -2
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/README.md +1 -1
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/__init__.py +1 -1
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/client.py +85 -50
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/methods/methods.py +6 -1
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/methods/td_functions.py +296 -4
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/__init__.py +33 -3
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/types.py +4484 -23
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/tdserver/schedule.py +11 -11
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/LICENSE +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/MANIFEST.in +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/Pytdbot.egg-info/SOURCES.txt +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/Pytdbot.egg-info/dependency_links.txt +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/Pytdbot.egg-info/requires.txt +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/Pytdbot.egg-info/top_level.txt +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/client_manager.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/exception/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/filters.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/handlers/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/handlers/decorators.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/handlers/handler.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/handlers/td_updates.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/methods/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/tdjson/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/tdjson/tdjson.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/plugins/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/bound_methods/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/bound_methods/callback_query.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/bound_methods/chatActions.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/bound_methods/file.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/td_types/bound_methods/message.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/tdserver/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/types/tdserver/stats.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/__init__.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/asyncio_utils.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/escape.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/json_utils.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/obj_encoder.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/strings.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/text_format.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/pytdbot/utils/webapps.py +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/requirements.txt +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/setup.cfg +0 -0
- {pytdbot-0.9.5.dev0 → pytdbot-0.9.6.dev0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Pytdbot
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.6.dev0
|
|
4
4
|
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
5
|
Home-page: https://github.com/pytdbot/client
|
|
6
6
|
Author: AYMEN Mohammed
|
|
@@ -30,7 +30,7 @@ Dynamic: requires-dist
|
|
|
30
30
|
Dynamic: requires-python
|
|
31
31
|
Dynamic: summary
|
|
32
32
|
|
|
33
|
-
# Pytdbot [](https://pypi.org/project/Pytdbot) [](https://pypi.org/project/Pytdbot) [](https://github.com/tdlib/td) [](https://pepy.tech/project/pytdbot) [](https://t.me/pytdbotchat)
|
|
34
34
|
|
|
35
35
|
Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Pytdbot
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.6.dev0
|
|
4
4
|
Summary: Easy-to-use asynchronous TDLib wrapper for Python.
|
|
5
5
|
Home-page: https://github.com/pytdbot/client
|
|
6
6
|
Author: AYMEN Mohammed
|
|
@@ -30,7 +30,7 @@ Dynamic: requires-dist
|
|
|
30
30
|
Dynamic: requires-python
|
|
31
31
|
Dynamic: summary
|
|
32
32
|
|
|
33
|
-
# Pytdbot [](https://pypi.org/project/Pytdbot) [](https://pypi.org/project/Pytdbot) [](https://github.com/tdlib/td) [](https://pepy.tech/project/pytdbot) [](https://t.me/pytdbotchat)
|
|
34
34
|
|
|
35
35
|
Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
36
36
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Pytdbot [](https://pypi.org/project/Pytdbot) [](https://pypi.org/project/Pytdbot) [](https://github.com/tdlib/td) [](https://pepy.tech/project/pytdbot) [](https://t.me/pytdbotchat)
|
|
2
2
|
|
|
3
3
|
Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ from os.path import join as join_path
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from platform import python_implementation, python_version
|
|
9
9
|
from threading import current_thread, main_thread
|
|
10
|
-
from typing import Callable, Dict, Union
|
|
10
|
+
from typing import Callable, Dict, Type, Union
|
|
11
11
|
|
|
12
12
|
import aio_pika
|
|
13
13
|
from deepdiff import DeepDiff
|
|
@@ -129,6 +129,7 @@ class Client(Decorators, Methods):
|
|
|
129
129
|
options: dict = None,
|
|
130
130
|
workers: int = 5,
|
|
131
131
|
no_updates: bool = False,
|
|
132
|
+
load_messages_before_reply: bool = False,
|
|
132
133
|
td_verbosity: int = 2,
|
|
133
134
|
td_log: LogStream = None,
|
|
134
135
|
user_bot: bool = False,
|
|
@@ -159,6 +160,7 @@ class Client(Decorators, Methods):
|
|
|
159
160
|
self.td_options = options
|
|
160
161
|
self.workers = workers
|
|
161
162
|
self.no_updates = no_updates
|
|
163
|
+
self.load_messages_before_reply = load_messages_before_reply
|
|
162
164
|
self.queue = asyncio.Queue()
|
|
163
165
|
self.user_bot = user_bot
|
|
164
166
|
self.my_id = (
|
|
@@ -179,6 +181,12 @@ class Client(Decorators, Methods):
|
|
|
179
181
|
self.is_rabbitmq = True if rabbitmq_url else False
|
|
180
182
|
self.options = {}
|
|
181
183
|
self.allow_outgoing_message_types: tuple = (types.MessagePaymentRefunded,)
|
|
184
|
+
self.get_message_methods = {
|
|
185
|
+
"getmessage",
|
|
186
|
+
"getmessagelocally",
|
|
187
|
+
"getrepliedmessage",
|
|
188
|
+
"getcallbackquerymessage",
|
|
189
|
+
} # TODO: improve this
|
|
182
190
|
|
|
183
191
|
self._check_init_args()
|
|
184
192
|
|
|
@@ -240,13 +248,13 @@ class Client(Decorators, Methods):
|
|
|
240
248
|
return await self.invoke({"@type": "getServerStats"})
|
|
241
249
|
|
|
242
250
|
async def scheduleEvent(
|
|
243
|
-
self,
|
|
251
|
+
self, payload: str, send_at: int
|
|
244
252
|
) -> Union["pytdbot.types.ScheduledEvent", "pytdbot.types.Error"]:
|
|
245
253
|
"""Schedule an event
|
|
246
254
|
|
|
247
255
|
Parameters:
|
|
248
|
-
|
|
249
|
-
The event
|
|
256
|
+
payload (:class:`str`):
|
|
257
|
+
The event payload to be scheduled
|
|
250
258
|
|
|
251
259
|
send_at (:class:`int`):
|
|
252
260
|
Unix timestamp when the event should be sent
|
|
@@ -254,13 +262,13 @@ class Client(Decorators, Methods):
|
|
|
254
262
|
|
|
255
263
|
self._check_rabbitmq()
|
|
256
264
|
|
|
257
|
-
if not isinstance(
|
|
258
|
-
raise ValueError("
|
|
265
|
+
if not isinstance(payload, str):
|
|
266
|
+
raise ValueError("payload must be str")
|
|
259
267
|
if not isinstance(send_at, (int, float)):
|
|
260
268
|
raise ValueError("send_at must be int")
|
|
261
269
|
|
|
262
270
|
return await self.invoke(
|
|
263
|
-
{"@type": "scheduleEvent", "
|
|
271
|
+
{"@type": "scheduleEvent", "payload": payload, "send_at": send_at}
|
|
264
272
|
)
|
|
265
273
|
|
|
266
274
|
async def cancelScheduledEvent(
|
|
@@ -326,7 +334,7 @@ class Client(Decorators, Methods):
|
|
|
326
334
|
|
|
327
335
|
def add_handler(
|
|
328
336
|
self,
|
|
329
|
-
update_type: str,
|
|
337
|
+
update_type: Union[Type["pytdbot.types.Update"], str],
|
|
330
338
|
func: Callable,
|
|
331
339
|
filters: pytdbot.filters.Filter = None,
|
|
332
340
|
position: int = None,
|
|
@@ -336,7 +344,7 @@ class Client(Decorators, Methods):
|
|
|
336
344
|
r"""Add an update handler
|
|
337
345
|
|
|
338
346
|
Parameters:
|
|
339
|
-
update_type (``str``):
|
|
347
|
+
update_type (``str`` || :class:`~pytdbot.types.Update`):
|
|
340
348
|
An update type
|
|
341
349
|
|
|
342
350
|
func (``Callable``):
|
|
@@ -359,23 +367,28 @@ class Client(Decorators, Methods):
|
|
|
359
367
|
"""
|
|
360
368
|
|
|
361
369
|
if not isinstance(update_type, str):
|
|
362
|
-
|
|
363
|
-
|
|
370
|
+
if issubclass(update_type, types.Update):
|
|
371
|
+
update_type = update_type.getType()
|
|
372
|
+
else:
|
|
373
|
+
raise TypeError(
|
|
374
|
+
"update_type must be str or subclass of pytdbot.types.Update"
|
|
375
|
+
)
|
|
376
|
+
if not isinstance(func, Callable):
|
|
364
377
|
raise TypeError("func must be callable")
|
|
365
|
-
|
|
378
|
+
if filters is not None and not isinstance(filters, Filter):
|
|
366
379
|
raise TypeError("filters must be instance of pytdbot.filters.Filter")
|
|
367
|
-
else:
|
|
368
|
-
handler = Handler(
|
|
369
|
-
func, update_type, filters, position, inner_object, is_from_plugin
|
|
370
|
-
)
|
|
371
380
|
|
|
372
|
-
|
|
373
|
-
|
|
381
|
+
handler = Handler(
|
|
382
|
+
func, update_type, filters, position, inner_object, is_from_plugin
|
|
383
|
+
)
|
|
374
384
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
385
|
+
if update_type not in self._handlers:
|
|
386
|
+
self._handlers[update_type] = []
|
|
387
|
+
|
|
388
|
+
if isinstance(position, int):
|
|
389
|
+
self._handlers[update_type].insert(position, handler)
|
|
390
|
+
else:
|
|
391
|
+
self._handlers[update_type].append(handler)
|
|
379
392
|
|
|
380
393
|
self._update_handlers()
|
|
381
394
|
|
|
@@ -451,56 +464,78 @@ class Client(Decorators, Methods):
|
|
|
451
464
|
"""
|
|
452
465
|
|
|
453
466
|
request = obj_to_dict(request)
|
|
454
|
-
|
|
455
467
|
request["@extra"] = {"id": create_extra_id()}
|
|
456
|
-
|
|
457
|
-
future = self._create_request_future(request)
|
|
468
|
+
request_method = request["@type"].lower()
|
|
458
469
|
|
|
459
470
|
if (
|
|
460
471
|
self.logger.root.level >= DEBUG or self.logger.level >= DEBUG
|
|
461
472
|
): # dumping all requests may create performance issues
|
|
462
473
|
self.logger.debug(f"Sending: {dumps(request, indent=4)}")
|
|
463
474
|
|
|
464
|
-
is_chat_attempted_load =
|
|
475
|
+
is_chat_attempted_load = request_method == "getchat"
|
|
476
|
+
is_message_attempted_load = request_method in self.get_message_methods
|
|
465
477
|
|
|
466
478
|
while True:
|
|
467
479
|
future = self._create_request_future(request)
|
|
468
480
|
await self.__send(request)
|
|
469
481
|
result = await future
|
|
470
482
|
|
|
471
|
-
if isinstance(result, types.Error):
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
483
|
+
if not isinstance(result, types.Error):
|
|
484
|
+
break
|
|
485
|
+
|
|
486
|
+
error_code = result.code
|
|
487
|
+
error_message = result.message
|
|
488
|
+
|
|
489
|
+
if error_message.startswith(
|
|
490
|
+
"Failed to parse JSON object as TDLib request:"
|
|
491
|
+
):
|
|
492
|
+
raise ValueError(error_message)
|
|
477
493
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
):
|
|
481
|
-
is_chat_attempted_load = True
|
|
494
|
+
if error_code != 400:
|
|
495
|
+
break
|
|
482
496
|
|
|
483
|
-
|
|
497
|
+
chat_id = request.get("chat_id")
|
|
498
|
+
message_id = request.get("message_id")
|
|
484
499
|
|
|
485
|
-
|
|
500
|
+
if not is_message_attempted_load and (
|
|
501
|
+
error_message == "Message not found" and (chat_id and message_id)
|
|
502
|
+
):
|
|
503
|
+
is_message_attempted_load = True
|
|
486
504
|
|
|
487
|
-
|
|
505
|
+
self.logger.debug(f"Attempt to load message {message_id} in {chat_id}")
|
|
488
506
|
|
|
489
|
-
|
|
490
|
-
|
|
507
|
+
message = await self.getMessage(chat_id=chat_id, message_id=message_id)
|
|
508
|
+
if message:
|
|
509
|
+
self.logger.debug(f"Message {message_id} in {chat_id} is loaded")
|
|
510
|
+
continue
|
|
511
|
+
else:
|
|
512
|
+
self.logger.debug(
|
|
513
|
+
f"Failed to load message {message_id} in {chat_id}"
|
|
514
|
+
)
|
|
491
515
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
516
|
+
if not is_chat_attempted_load and (
|
|
517
|
+
error_message == "Chat not found" and chat_id
|
|
518
|
+
):
|
|
519
|
+
is_chat_attempted_load = True
|
|
495
520
|
|
|
496
|
-
|
|
497
|
-
# load the replied message to avoid "Message not found"
|
|
498
|
-
if reply_to_message_id > 0:
|
|
499
|
-
await self.getMessage(chat_id, reply_to_message_id)
|
|
521
|
+
self.logger.debug(f"Attempt to load chat {chat_id}")
|
|
500
522
|
|
|
501
|
-
|
|
523
|
+
chat = await self.getChat(chat_id)
|
|
524
|
+
if not isinstance(chat, types.Error):
|
|
525
|
+
self.logger.debug(f"Chat {chat_id} is loaded")
|
|
526
|
+
|
|
527
|
+
reply_to_message_id = (request.get("reply_to") or {}).get(
|
|
528
|
+
"message_id", 0
|
|
529
|
+
)
|
|
502
530
|
|
|
503
|
-
|
|
531
|
+
# if the request is a reply to another message
|
|
532
|
+
# load the replied message to avoid "Message not found"
|
|
533
|
+
if reply_to_message_id > 0:
|
|
534
|
+
await self.getMessage(chat_id, reply_to_message_id)
|
|
535
|
+
|
|
536
|
+
continue
|
|
537
|
+
else:
|
|
538
|
+
self.logger.error(f"Couldn't load chat {chat_id}")
|
|
504
539
|
|
|
505
540
|
break
|
|
506
541
|
|
|
@@ -1027,7 +1027,7 @@ class Methods(TDLibFunctions):
|
|
|
1027
1027
|
return await self.sendMessageWithContent(
|
|
1028
1028
|
chat_id=chat_id,
|
|
1029
1029
|
content=InputMessageVoiceNote(
|
|
1030
|
-
|
|
1030
|
+
voice_note=voice,
|
|
1031
1031
|
waveform=waveform,
|
|
1032
1032
|
duration=duration,
|
|
1033
1033
|
caption=caption,
|
|
@@ -1389,6 +1389,11 @@ class Methods(TDLibFunctions):
|
|
|
1389
1389
|
message_id=reply_to_message_id, quote=quote
|
|
1390
1390
|
)
|
|
1391
1391
|
|
|
1392
|
+
if self.load_messages_before_reply and isinstance(
|
|
1393
|
+
reply_to, InputMessageReplyToMessage
|
|
1394
|
+
):
|
|
1395
|
+
await self.getMessage(chat_id=chat_id, message_id=reply_to.message_id)
|
|
1396
|
+
|
|
1392
1397
|
res = await self.sendMessage(
|
|
1393
1398
|
chat_id=chat_id,
|
|
1394
1399
|
message_thread_id=message_thread_id,
|
|
@@ -1039,7 +1039,7 @@ class TDLibFunctions:
|
|
|
1039
1039
|
async def getRepliedMessage(
|
|
1040
1040
|
self, chat_id: int = 0, message_id: int = 0
|
|
1041
1041
|
) -> Union["types.Error", "types.Message"]:
|
|
1042
|
-
r"""Returns information about a non\-bundled message that is replied by a given message\. Also, returns the pinned message, the game message, the invoice message, the message with a previously set same background, the giveaway message, and the topic creation message for messages of the types messagePinMessage, messageGameScore, messagePaymentSuccessful, messageChatSetBackground, messageGiveawayCompleted and topic messages without non\-bundled replied message respectively\. Returns a 404 error if the message doesn't exist
|
|
1042
|
+
r"""Returns information about a non\-bundled message that is replied by a given message\. Also, returns the pinned message, the game message, the invoice message, the message with a previously set same background, the giveaway message, the checklist message, and the topic creation message for messages of the types messagePinMessage, messageGameScore, messagePaymentSuccessful, messageChatSetBackground, messageGiveawayCompleted, messageChecklistTasksDone and messageChecklistTasksAdded, and topic messages without non\-bundled replied message respectively\. Returns a 404 error if the message doesn't exist
|
|
1043
1043
|
|
|
1044
1044
|
Parameters:
|
|
1045
1045
|
chat_id (:class:`int`):
|
|
@@ -2006,6 +2006,66 @@ class TDLibFunctions:
|
|
|
2006
2006
|
}
|
|
2007
2007
|
)
|
|
2008
2008
|
|
|
2009
|
+
async def getDirectMessagesChatTopicRevenue(
|
|
2010
|
+
self, chat_id: int = 0, topic_id: int = 0
|
|
2011
|
+
) -> Union["types.Error", "types.StarCount"]:
|
|
2012
|
+
r"""Returns the total number of Telegram Stars received by the channel chat for direct messages from the given topic
|
|
2013
|
+
|
|
2014
|
+
Parameters:
|
|
2015
|
+
chat_id (:class:`int`):
|
|
2016
|
+
Chat identifier of the channel direct messages chat administered by the current user
|
|
2017
|
+
|
|
2018
|
+
topic_id (:class:`int`):
|
|
2019
|
+
Identifier of the topic
|
|
2020
|
+
|
|
2021
|
+
Returns:
|
|
2022
|
+
:class:`~pytdbot.types.StarCount`
|
|
2023
|
+
"""
|
|
2024
|
+
|
|
2025
|
+
return await self.invoke(
|
|
2026
|
+
{
|
|
2027
|
+
"@type": "getDirectMessagesChatTopicRevenue",
|
|
2028
|
+
"chat_id": chat_id,
|
|
2029
|
+
"topic_id": topic_id,
|
|
2030
|
+
}
|
|
2031
|
+
)
|
|
2032
|
+
|
|
2033
|
+
async def toggleDirectMessagesChatTopicCanSendUnpaidMessages(
|
|
2034
|
+
self,
|
|
2035
|
+
chat_id: int = 0,
|
|
2036
|
+
topic_id: int = 0,
|
|
2037
|
+
can_send_unpaid_messages: bool = False,
|
|
2038
|
+
refund_payments: bool = False,
|
|
2039
|
+
) -> Union["types.Error", "types.Ok"]:
|
|
2040
|
+
r"""Allows to send unpaid messages to the given topic of the channel direct messages chat administered by the current user
|
|
2041
|
+
|
|
2042
|
+
Parameters:
|
|
2043
|
+
chat_id (:class:`int`):
|
|
2044
|
+
Chat identifier
|
|
2045
|
+
|
|
2046
|
+
topic_id (:class:`int`):
|
|
2047
|
+
Identifier of the topic
|
|
2048
|
+
|
|
2049
|
+
can_send_unpaid_messages (:class:`bool`):
|
|
2050
|
+
Pass true to allow unpaid messages; pass false to disallow unpaid messages
|
|
2051
|
+
|
|
2052
|
+
refund_payments (:class:`bool`):
|
|
2053
|
+
Pass true to refund the user previously paid messages
|
|
2054
|
+
|
|
2055
|
+
Returns:
|
|
2056
|
+
:class:`~pytdbot.types.Ok`
|
|
2057
|
+
"""
|
|
2058
|
+
|
|
2059
|
+
return await self.invoke(
|
|
2060
|
+
{
|
|
2061
|
+
"@type": "toggleDirectMessagesChatTopicCanSendUnpaidMessages",
|
|
2062
|
+
"chat_id": chat_id,
|
|
2063
|
+
"topic_id": topic_id,
|
|
2064
|
+
"can_send_unpaid_messages": can_send_unpaid_messages,
|
|
2065
|
+
"refund_payments": refund_payments,
|
|
2066
|
+
}
|
|
2067
|
+
)
|
|
2068
|
+
|
|
2009
2069
|
async def loadSavedMessagesTopics(
|
|
2010
2070
|
self, limit: int = 0
|
|
2011
2071
|
) -> Union["types.Error", "types.Ok"]:
|
|
@@ -3139,6 +3199,94 @@ class TDLibFunctions:
|
|
|
3139
3199
|
}
|
|
3140
3200
|
)
|
|
3141
3201
|
|
|
3202
|
+
async def getVideoMessageAdvertisements(
|
|
3203
|
+
self, chat_id: int = 0, message_id: int = 0
|
|
3204
|
+
) -> Union["types.Error", "types.VideoMessageAdvertisements"]:
|
|
3205
|
+
r"""Returns advertisements to be shown while a video from a message is watched\. Available only if messageProperties\.can\_get\_video\_advertisements
|
|
3206
|
+
|
|
3207
|
+
Parameters:
|
|
3208
|
+
chat_id (:class:`int`):
|
|
3209
|
+
Identifier of the chat with the message
|
|
3210
|
+
|
|
3211
|
+
message_id (:class:`int`):
|
|
3212
|
+
Identifier of the message
|
|
3213
|
+
|
|
3214
|
+
Returns:
|
|
3215
|
+
:class:`~pytdbot.types.VideoMessageAdvertisements`
|
|
3216
|
+
"""
|
|
3217
|
+
|
|
3218
|
+
return await self.invoke(
|
|
3219
|
+
{
|
|
3220
|
+
"@type": "getVideoMessageAdvertisements",
|
|
3221
|
+
"chat_id": chat_id,
|
|
3222
|
+
"message_id": message_id,
|
|
3223
|
+
}
|
|
3224
|
+
)
|
|
3225
|
+
|
|
3226
|
+
async def viewVideoMessageAdvertisement(
|
|
3227
|
+
self, advertisement_unique_id: int = 0
|
|
3228
|
+
) -> Union["types.Error", "types.Ok"]:
|
|
3229
|
+
r"""Informs TDLib that the user viewed a video message advertisement
|
|
3230
|
+
|
|
3231
|
+
Parameters:
|
|
3232
|
+
advertisement_unique_id (:class:`int`):
|
|
3233
|
+
Unique identifier of the advertisement
|
|
3234
|
+
|
|
3235
|
+
Returns:
|
|
3236
|
+
:class:`~pytdbot.types.Ok`
|
|
3237
|
+
"""
|
|
3238
|
+
|
|
3239
|
+
return await self.invoke(
|
|
3240
|
+
{
|
|
3241
|
+
"@type": "viewVideoMessageAdvertisement",
|
|
3242
|
+
"advertisement_unique_id": advertisement_unique_id,
|
|
3243
|
+
}
|
|
3244
|
+
)
|
|
3245
|
+
|
|
3246
|
+
async def clickVideoMessageAdvertisement(
|
|
3247
|
+
self, advertisement_unique_id: int = 0
|
|
3248
|
+
) -> Union["types.Error", "types.Ok"]:
|
|
3249
|
+
r"""Informs TDLib that the user clicked a video message advertisement
|
|
3250
|
+
|
|
3251
|
+
Parameters:
|
|
3252
|
+
advertisement_unique_id (:class:`int`):
|
|
3253
|
+
Unique identifier of the advertisement
|
|
3254
|
+
|
|
3255
|
+
Returns:
|
|
3256
|
+
:class:`~pytdbot.types.Ok`
|
|
3257
|
+
"""
|
|
3258
|
+
|
|
3259
|
+
return await self.invoke(
|
|
3260
|
+
{
|
|
3261
|
+
"@type": "clickVideoMessageAdvertisement",
|
|
3262
|
+
"advertisement_unique_id": advertisement_unique_id,
|
|
3263
|
+
}
|
|
3264
|
+
)
|
|
3265
|
+
|
|
3266
|
+
async def reportVideoMessageAdvertisement(
|
|
3267
|
+
self, advertisement_unique_id: int = 0, option_id: bytes = b""
|
|
3268
|
+
) -> Union["types.Error", "types.ReportSponsoredResult"]:
|
|
3269
|
+
r"""Reports a video message advertisement to Telegram moderators
|
|
3270
|
+
|
|
3271
|
+
Parameters:
|
|
3272
|
+
advertisement_unique_id (:class:`int`):
|
|
3273
|
+
Unique identifier of the advertisement
|
|
3274
|
+
|
|
3275
|
+
option_id (:class:`bytes`):
|
|
3276
|
+
Option identifier chosen by the user; leave empty for the initial request
|
|
3277
|
+
|
|
3278
|
+
Returns:
|
|
3279
|
+
:class:`~pytdbot.types.ReportSponsoredResult`
|
|
3280
|
+
"""
|
|
3281
|
+
|
|
3282
|
+
return await self.invoke(
|
|
3283
|
+
{
|
|
3284
|
+
"@type": "reportVideoMessageAdvertisement",
|
|
3285
|
+
"advertisement_unique_id": advertisement_unique_id,
|
|
3286
|
+
"option_id": option_id,
|
|
3287
|
+
}
|
|
3288
|
+
)
|
|
3289
|
+
|
|
3142
3290
|
async def removeNotification(
|
|
3143
3291
|
self, notification_group_id: int = 0, notification_id: int = 0
|
|
3144
3292
|
) -> Union["types.Error", "types.Ok"]:
|
|
@@ -3909,6 +4057,42 @@ class TDLibFunctions:
|
|
|
3909
4057
|
}
|
|
3910
4058
|
)
|
|
3911
4059
|
|
|
4060
|
+
async def editMessageChecklist(
|
|
4061
|
+
self,
|
|
4062
|
+
chat_id: int = 0,
|
|
4063
|
+
message_id: int = 0,
|
|
4064
|
+
reply_markup: "types.ReplyMarkup" = None,
|
|
4065
|
+
checklist: "types.InputChecklist" = None,
|
|
4066
|
+
) -> Union["types.Error", "types.Message"]:
|
|
4067
|
+
r"""Edits the message content of a checklist\. Returns the edited message after the edit is completed on the server side
|
|
4068
|
+
|
|
4069
|
+
Parameters:
|
|
4070
|
+
chat_id (:class:`int`):
|
|
4071
|
+
The chat the message belongs to
|
|
4072
|
+
|
|
4073
|
+
message_id (:class:`int`):
|
|
4074
|
+
Identifier of the message\. Use messageProperties\.can\_be\_edited to check whether the message can be edited
|
|
4075
|
+
|
|
4076
|
+
reply_markup (:class:`"types.ReplyMarkup"`):
|
|
4077
|
+
The new message reply markup; pass null if none; for bots only
|
|
4078
|
+
|
|
4079
|
+
checklist (:class:`"types.InputChecklist"`):
|
|
4080
|
+
The new checklist\. If some tasks were completed, this information will be kept
|
|
4081
|
+
|
|
4082
|
+
Returns:
|
|
4083
|
+
:class:`~pytdbot.types.Message`
|
|
4084
|
+
"""
|
|
4085
|
+
|
|
4086
|
+
return await self.invoke(
|
|
4087
|
+
{
|
|
4088
|
+
"@type": "editMessageChecklist",
|
|
4089
|
+
"chat_id": chat_id,
|
|
4090
|
+
"message_id": message_id,
|
|
4091
|
+
"reply_markup": reply_markup,
|
|
4092
|
+
"checklist": checklist,
|
|
4093
|
+
}
|
|
4094
|
+
)
|
|
4095
|
+
|
|
3912
4096
|
async def editMessageMedia(
|
|
3913
4097
|
self,
|
|
3914
4098
|
chat_id: int = 0,
|
|
@@ -4448,6 +4632,47 @@ class TDLibFunctions:
|
|
|
4448
4632
|
}
|
|
4449
4633
|
)
|
|
4450
4634
|
|
|
4635
|
+
async def editBusinessMessageChecklist(
|
|
4636
|
+
self,
|
|
4637
|
+
business_connection_id: str = "",
|
|
4638
|
+
chat_id: int = 0,
|
|
4639
|
+
message_id: int = 0,
|
|
4640
|
+
reply_markup: "types.ReplyMarkup" = None,
|
|
4641
|
+
checklist: "types.InputChecklist" = None,
|
|
4642
|
+
) -> Union["types.Error", "types.BusinessMessage"]:
|
|
4643
|
+
r"""Edits the content of a checklist in a message sent on behalf of a business account; for bots only
|
|
4644
|
+
|
|
4645
|
+
Parameters:
|
|
4646
|
+
business_connection_id (:class:`str`):
|
|
4647
|
+
Unique identifier of business connection on behalf of which the message was sent
|
|
4648
|
+
|
|
4649
|
+
chat_id (:class:`int`):
|
|
4650
|
+
The chat the message belongs to
|
|
4651
|
+
|
|
4652
|
+
message_id (:class:`int`):
|
|
4653
|
+
Identifier of the message
|
|
4654
|
+
|
|
4655
|
+
reply_markup (:class:`"types.ReplyMarkup"`):
|
|
4656
|
+
The new message reply markup; pass null if none
|
|
4657
|
+
|
|
4658
|
+
checklist (:class:`"types.InputChecklist"`):
|
|
4659
|
+
The new checklist\. If some tasks were completed, this information will be kept
|
|
4660
|
+
|
|
4661
|
+
Returns:
|
|
4662
|
+
:class:`~pytdbot.types.BusinessMessage`
|
|
4663
|
+
"""
|
|
4664
|
+
|
|
4665
|
+
return await self.invoke(
|
|
4666
|
+
{
|
|
4667
|
+
"@type": "editBusinessMessageChecklist",
|
|
4668
|
+
"business_connection_id": business_connection_id,
|
|
4669
|
+
"chat_id": chat_id,
|
|
4670
|
+
"message_id": message_id,
|
|
4671
|
+
"reply_markup": reply_markup,
|
|
4672
|
+
"checklist": checklist,
|
|
4673
|
+
}
|
|
4674
|
+
)
|
|
4675
|
+
|
|
4451
4676
|
async def editBusinessMessageMedia(
|
|
4452
4677
|
self,
|
|
4453
4678
|
business_connection_id: str = "",
|
|
@@ -5086,7 +5311,7 @@ class TDLibFunctions:
|
|
|
5086
5311
|
Identifier of a quick reply message in the same shortcut to be replied; pass 0 if none
|
|
5087
5312
|
|
|
5088
5313
|
input_message_content (:class:`"types.InputMessageContent"`):
|
|
5089
|
-
The content of the message to be added;
|
|
5314
|
+
The content of the message to be added; inputMessagePaidMedia, inputMessageForwarded and inputMessageLocation with live\_period aren't supported
|
|
5090
5315
|
|
|
5091
5316
|
Returns:
|
|
5092
5317
|
:class:`~pytdbot.types.QuickReplyMessage`
|
|
@@ -5203,7 +5428,7 @@ class TDLibFunctions:
|
|
|
5203
5428
|
message_id: int = 0,
|
|
5204
5429
|
input_message_content: "types.InputMessageContent" = None,
|
|
5205
5430
|
) -> Union["types.Error", "types.Ok"]:
|
|
5206
|
-
r"""Asynchronously edits the text, media or caption of a quick reply message\. Use quickReplyMessage\.can\_be\_edited to check whether a message can be edited\. Media message can be edited only to a media message\. The type of message content in an album can't be changed with exception of replacing a photo with a video or vice versa
|
|
5431
|
+
r"""Asynchronously edits the text, media or caption of a quick reply message\. Use quickReplyMessage\.can\_be\_edited to check whether a message can be edited\. Media message can be edited only to a media message\. Checklist messages can be edited only to a checklist message\. The type of message content in an album can't be changed with exception of replacing a photo with a video or vice versa
|
|
5207
5432
|
|
|
5208
5433
|
Parameters:
|
|
5209
5434
|
shortcut_id (:class:`int`):
|
|
@@ -5213,7 +5438,7 @@ class TDLibFunctions:
|
|
|
5213
5438
|
Identifier of the message
|
|
5214
5439
|
|
|
5215
5440
|
input_message_content (:class:`"types.InputMessageContent"`):
|
|
5216
|
-
New content of the message\. Must be one of the following types:
|
|
5441
|
+
New content of the message\. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageChecklist, inputMessageDocument, inputMessagePhoto, inputMessageText, or inputMessageVideo
|
|
5217
5442
|
|
|
5218
5443
|
Returns:
|
|
5219
5444
|
:class:`~pytdbot.types.Ok`
|
|
@@ -6328,6 +6553,73 @@ class TDLibFunctions:
|
|
|
6328
6553
|
}
|
|
6329
6554
|
)
|
|
6330
6555
|
|
|
6556
|
+
async def addChecklistTasks(
|
|
6557
|
+
self,
|
|
6558
|
+
chat_id: int = 0,
|
|
6559
|
+
message_id: int = 0,
|
|
6560
|
+
tasks: List["types.InputChecklistTask"] = None,
|
|
6561
|
+
) -> Union["types.Error", "types.Ok"]:
|
|
6562
|
+
r"""Adds tasks to a checklist in a message
|
|
6563
|
+
|
|
6564
|
+
Parameters:
|
|
6565
|
+
chat_id (:class:`int`):
|
|
6566
|
+
Identifier of the chat with the message
|
|
6567
|
+
|
|
6568
|
+
message_id (:class:`int`):
|
|
6569
|
+
Identifier of the message containing the checklist\. Use messageProperties\.can\_add\_tasks to check whether the tasks can be added
|
|
6570
|
+
|
|
6571
|
+
tasks (:class:`List["types.InputChecklistTask"]`):
|
|
6572
|
+
List of added tasks
|
|
6573
|
+
|
|
6574
|
+
Returns:
|
|
6575
|
+
:class:`~pytdbot.types.Ok`
|
|
6576
|
+
"""
|
|
6577
|
+
|
|
6578
|
+
return await self.invoke(
|
|
6579
|
+
{
|
|
6580
|
+
"@type": "addChecklistTasks",
|
|
6581
|
+
"chat_id": chat_id,
|
|
6582
|
+
"message_id": message_id,
|
|
6583
|
+
"tasks": tasks,
|
|
6584
|
+
}
|
|
6585
|
+
)
|
|
6586
|
+
|
|
6587
|
+
async def markChecklistTasksAsDone(
|
|
6588
|
+
self,
|
|
6589
|
+
chat_id: int = 0,
|
|
6590
|
+
message_id: int = 0,
|
|
6591
|
+
marked_as_done_task_ids: List[int] = None,
|
|
6592
|
+
marked_as_not_done_task_ids: List[int] = None,
|
|
6593
|
+
) -> Union["types.Error", "types.Ok"]:
|
|
6594
|
+
r"""Adds tasks of a checklist in a message as done or not done
|
|
6595
|
+
|
|
6596
|
+
Parameters:
|
|
6597
|
+
chat_id (:class:`int`):
|
|
6598
|
+
Identifier of the chat with the message
|
|
6599
|
+
|
|
6600
|
+
message_id (:class:`int`):
|
|
6601
|
+
Identifier of the message containing the checklist\. Use messageProperties\.can\_mark\_tasks\_as\_done to check whether the tasks can be marked as done or not done
|
|
6602
|
+
|
|
6603
|
+
marked_as_done_task_ids (:class:`List[int]`):
|
|
6604
|
+
Identifiers of tasks that were marked as done
|
|
6605
|
+
|
|
6606
|
+
marked_as_not_done_task_ids (:class:`List[int]`):
|
|
6607
|
+
Identifiers of tasks that were marked as not done
|
|
6608
|
+
|
|
6609
|
+
Returns:
|
|
6610
|
+
:class:`~pytdbot.types.Ok`
|
|
6611
|
+
"""
|
|
6612
|
+
|
|
6613
|
+
return await self.invoke(
|
|
6614
|
+
{
|
|
6615
|
+
"@type": "markChecklistTasksAsDone",
|
|
6616
|
+
"chat_id": chat_id,
|
|
6617
|
+
"message_id": message_id,
|
|
6618
|
+
"marked_as_done_task_ids": marked_as_done_task_ids,
|
|
6619
|
+
"marked_as_not_done_task_ids": marked_as_not_done_task_ids,
|
|
6620
|
+
}
|
|
6621
|
+
)
|
|
6622
|
+
|
|
6331
6623
|
async def hideSuggestedAction(
|
|
6332
6624
|
self, action: "types.SuggestedAction" = None
|
|
6333
6625
|
) -> Union["types.Error", "types.Ok"]:
|