telegrinder 0.1.dev158__py3-none-any.whl → 0.1.dev160__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.

Potentially problematic release.


This version of telegrinder might be problematic. Click here for more details.

Files changed (128) hide show
  1. telegrinder/__init__.py +4 -2
  2. telegrinder/api/__init__.py +0 -0
  3. telegrinder/api/abc.py +6 -4
  4. telegrinder/api/api.py +25 -11
  5. telegrinder/api/error.py +0 -0
  6. telegrinder/api/response.py +0 -0
  7. telegrinder/bot/__init__.py +0 -0
  8. telegrinder/bot/bot.py +0 -0
  9. telegrinder/bot/cute_types/__init__.py +0 -0
  10. telegrinder/bot/cute_types/base.py +100 -9
  11. telegrinder/bot/cute_types/callback_query.py +426 -37
  12. telegrinder/bot/cute_types/inline_query.py +44 -17
  13. telegrinder/bot/cute_types/message.py +2885 -117
  14. telegrinder/bot/cute_types/update.py +14 -7
  15. telegrinder/bot/cute_types/utils.py +542 -0
  16. telegrinder/bot/dispatch/__init__.py +0 -0
  17. telegrinder/bot/dispatch/abc.py +0 -0
  18. telegrinder/bot/dispatch/composition.py +0 -0
  19. telegrinder/bot/dispatch/context.py +0 -0
  20. telegrinder/bot/dispatch/dispatch.py +0 -0
  21. telegrinder/bot/dispatch/handler/__init__.py +0 -0
  22. telegrinder/bot/dispatch/handler/abc.py +0 -0
  23. telegrinder/bot/dispatch/handler/func.py +1 -1
  24. telegrinder/bot/dispatch/handler/message_reply.py +0 -0
  25. telegrinder/bot/dispatch/middleware/__init__.py +0 -0
  26. telegrinder/bot/dispatch/middleware/abc.py +0 -0
  27. telegrinder/bot/dispatch/process.py +0 -0
  28. telegrinder/bot/dispatch/return_manager/__init__.py +0 -0
  29. telegrinder/bot/dispatch/return_manager/abc.py +0 -0
  30. telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
  31. telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
  32. telegrinder/bot/dispatch/return_manager/message.py +0 -0
  33. telegrinder/bot/dispatch/view/__init__.py +0 -0
  34. telegrinder/bot/dispatch/view/abc.py +40 -29
  35. telegrinder/bot/dispatch/view/box.py +0 -0
  36. telegrinder/bot/dispatch/view/callback_query.py +0 -0
  37. telegrinder/bot/dispatch/view/inline_query.py +0 -0
  38. telegrinder/bot/dispatch/view/message.py +0 -0
  39. telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
  40. telegrinder/bot/dispatch/waiter_machine/machine.py +0 -0
  41. telegrinder/bot/dispatch/waiter_machine/middleware.py +0 -0
  42. telegrinder/bot/dispatch/waiter_machine/short_state.py +0 -0
  43. telegrinder/bot/polling/__init__.py +0 -0
  44. telegrinder/bot/polling/abc.py +0 -0
  45. telegrinder/bot/polling/polling.py +7 -11
  46. telegrinder/bot/rules/__init__.py +0 -0
  47. telegrinder/bot/rules/abc.py +1 -1
  48. telegrinder/bot/rules/adapter/__init__.py +0 -0
  49. telegrinder/bot/rules/adapter/abc.py +0 -0
  50. telegrinder/bot/rules/adapter/errors.py +0 -0
  51. telegrinder/bot/rules/adapter/event.py +12 -6
  52. telegrinder/bot/rules/adapter/raw_update.py +0 -0
  53. telegrinder/bot/rules/callback_data.py +3 -11
  54. telegrinder/bot/rules/command.py +0 -0
  55. telegrinder/bot/rules/enum_text.py +0 -0
  56. telegrinder/bot/rules/func.py +0 -0
  57. telegrinder/bot/rules/fuzzy.py +0 -0
  58. telegrinder/bot/rules/inline.py +2 -1
  59. telegrinder/bot/rules/integer.py +0 -0
  60. telegrinder/bot/rules/is_from.py +0 -0
  61. telegrinder/bot/rules/markup.py +3 -1
  62. telegrinder/bot/rules/mention.py +0 -0
  63. telegrinder/bot/rules/message_entities.py +3 -1
  64. telegrinder/bot/rules/regex.py +1 -1
  65. telegrinder/bot/rules/rule_enum.py +0 -0
  66. telegrinder/bot/rules/start.py +0 -0
  67. telegrinder/bot/rules/text.py +0 -0
  68. telegrinder/bot/scenario/__init__.py +0 -0
  69. telegrinder/bot/scenario/abc.py +0 -0
  70. telegrinder/bot/scenario/checkbox.py +0 -0
  71. telegrinder/bot/scenario/choice.py +0 -0
  72. telegrinder/client/__init__.py +2 -2
  73. telegrinder/client/abc.py +35 -12
  74. telegrinder/client/aiohttp.py +35 -22
  75. telegrinder/model.py +70 -23
  76. telegrinder/modules.py +22 -12
  77. telegrinder/msgspec_json.py +0 -0
  78. telegrinder/msgspec_utils.py +30 -10
  79. telegrinder/node/__init__.py +0 -0
  80. telegrinder/node/attachment.py +0 -0
  81. telegrinder/node/base.py +0 -0
  82. telegrinder/node/composer.py +0 -0
  83. telegrinder/node/container.py +0 -0
  84. telegrinder/node/message.py +0 -0
  85. telegrinder/node/rule.py +0 -0
  86. telegrinder/node/source.py +0 -0
  87. telegrinder/node/text.py +0 -0
  88. telegrinder/node/tools/__init__.py +0 -0
  89. telegrinder/node/tools/generator.py +0 -0
  90. telegrinder/node/update.py +0 -0
  91. telegrinder/rules.py +0 -0
  92. telegrinder/tools/__init__.py +2 -30
  93. telegrinder/tools/buttons.py +19 -5
  94. telegrinder/tools/error_handler/__init__.py +2 -0
  95. telegrinder/tools/error_handler/abc.py +5 -1
  96. telegrinder/tools/error_handler/error.py +10 -0
  97. telegrinder/tools/error_handler/error_handler.py +100 -81
  98. telegrinder/tools/formatting/__init__.py +0 -0
  99. telegrinder/tools/formatting/html.py +0 -0
  100. telegrinder/tools/formatting/links.py +0 -0
  101. telegrinder/tools/formatting/spec_html_formats.py +0 -0
  102. telegrinder/tools/global_context/__init__.py +0 -0
  103. telegrinder/tools/global_context/abc.py +0 -0
  104. telegrinder/tools/global_context/global_context.py +65 -67
  105. telegrinder/tools/global_context/telegrinder_ctx.py +0 -0
  106. telegrinder/tools/i18n/__init__.py +0 -0
  107. telegrinder/tools/i18n/base.py +0 -0
  108. telegrinder/tools/i18n/middleware/__init__.py +0 -0
  109. telegrinder/tools/i18n/middleware/base.py +0 -0
  110. telegrinder/tools/i18n/simple.py +0 -0
  111. telegrinder/tools/kb_set/__init__.py +0 -0
  112. telegrinder/tools/kb_set/base.py +0 -0
  113. telegrinder/tools/kb_set/yaml.py +3 -3
  114. telegrinder/tools/keyboard.py +17 -26
  115. telegrinder/tools/loop_wrapper/__init__.py +0 -0
  116. telegrinder/tools/loop_wrapper/abc.py +0 -0
  117. telegrinder/tools/loop_wrapper/loop_wrapper.py +0 -0
  118. telegrinder/tools/magic.py +1 -1
  119. telegrinder/tools/parse_mode.py +0 -0
  120. telegrinder/types/__init__.py +0 -0
  121. telegrinder/types/enums.py +13 -9
  122. telegrinder/types/methods.py +783 -673
  123. telegrinder/types/objects.py +317 -163
  124. {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/LICENSE +0 -0
  125. {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/METADATA +9 -7
  126. {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/RECORD +42 -41
  127. {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/WHEEL +1 -1
  128. telegrinder/tools/inline_query.py +0 -684
@@ -14,15 +14,8 @@ from telegrinder.types.objects import (
14
14
 
15
15
  from .buttons import Button, ButtonT, InlineButton, RowButtons
16
16
 
17
- DictStrAny = dict[str, typing.Any]
18
- AnyMarkup = InlineKeyboardMarkup | ReplyKeyboardMarkup
19
-
20
-
21
- def keyboard_remove(*, selective: bool | None = None) -> ReplyKeyboardRemove:
22
- return ReplyKeyboardRemove(
23
- remove_keyboard=True,
24
- selective=Nothing() if selective is None else Some(selective),
25
- )
17
+ DictStrAny: typing.TypeAlias = dict[str, typing.Any]
18
+ AnyMarkup: typing.TypeAlias = InlineKeyboardMarkup | ReplyKeyboardMarkup
26
19
 
27
20
 
28
21
  @dataclasses.dataclass
@@ -31,12 +24,12 @@ class KeyboardModel:
31
24
  one_time_keyboard: bool | Option[bool]
32
25
  selective: bool | Option[bool]
33
26
  is_persistent: bool | Option[bool]
34
- keyboard: list[list[dict[str, typing.Any]]]
27
+ keyboard: list[list[DictStrAny]]
35
28
 
36
29
 
37
30
  class ABCMarkup(ABC, typing.Generic[ButtonT]):
38
31
  BUTTON: type[ButtonT]
39
- keyboard: list[list[dict[str, typing.Any]]]
32
+ keyboard: list[list[DictStrAny]]
40
33
 
41
34
  @abstractmethod
42
35
  def dict(self) -> DictStrAny:
@@ -70,7 +63,7 @@ class ABCMarkup(ABC, typing.Generic[ButtonT]):
70
63
  self.keyboard.append([])
71
64
  return self
72
65
 
73
- def format(self, **format_data: typing.Dict[str, str]) -> "ABCMarkup":
66
+ def format(self, **format_data: str) -> typing.Self:
74
67
  copy_keyboard = self.__class__()
75
68
  for row in self.keyboard:
76
69
  for button in row:
@@ -85,22 +78,21 @@ class ABCMarkup(ABC, typing.Generic[ButtonT]):
85
78
  return self
86
79
 
87
80
 
81
+ @dataclasses.dataclass(kw_only=True)
88
82
  class Keyboard(ABCMarkup[Button], KeyboardModel):
89
83
  BUTTON = Button
90
84
 
91
- def __init__(
92
- self,
93
- *,
94
- resize_keyboard: bool = True,
95
- one_time_keyboard: bool = False,
96
- selective: bool = False,
97
- is_persistent: bool = False,
98
- ):
99
- self.keyboard = [[]]
100
- self.resize_keyboard = resize_keyboard
101
- self.one_time_keyboard = one_time_keyboard
102
- self.selective = selective
103
- self.is_persistent = is_persistent
85
+ keyboard: list[list[DictStrAny]] = dataclasses.field(
86
+ default_factory=lambda: [[]],
87
+ init=False,
88
+ )
89
+ resize_keyboard: bool = dataclasses.field(default=True)
90
+ one_time_keyboard: bool = dataclasses.field(default=False)
91
+ selective: bool = dataclasses.field(default=False)
92
+ is_persistent: bool = dataclasses.field(default=False)
93
+
94
+ def get_empty_markup(self, *, selective: bool = False) -> ReplyKeyboardRemove:
95
+ return ReplyKeyboardRemove(remove_keyboard=True, selective=selective) # type: ignore
104
96
 
105
97
  def dict(self) -> DictStrAny:
106
98
  self.keyboard = [row for row in self.keyboard if row]
@@ -133,5 +125,4 @@ __all__ = (
133
125
  "InlineKeyboard",
134
126
  "Keyboard",
135
127
  "KeyboardModel",
136
- "keyboard_remove",
137
128
  )
File without changes
File without changes
File without changes
@@ -8,7 +8,7 @@ if typing.TYPE_CHECKING:
8
8
 
9
9
  T = typing.TypeVar("T", bound=ABCRule)
10
10
 
11
- FuncType = types.FunctionType | typing.Callable
11
+ FuncType: typing.TypeAlias = types.FunctionType | typing.Callable[..., typing.Any]
12
12
  TRANSLATIONS_KEY = "_translations"
13
13
 
14
14
 
File without changes
File without changes
@@ -35,6 +35,8 @@ class ProgrammingLanguage(str, enum.Enum):
35
35
  HTML = "html"
36
36
  YAML = "yaml"
37
37
  JSON = "json"
38
+ MARKDOWN = "markdown"
39
+ MARKUP = "markup"
38
40
 
39
41
 
40
42
  class ChatAction(str, enum.Enum):
@@ -152,17 +154,19 @@ class ReactionEmoji(str, enum.Enum):
152
154
  ENRAGED_FACE = "😡"
153
155
 
154
156
 
155
- class DefaultUserColor(int, enum.Enum):
156
- """Type of DefaultUserColor.
157
+ class DefaultAccentColor(int, enum.Enum):
158
+ """Type of DefaultAccentColor.
157
159
 
158
160
  One of 7 possible user colors:
159
- - red
160
- - orange
161
- - purple
162
- - green
163
- - cyan
164
- - blue
165
- - pink
161
+ - Red
162
+ - Orange
163
+ - Purple
164
+ - Green
165
+ - Cyan
166
+ - Blue
167
+ - Pink
168
+
169
+ Docs: https://core.telegram.org/bots/api#accent-colors
166
170
  """
167
171
 
168
172
  RED = 0