Pytdbot 0.9.0.dev3__tar.gz → 0.9.0.dev4__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.dev3 → Pytdbot-0.9.0.dev4}/PKG-INFO +2 -2
  2. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/Pytdbot.egg-info/PKG-INFO +2 -2
  3. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/Pytdbot.egg-info/SOURCES.txt +2 -1
  4. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/README.md +1 -1
  5. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/__init__.py +1 -1
  6. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/client.py +26 -10
  7. Pytdbot-0.9.0.dev4/pytdbot/exception/__init__.py +31 -0
  8. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/filters.py +1 -1
  9. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/handlers/decorators.py +25 -9
  10. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/handlers/td_updates.py +152 -152
  11. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/methods/methods.py +14 -14
  12. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/methods/td_functions.py +244 -43
  13. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/tdjson/tdjson.py +5 -5
  14. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/__init__.py +45 -11
  15. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/plugins/__init__.py +1 -1
  16. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/bound_methods/message.py +5 -5
  17. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/types.py +1128 -423
  18. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/__init__.py +3 -0
  19. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/escape.py +2 -2
  20. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/text_format.py +12 -12
  21. Pytdbot-0.9.0.dev4/pytdbot/utils/webapps.py +81 -0
  22. Pytdbot-0.9.0.dev3/pytdbot/exception/__init__.py +0 -13
  23. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/LICENSE +0 -0
  24. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/MANIFEST.in +0 -0
  25. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/Pytdbot.egg-info/dependency_links.txt +0 -0
  26. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/Pytdbot.egg-info/requires.txt +0 -0
  27. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/Pytdbot.egg-info/top_level.txt +0 -0
  28. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/handlers/__init__.py +0 -0
  29. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/handlers/handler.py +0 -0
  30. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/methods/__init__.py +0 -0
  31. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/tdjson/__init__.py +0 -0
  32. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/__init__.py +0 -0
  33. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/bound_methods/__init__.py +0 -0
  34. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/bound_methods/chatActions.py +0 -0
  35. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/types/td_types/bound_methods/file.py +0 -0
  36. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/json_utils.py +0 -0
  37. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/obj_encoder.py +0 -0
  38. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/pytdbot/utils/strings.py +0 -0
  39. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/requirements.txt +0 -0
  40. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/setup.cfg +0 -0
  41. {Pytdbot-0.9.0.dev3 → Pytdbot-0.9.0.dev4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Pytdbot
3
- Version: 0.9.0.dev3
3
+ Version: 0.9.0.dev4
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
@@ -14,7 +14,7 @@ Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
 
17
- # 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.39-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)
17
+ # 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.40-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)
18
18
 
19
19
  Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
20
20
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Pytdbot
3
- Version: 0.9.0.dev3
3
+ Version: 0.9.0.dev4
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
@@ -14,7 +14,7 @@ Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
 
17
- # 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.39-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)
17
+ # 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.40-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)
18
18
 
19
19
  Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.
20
20
 
@@ -34,4 +34,5 @@ pytdbot/utils/escape.py
34
34
  pytdbot/utils/json_utils.py
35
35
  pytdbot/utils/obj_encoder.py
36
36
  pytdbot/utils/strings.py
37
- pytdbot/utils/text_format.py
37
+ pytdbot/utils/text_format.py
38
+ pytdbot/utils/webapps.py
@@ -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.39-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.40-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
 
@@ -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.0dev3"
7
+ __version__ = "0.9.0dev4"
8
8
  __copyright__ = "Copyright (c) 2022-2024 AYMEN Mohammed ~ https://github.com/AYMENJD"
9
9
  __license__ = "MIT License"
10
10
 
@@ -36,7 +36,7 @@ from .utils import (
36
36
  class Client(Decorators, Methods):
37
37
  r"""Pytdbot, a TDLib client
38
38
 
39
- Args:
39
+ Parameters:
40
40
  token (``str``, *optional*):
41
41
  Bot token
42
42
 
@@ -231,7 +231,7 @@ class Client(Decorators, Methods):
231
231
  async def start(self, login: bool = True) -> None:
232
232
  r"""Start pytdbot client
233
233
 
234
- Args:
234
+ Parameters:
235
235
  login (``bool``, *optional*):
236
236
  Login after start. Default is ``True``
237
237
  """
@@ -302,7 +302,7 @@ class Client(Decorators, Methods):
302
302
  ) -> None:
303
303
  r"""Add an update handler
304
304
 
305
- Args:
305
+ Parameters:
306
306
  update_type (``str``):
307
307
  An update type
308
308
 
@@ -341,7 +341,7 @@ class Client(Decorators, Methods):
341
341
  def remove_handler(self, func: Callable) -> bool:
342
342
  r"""Remove an update handler
343
343
 
344
- Args:
344
+ Parameters:
345
345
  func (``Callable``):
346
346
  A callable function
347
347
 
@@ -380,7 +380,7 @@ class Client(Decorators, Methods):
380
380
  if not isinstance(res, types.Error):
381
381
  print(res)
382
382
 
383
- Args:
383
+ Parameters:
384
384
  request (``dict``):
385
385
  The request to be sent
386
386
 
@@ -463,7 +463,7 @@ class Client(Decorators, Methods):
463
463
  if not isinstance(res, types.Error):
464
464
  print(res)
465
465
 
466
- Args:
466
+ Parameters:
467
467
  method (``str``):
468
468
  TDLib method name
469
469
 
@@ -491,7 +491,7 @@ class Client(Decorators, Methods):
491
491
 
492
492
  client.run()
493
493
 
494
- Args:
494
+ Parameters:
495
495
  login (``bool``, *optional*):
496
496
  Login after start. Default is ``True``
497
497
  """
@@ -595,7 +595,7 @@ class Client(Decorators, Methods):
595
595
  def get_retry_after_time(self, error_message: str) -> int:
596
596
  r"""Get the retry after time from flood wait error message
597
597
 
598
- Args:
598
+ Parameters:
599
599
  error_message (``str``):
600
600
  The returned error message from TDLib
601
601
 
@@ -735,9 +735,20 @@ class Client(Decorators, Methods):
735
735
  else:
736
736
  await self._handle_update(update)
737
737
 
738
+ def get_inner_object(self, update: types.TlObject):
739
+ if isinstance(update, types.UpdateNewMessage):
740
+ return update.message
741
+ return update
742
+
738
743
  async def __run_initializers(self, update):
739
744
  for initializer in self._handlers["initializer"]:
740
745
  try:
746
+ update = (
747
+ self.get_inner_object(update)
748
+ if initializer.inner_object
749
+ else update
750
+ )
751
+
741
752
  if initializer.filter is not None:
742
753
  filter_function = initializer.filter.func
743
754
 
@@ -756,8 +767,9 @@ class Client(Decorators, Methods):
756
767
  async def __run_handlers(self, update):
757
768
  for handler in self._handlers[update.getType()]:
758
769
  try:
759
- if handler.inner_object and isinstance(update, types.UpdateNewMessage):
760
- update = update.message
770
+ update = (
771
+ self.get_inner_object(update) if handler.inner_object else update
772
+ )
761
773
 
762
774
  if handler.filter is not None:
763
775
  filter_function = handler.filter.func
@@ -776,6 +788,10 @@ class Client(Decorators, Methods):
776
788
  async def __run_finalizers(self, update):
777
789
  for finalizer in self._handlers["finalizer"]:
778
790
  try:
791
+ update = (
792
+ self.get_inner_object(update) if finalizer.inner_object else update
793
+ )
794
+
779
795
  if finalizer.filter is not None:
780
796
  filter_function = finalizer.filter.func
781
797
 
@@ -0,0 +1,31 @@
1
+ __all__ = ("StopHandlers", "AuthorizationError")
2
+
3
+
4
+ class StopHandlers(Exception):
5
+ r"""An exception to stop handlers from execution"""
6
+
7
+ pass
8
+
9
+
10
+ class AuthorizationError(Exception):
11
+ r"""An exception for authorization errors"""
12
+
13
+ pass
14
+
15
+
16
+ class WebAppDataInvalid(Exception):
17
+ r"""An exception for invalid webapp data"""
18
+
19
+ pass
20
+
21
+
22
+ class WebAppDataOutdated(Exception):
23
+ r"""An exception for outdated webapp data"""
24
+
25
+ pass
26
+
27
+
28
+ class WebAppDataMismatch(Exception):
29
+ r"""An exception for mismatched webapp data"""
30
+
31
+ pass
@@ -52,7 +52,7 @@ def create(func: Callable) -> Filter:
52
52
 
53
53
  client.run()
54
54
 
55
- Args:
55
+ Parameters:
56
56
  func (``Callable``):
57
57
  The filter function
58
58
 
@@ -16,16 +16,20 @@ class Decorators(Updates):
16
16
  self: "pytdbot.Client" = None,
17
17
  filters: "pytdbot.filters.Filter" = None,
18
18
  position: int = None,
19
+ inner_object: bool = False,
19
20
  ) -> None:
20
21
  r"""A decorator to initialize an event object before running other handlers
21
22
 
22
- Args:
23
+ Parameters:
23
24
  filters (:class:`~pytdbot.filters.Filter`, *optional*):
24
25
  An update filter
25
26
 
26
27
  position (``int``, *optional*):
27
28
  The function position in initializers list. Default is ``None`` (append)
28
29
 
30
+ inner_object (``bool``, *optional*):
31
+ Wether to pass an inner object of update or not; for example ``UpdateNewMessage.message``. Default is ``False``
32
+
29
33
  Raises:
30
34
  :py:class:`TypeError`
31
35
  """
@@ -35,13 +39,19 @@ class Decorators(Updates):
35
39
  return func
36
40
  elif isinstance(self, pytdbot.Client):
37
41
  if iscoroutinefunction(func):
38
- self.add_handler("initializer", func, filters, position)
42
+ self.add_handler(
43
+ "initializer", func, filters, position, inner_object
44
+ )
39
45
  else:
40
46
  raise TypeError("Handler must be async")
41
47
  elif isinstance(self, pytdbot.filters.Filter):
42
- func._handler = Handler(func, "initializer", self, position)
48
+ func._handler = Handler(
49
+ func, "initializer", self, position, inner_object
50
+ )
43
51
  else:
44
- func._handler = Handler(func, "initializer", filters, position)
52
+ func._handler = Handler(
53
+ func, "initializer", filters, position, inner_object
54
+ )
45
55
 
46
56
  return func
47
57
 
@@ -51,16 +61,20 @@ class Decorators(Updates):
51
61
  self: "pytdbot.Client" = None,
52
62
  filters: "pytdbot.filters.Filter" = None,
53
63
  position: int = None,
64
+ inner_object: bool = False,
54
65
  ) -> None:
55
66
  r"""A decorator to finalize an event object after running all handlers
56
67
 
57
- Args:
68
+ Parameters:
58
69
  filters (:class:`~pytdbot.filters.Filter`, *optional*):
59
70
  An update filter
60
71
 
61
72
  position (``int``, *optional*):
62
73
  The function position in finalizers list. Default is ``None`` (append)
63
74
 
75
+ inner_object (``bool``, *optional*):
76
+ Wether to pass an inner object of update or not; for example ``UpdateNewMessage.message``. Default is ``False``
77
+
64
78
  Raises:
65
79
  :py:class:`TypeError`
66
80
  """
@@ -70,13 +84,15 @@ class Decorators(Updates):
70
84
  return func
71
85
  elif isinstance(self, pytdbot.Client):
72
86
  if iscoroutinefunction(func):
73
- self.add_handler("finalizer", func, filters, position)
87
+ self.add_handler("finalizer", func, filters, position, inner_object)
74
88
  else:
75
89
  raise TypeError("Handler must be async")
76
90
  elif isinstance(self, pytdbot.filters.Filter):
77
- func._handler = Handler(func, "finalizer", self, position)
91
+ func._handler = Handler(func, "finalizer", self, position, inner_object)
78
92
  else:
79
- func._handler = Handler(func, "finalizer", filters, position)
93
+ func._handler = Handler(
94
+ func, "finalizer", filters, position, inner_object
95
+ )
80
96
  return func
81
97
 
82
98
  return decorator
@@ -88,7 +104,7 @@ class Decorators(Updates):
88
104
  ) -> None:
89
105
  r"""A decorator to handle ``updateNewMessage`` but with ``Message`` object.
90
106
 
91
- Args:
107
+ Parameters:
92
108
  filters (:class:`~pytdbot.filters.Filter`, *optional*):
93
109
  An update filter
94
110