Pytdbot 0.9.0.dev7__tar.gz → 0.9.1__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.
Files changed (41) hide show
  1. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/PKG-INFO +7 -8
  2. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/Pytdbot.egg-info/PKG-INFO +7 -8
  3. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/README.md +6 -7
  4. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/__init__.py +1 -1
  5. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/client.py +9 -6
  6. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/handlers/td_updates.py +89 -0
  7. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/methods/td_functions.py +175 -46
  8. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/__init__.py +47 -5
  9. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/bound_methods/callback_query.py +1 -1
  10. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/bound_methods/message.py +1 -1
  11. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/types.py +1142 -55
  12. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/LICENSE +0 -0
  13. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/MANIFEST.in +0 -0
  14. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/Pytdbot.egg-info/SOURCES.txt +0 -0
  15. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/Pytdbot.egg-info/dependency_links.txt +0 -0
  16. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/Pytdbot.egg-info/requires.txt +0 -0
  17. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/Pytdbot.egg-info/top_level.txt +0 -0
  18. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/exception/__init__.py +0 -0
  19. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/filters.py +0 -0
  20. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/handlers/__init__.py +0 -0
  21. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/handlers/decorators.py +0 -0
  22. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/handlers/handler.py +0 -0
  23. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/methods/__init__.py +0 -0
  24. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/methods/methods.py +0 -0
  25. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/tdjson/__init__.py +0 -0
  26. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/tdjson/tdjson.py +0 -0
  27. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/plugins/__init__.py +0 -0
  28. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/__init__.py +0 -0
  29. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/bound_methods/__init__.py +0 -0
  30. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/bound_methods/chatActions.py +0 -0
  31. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/types/td_types/bound_methods/file.py +0 -0
  32. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/__init__.py +0 -0
  33. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/escape.py +0 -0
  34. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/json_utils.py +0 -0
  35. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/obj_encoder.py +0 -0
  36. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/strings.py +0 -0
  37. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/text_format.py +0 -0
  38. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/pytdbot/utils/webapps.py +0 -0
  39. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/requirements.txt +0 -0
  40. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/setup.cfg +0 -0
  41. {pytdbot-0.9.0.dev7 → pytdbot-0.9.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: Pytdbot
3
- Version: 0.9.0.dev7
3
+ Version: 0.9.1
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
@@ -29,7 +29,7 @@ Dynamic: requires-dist
29
29
  Dynamic: requires-python
30
30
  Dynamic: summary
31
31
 
32
- # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.44-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
32
+ # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.46-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
33
33
 
34
34
  Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
35
35
 
@@ -61,18 +61,18 @@ Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/t
61
61
  You can install Pytdbot with TDLib included using pip:
62
62
 
63
63
  ```bash
64
- pip install pytdbot[tdjson]
64
+ pip install --upgrade pytdbot[tdjson]
65
65
  ```
66
66
 
67
- or without **pre-built** TDLib:
67
+ If the installation fails, then install without **pre-built** TDLib:
68
68
 
69
69
  ```bash
70
70
  pip install pytdbot
71
71
  ```
72
72
 
73
- If the install fails, then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client(lib_path="/path/to/libtdjson")`.
73
+ Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
74
74
 
75
- You could also install the development version from Github, using the following command:
75
+ You could also install the development version using the following command:
76
76
 
77
77
  ```bash
78
78
  pip install --pre pytdbot
@@ -89,10 +89,9 @@ import asyncio
89
89
  from pytdbot import Client, types
90
90
 
91
91
  client = Client(
92
- token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token or phone number if you want to login as user
92
+ token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
93
93
  api_id=0,
94
94
  api_hash="API_HASH",
95
- lib_path="/path/to/libtdjson.so", # Path to TDjson shared library
96
95
  files_directory="BotDB", # Path where to store TDLib files
97
96
  database_encryption_key="1234echobot$",
98
97
  td_verbosity=2, # TDLib verbosity level
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: Pytdbot
3
- Version: 0.9.0.dev7
3
+ Version: 0.9.1
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
@@ -29,7 +29,7 @@ Dynamic: requires-dist
29
29
  Dynamic: requires-python
30
30
  Dynamic: summary
31
31
 
32
- # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.44-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
32
+ # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.46-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
33
33
 
34
34
  Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
35
35
 
@@ -61,18 +61,18 @@ Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/t
61
61
  You can install Pytdbot with TDLib included using pip:
62
62
 
63
63
  ```bash
64
- pip install pytdbot[tdjson]
64
+ pip install --upgrade pytdbot[tdjson]
65
65
  ```
66
66
 
67
- or without **pre-built** TDLib:
67
+ If the installation fails, then install without **pre-built** TDLib:
68
68
 
69
69
  ```bash
70
70
  pip install pytdbot
71
71
  ```
72
72
 
73
- If the install fails, then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client(lib_path="/path/to/libtdjson")`.
73
+ Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
74
74
 
75
- You could also install the development version from Github, using the following command:
75
+ You could also install the development version using the following command:
76
76
 
77
77
  ```bash
78
78
  pip install --pre pytdbot
@@ -89,10 +89,9 @@ import asyncio
89
89
  from pytdbot import Client, types
90
90
 
91
91
  client = Client(
92
- token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token or phone number if you want to login as user
92
+ token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
93
93
  api_id=0,
94
94
  api_hash="API_HASH",
95
- lib_path="/path/to/libtdjson.so", # Path to TDjson shared library
96
95
  files_directory="BotDB", # Path where to store TDLib files
97
96
  database_encryption_key="1234echobot$",
98
97
  td_verbosity=2, # TDLib verbosity level
@@ -1,4 +1,4 @@
1
- # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.44-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
1
+ # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.46-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)
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
 
@@ -30,18 +30,18 @@ Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/t
30
30
  You can install Pytdbot with TDLib included using pip:
31
31
 
32
32
  ```bash
33
- pip install pytdbot[tdjson]
33
+ pip install --upgrade pytdbot[tdjson]
34
34
  ```
35
35
 
36
- or without **pre-built** TDLib:
36
+ If the installation fails, then install without **pre-built** TDLib:
37
37
 
38
38
  ```bash
39
39
  pip install pytdbot
40
40
  ```
41
41
 
42
- If the install fails, then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client(lib_path="/path/to/libtdjson")`.
42
+ Then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client.lib_path`.
43
43
 
44
- You could also install the development version from Github, using the following command:
44
+ You could also install the development version using the following command:
45
45
 
46
46
  ```bash
47
47
  pip install --pre pytdbot
@@ -58,10 +58,9 @@ import asyncio
58
58
  from pytdbot import Client, types
59
59
 
60
60
  client = Client(
61
- token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token or phone number if you want to login as user
61
+ token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
62
62
  api_id=0,
63
63
  api_hash="API_HASH",
64
- lib_path="/path/to/libtdjson.so", # Path to TDjson shared library
65
64
  files_directory="BotDB", # Path where to store TDLib files
66
65
  database_encryption_key="1234echobot$",
67
66
  td_verbosity=2, # TDLib verbosity level
@@ -4,7 +4,7 @@ from .client import Client
4
4
 
5
5
  __all__ = ["types", "utils", "filters", "exception", "TdJson", "Client"]
6
6
 
7
- __version__ = "0.9.0dev7"
7
+ __version__ = "0.9.1"
8
8
  __copyright__ = "Copyright (c) 2022-2025 Pytdbot, AYMENJD"
9
9
  __license__ = "MIT License"
10
10
 
@@ -396,7 +396,7 @@ class Client(Decorators, Methods):
396
396
  ): # dumping all requests may create performance issues
397
397
  self.logger.debug(f"Sending: {dumps(request, indent=4)}")
398
398
 
399
- is_chat_attempted_load = False
399
+ is_chat_attempted_load = request["@type"].lower() == "getchat"
400
400
 
401
401
  while True:
402
402
  future = self._create_request_future(request)
@@ -409,7 +409,8 @@ class Client(Decorators, Methods):
409
409
  "Failed to parse JSON object as TDLib request:"
410
410
  ):
411
411
  raise ValueError(result.message)
412
- elif not is_chat_attempted_load and (
412
+
413
+ if not is_chat_attempted_load and (
413
414
  result.message == "Chat not found" and "chat_id" in request
414
415
  ):
415
416
  is_chat_attempted_load = True
@@ -433,8 +434,8 @@ class Client(Decorators, Methods):
433
434
  await self.getMessage(chat_id, reply_to_message_id)
434
435
 
435
436
  continue
436
- else:
437
- self.logger.error(f"Couldn't load chat {chat_id}")
437
+
438
+ self.logger.error(f"Couldn't load chat {chat_id}")
438
439
 
439
440
  break
440
441
 
@@ -558,7 +559,8 @@ class Client(Decorators, Methods):
558
559
  else:
559
560
  await self.__rchannel.default_exchange.publish(
560
561
  aio_pika.Message(
561
- json_dumps(request), reply_to=self.__rqueues["responses"].name
562
+ json_dumps(request, encode=True),
563
+ reply_to=self.__rqueues["responses"].name,
562
564
  ),
563
565
  routing_key=self.__rqueues["requests"].name,
564
566
  )
@@ -1040,7 +1042,8 @@ class Client(Decorators, Methods):
1040
1042
  for worker_task in self._workers_tasks:
1041
1043
  worker_task.cancel()
1042
1044
 
1043
- self.__listen_loop_task.cancel()
1045
+ if self.__listen_loop_task:
1046
+ self.__listen_loop_task.cancel()
1044
1047
 
1045
1048
  def _register_signal_handlers(self):
1046
1049
  def _handle_signal():
@@ -3065,6 +3065,55 @@ class Updates:
3065
3065
 
3066
3066
  return decorator
3067
3067
 
3068
+ def on_updateApplicationRecaptchaVerificationRequired(
3069
+ self: "pytdbot.Client" = None,
3070
+ filters: "pytdbot.filters.Filter" = None,
3071
+ position: int = None,
3072
+ ) -> Callable:
3073
+ r"""A request can't be completed unless reCAPTCHA verification is performed; for official mobile applications only\. The method setApplicationVerificationToken must be called once the verification is completed or failed
3074
+
3075
+ Parameters:
3076
+ filters (:class:`pytdbot.filters.Filter`, *optional*):
3077
+ An update filter
3078
+
3079
+ position (``int``, *optional*):
3080
+ The function position in handlers list. Default is ``None`` (append)
3081
+
3082
+ Raises:
3083
+ :py:class:`TypeError`
3084
+ """
3085
+
3086
+ def decorator(func: Callable) -> Callable:
3087
+ if hasattr(func, "_handler"):
3088
+ return func
3089
+ elif isinstance(self, pytdbot.Client):
3090
+ if iscoroutinefunction(func):
3091
+ self.add_handler(
3092
+ "updateApplicationRecaptchaVerificationRequired",
3093
+ func,
3094
+ filters,
3095
+ position,
3096
+ )
3097
+ else:
3098
+ raise TypeError("Handler must be async")
3099
+ elif isinstance(self, pytdbot.filters.Filter):
3100
+ func._handler = Handler(
3101
+ func,
3102
+ "updateApplicationRecaptchaVerificationRequired",
3103
+ self,
3104
+ position,
3105
+ )
3106
+ else:
3107
+ func._handler = Handler(
3108
+ func,
3109
+ "updateApplicationRecaptchaVerificationRequired",
3110
+ filters,
3111
+ position,
3112
+ )
3113
+ return func
3114
+
3115
+ return decorator
3116
+
3068
3117
  def on_updateCall(
3069
3118
  self: "pytdbot.Client" = None,
3070
3119
  filters: "pytdbot.filters.Filter" = None,
@@ -4369,6 +4418,46 @@ class Updates:
4369
4418
 
4370
4419
  return decorator
4371
4420
 
4421
+ def on_updateDefaultPaidReactionType(
4422
+ self: "pytdbot.Client" = None,
4423
+ filters: "pytdbot.filters.Filter" = None,
4424
+ position: int = None,
4425
+ ) -> Callable:
4426
+ r"""The type of default paid reaction has changed
4427
+
4428
+ Parameters:
4429
+ filters (:class:`pytdbot.filters.Filter`, *optional*):
4430
+ An update filter
4431
+
4432
+ position (``int``, *optional*):
4433
+ The function position in handlers list. Default is ``None`` (append)
4434
+
4435
+ Raises:
4436
+ :py:class:`TypeError`
4437
+ """
4438
+
4439
+ def decorator(func: Callable) -> Callable:
4440
+ if hasattr(func, "_handler"):
4441
+ return func
4442
+ elif isinstance(self, pytdbot.Client):
4443
+ if iscoroutinefunction(func):
4444
+ self.add_handler(
4445
+ "updateDefaultPaidReactionType", func, filters, position
4446
+ )
4447
+ else:
4448
+ raise TypeError("Handler must be async")
4449
+ elif isinstance(self, pytdbot.filters.Filter):
4450
+ func._handler = Handler(
4451
+ func, "updateDefaultPaidReactionType", self, position
4452
+ )
4453
+ else:
4454
+ func._handler = Handler(
4455
+ func, "updateDefaultPaidReactionType", filters, position
4456
+ )
4457
+ return func
4458
+
4459
+ return decorator
4460
+
4372
4461
  def on_updateSavedMessagesTags(
4373
4462
  self: "pytdbot.Client" = None,
4374
4463
  filters: "pytdbot.filters.Filter" = None,