telegrinder 0.1.dev159__py3-none-any.whl → 0.1.dev161__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 (127) hide show
  1. telegrinder/__init__.py +4 -2
  2. telegrinder/api/__init__.py +0 -0
  3. telegrinder/api/abc.py +5 -0
  4. telegrinder/api/api.py +4 -4
  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 +0 -0
  11. telegrinder/bot/cute_types/callback_query.py +81 -85
  12. telegrinder/bot/cute_types/inline_query.py +36 -9
  13. telegrinder/bot/cute_types/message.py +524 -568
  14. telegrinder/bot/cute_types/update.py +0 -0
  15. telegrinder/bot/cute_types/utils.py +201 -453
  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 +20 -16
  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 +0 -0
  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 +2 -2
  69. telegrinder/bot/scenario/abc.py +0 -0
  70. telegrinder/bot/scenario/checkbox.py +9 -13
  71. telegrinder/bot/scenario/choice.py +2 -2
  72. telegrinder/client/__init__.py +0 -0
  73. telegrinder/client/abc.py +0 -0
  74. telegrinder/client/aiohttp.py +0 -0
  75. telegrinder/model.py +35 -36
  76. telegrinder/modules.py +21 -11
  77. telegrinder/msgspec_json.py +0 -0
  78. telegrinder/msgspec_utils.py +2 -2
  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 -3
  93. telegrinder/tools/buttons.py +0 -0
  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 +2 -0
  122. telegrinder/types/methods.py +477 -526
  123. telegrinder/types/objects.py +209 -97
  124. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/LICENSE +0 -0
  125. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/METADATA +9 -8
  126. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/RECORD +38 -37
  127. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/WHEEL +1 -1
@@ -8,7 +8,7 @@ from telegrinder.tools.keyboard import InlineKeyboard, Keyboard
8
8
 
9
9
  from .base import KeyboardSetBase, KeyboardSetError
10
10
 
11
- PathLike = str | os.PathLike[str]
11
+ PathLike: typing.TypeAlias = str | os.PathLike[str]
12
12
 
13
13
 
14
14
  class KeyboardSetYAML(KeyboardSetBase):
@@ -27,7 +27,7 @@ class KeyboardSetYAML(KeyboardSetBase):
27
27
  encoding="UTF-8",
28
28
  ),
29
29
  yaml.Loader,
30
- )
30
+ )
31
31
  for name, hint in typing.get_type_hints(cls).items():
32
32
  g = re.match(r"(?:kb_|keyboard_)(.+)", name.lower())
33
33
  if not g:
@@ -47,7 +47,7 @@ class KeyboardSetYAML(KeyboardSetBase):
47
47
  "Keyboard should be dict with field buttons which must be a list, "
48
48
  "check documentation."
49
49
  )
50
-
50
+
51
51
  buttons = kb_config.pop("buttons")
52
52
  new_keyboard: Keyboard | InlineKeyboard = hint(**kb_config)
53
53
  for button in buttons:
@@ -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):