Pytdbot 0.9.0.dev7__tar.gz → 0.9.2.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.
Files changed (41) hide show
  1. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/PKG-INFO +7 -8
  2. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/Pytdbot.egg-info/PKG-INFO +7 -8
  3. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/README.md +6 -7
  4. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/__init__.py +1 -1
  5. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/client.py +27 -8
  6. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/handlers/td_updates.py +89 -0
  7. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/methods/td_functions.py +175 -46
  8. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/__init__.py +47 -5
  9. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/bound_methods/callback_query.py +1 -1
  10. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/bound_methods/message.py +3 -3
  11. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/types.py +1142 -55
  12. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/LICENSE +0 -0
  13. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/MANIFEST.in +0 -0
  14. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/Pytdbot.egg-info/SOURCES.txt +0 -0
  15. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/Pytdbot.egg-info/dependency_links.txt +0 -0
  16. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/Pytdbot.egg-info/requires.txt +0 -0
  17. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/Pytdbot.egg-info/top_level.txt +0 -0
  18. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/exception/__init__.py +0 -0
  19. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/filters.py +0 -0
  20. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/handlers/__init__.py +0 -0
  21. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/handlers/decorators.py +0 -0
  22. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/handlers/handler.py +0 -0
  23. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/methods/__init__.py +0 -0
  24. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/methods/methods.py +0 -0
  25. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/tdjson/__init__.py +0 -0
  26. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/tdjson/tdjson.py +0 -0
  27. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/plugins/__init__.py +0 -0
  28. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/__init__.py +0 -0
  29. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/bound_methods/__init__.py +0 -0
  30. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/bound_methods/chatActions.py +0 -0
  31. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/types/td_types/bound_methods/file.py +0 -0
  32. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/__init__.py +0 -0
  33. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/escape.py +0 -0
  34. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/json_utils.py +0 -0
  35. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/obj_encoder.py +0 -0
  36. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/strings.py +0 -0
  37. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/text_format.py +0 -0
  38. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/pytdbot/utils/webapps.py +0 -0
  39. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/requirements.txt +0 -0
  40. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/setup.cfg +0 -0
  41. {pytdbot-0.9.0.dev7 → pytdbot-0.9.2.dev0}/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.2.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
@@ -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.2.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
@@ -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.2.dev0"
8
8
  __copyright__ = "Copyright (c) 2022-2025 Pytdbot, AYMENJD"
9
9
  __license__ = "MIT License"
10
10
 
@@ -136,6 +136,7 @@ class Client(Decorators, Methods):
136
136
  no_updates: bool = False,
137
137
  td_verbosity: int = 2,
138
138
  td_log: LogStream = None,
139
+ user_bot: bool = False,
139
140
  ) -> None:
140
141
  self.__api_id = api_id
141
142
  self.__api_hash = api_hash
@@ -164,7 +165,12 @@ class Client(Decorators, Methods):
164
165
  self.workers = workers
165
166
  self.no_updates = no_updates
166
167
  self.queue = asyncio.Queue()
167
- self.my_id = get_bot_id_from_token(self.__token)
168
+ self.user_bot = user_bot
169
+ self.my_id = (
170
+ get_bot_id_from_token(self.__token)
171
+ if isinstance(self.__token, str)
172
+ else None
173
+ )
168
174
  self.logger = getLogger(f"{__name__}:{self.my_id or 0}")
169
175
  self.td_verbosity = td_verbosity
170
176
  self.connection_state: str = None
@@ -233,6 +239,9 @@ class Client(Decorators, Methods):
233
239
  Login after start. Default is ``True``
234
240
  """
235
241
 
242
+ if self.user_bot:
243
+ login = False
244
+
236
245
  if not self.is_running:
237
246
  self.logger.info("Starting pytdbot client...")
238
247
 
@@ -259,7 +268,11 @@ class Client(Decorators, Methods):
259
268
  async def login(self) -> None:
260
269
  r"""Login to Telegram."""
261
270
 
262
- if not self.__token or (self.is_authenticated or self.is_rabbitmq):
271
+ if (
272
+ not self.__token
273
+ or self.user_bot
274
+ or (self.is_authenticated or self.is_rabbitmq)
275
+ ):
263
276
  return
264
277
 
265
278
  self.__login = True
@@ -396,7 +409,7 @@ class Client(Decorators, Methods):
396
409
  ): # dumping all requests may create performance issues
397
410
  self.logger.debug(f"Sending: {dumps(request, indent=4)}")
398
411
 
399
- is_chat_attempted_load = False
412
+ is_chat_attempted_load = request["@type"].lower() == "getchat"
400
413
 
401
414
  while True:
402
415
  future = self._create_request_future(request)
@@ -409,7 +422,8 @@ class Client(Decorators, Methods):
409
422
  "Failed to parse JSON object as TDLib request:"
410
423
  ):
411
424
  raise ValueError(result.message)
412
- elif not is_chat_attempted_load and (
425
+
426
+ if not is_chat_attempted_load and (
413
427
  result.message == "Chat not found" and "chat_id" in request
414
428
  ):
415
429
  is_chat_attempted_load = True
@@ -433,8 +447,8 @@ class Client(Decorators, Methods):
433
447
  await self.getMessage(chat_id, reply_to_message_id)
434
448
 
435
449
  continue
436
- else:
437
- self.logger.error(f"Couldn't load chat {chat_id}")
450
+
451
+ self.logger.error(f"Couldn't load chat {chat_id}")
438
452
 
439
453
  break
440
454
 
@@ -558,12 +572,16 @@ class Client(Decorators, Methods):
558
572
  else:
559
573
  await self.__rchannel.default_exchange.publish(
560
574
  aio_pika.Message(
561
- json_dumps(request), reply_to=self.__rqueues["responses"].name
575
+ json_dumps(request, encode=True),
576
+ reply_to=self.__rqueues["responses"].name,
562
577
  ),
563
578
  routing_key=self.__rqueues["requests"].name,
564
579
  )
565
580
 
566
581
  def _check_init_args(self):
582
+ if self.user_bot:
583
+ return
584
+
567
585
  if not self.is_rabbitmq:
568
586
  if not isinstance(self.__api_id, int):
569
587
  raise TypeError("api_id must be an int")
@@ -1040,7 +1058,8 @@ class Client(Decorators, Methods):
1040
1058
  for worker_task in self._workers_tasks:
1041
1059
  worker_task.cancel()
1042
1060
 
1043
- self.__listen_loop_task.cancel()
1061
+ if self.__listen_loop_task:
1062
+ self.__listen_loop_task.cancel()
1044
1063
 
1045
1064
  def _register_signal_handlers(self):
1046
1065
  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,