telegrinder 1.0.0rc1__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.
Files changed (215) hide show
  1. telegrinder/__init__.py +258 -0
  2. telegrinder/__meta__.py +1 -0
  3. telegrinder/api/__init__.py +15 -0
  4. telegrinder/api/api.py +175 -0
  5. telegrinder/api/error.py +50 -0
  6. telegrinder/api/response.py +23 -0
  7. telegrinder/api/token.py +30 -0
  8. telegrinder/api/validators.py +30 -0
  9. telegrinder/bot/__init__.py +144 -0
  10. telegrinder/bot/bot.py +70 -0
  11. telegrinder/bot/cute_types/__init__.py +41 -0
  12. telegrinder/bot/cute_types/base.py +228 -0
  13. telegrinder/bot/cute_types/base.pyi +49 -0
  14. telegrinder/bot/cute_types/business_connection.py +9 -0
  15. telegrinder/bot/cute_types/business_messages_deleted.py +9 -0
  16. telegrinder/bot/cute_types/callback_query.py +248 -0
  17. telegrinder/bot/cute_types/chat_boost_removed.py +9 -0
  18. telegrinder/bot/cute_types/chat_boost_updated.py +9 -0
  19. telegrinder/bot/cute_types/chat_join_request.py +59 -0
  20. telegrinder/bot/cute_types/chat_member_updated.py +158 -0
  21. telegrinder/bot/cute_types/chosen_inline_result.py +11 -0
  22. telegrinder/bot/cute_types/inline_query.py +41 -0
  23. telegrinder/bot/cute_types/message.py +2809 -0
  24. telegrinder/bot/cute_types/message_reaction_count_updated.py +9 -0
  25. telegrinder/bot/cute_types/message_reaction_updated.py +9 -0
  26. telegrinder/bot/cute_types/paid_media_purchased.py +11 -0
  27. telegrinder/bot/cute_types/poll.py +9 -0
  28. telegrinder/bot/cute_types/poll_answer.py +9 -0
  29. telegrinder/bot/cute_types/pre_checkout_query.py +36 -0
  30. telegrinder/bot/cute_types/shipping_query.py +11 -0
  31. telegrinder/bot/cute_types/update.py +209 -0
  32. telegrinder/bot/cute_types/utils.py +141 -0
  33. telegrinder/bot/dispatch/__init__.py +99 -0
  34. telegrinder/bot/dispatch/abc.py +74 -0
  35. telegrinder/bot/dispatch/action.py +99 -0
  36. telegrinder/bot/dispatch/context.py +162 -0
  37. telegrinder/bot/dispatch/dispatch.py +362 -0
  38. telegrinder/bot/dispatch/handler/__init__.py +23 -0
  39. telegrinder/bot/dispatch/handler/abc.py +25 -0
  40. telegrinder/bot/dispatch/handler/audio_reply.py +43 -0
  41. telegrinder/bot/dispatch/handler/base.py +34 -0
  42. telegrinder/bot/dispatch/handler/document_reply.py +43 -0
  43. telegrinder/bot/dispatch/handler/func.py +73 -0
  44. telegrinder/bot/dispatch/handler/media_group_reply.py +43 -0
  45. telegrinder/bot/dispatch/handler/message_reply.py +35 -0
  46. telegrinder/bot/dispatch/handler/photo_reply.py +43 -0
  47. telegrinder/bot/dispatch/handler/sticker_reply.py +36 -0
  48. telegrinder/bot/dispatch/handler/video_reply.py +43 -0
  49. telegrinder/bot/dispatch/middleware/__init__.py +13 -0
  50. telegrinder/bot/dispatch/middleware/abc.py +112 -0
  51. telegrinder/bot/dispatch/middleware/box.py +32 -0
  52. telegrinder/bot/dispatch/middleware/filter.py +88 -0
  53. telegrinder/bot/dispatch/middleware/media_group.py +69 -0
  54. telegrinder/bot/dispatch/process.py +93 -0
  55. telegrinder/bot/dispatch/return_manager/__init__.py +21 -0
  56. telegrinder/bot/dispatch/return_manager/abc.py +107 -0
  57. telegrinder/bot/dispatch/return_manager/callback_query.py +19 -0
  58. telegrinder/bot/dispatch/return_manager/inline_query.py +14 -0
  59. telegrinder/bot/dispatch/return_manager/message.py +34 -0
  60. telegrinder/bot/dispatch/return_manager/pre_checkout_query.py +19 -0
  61. telegrinder/bot/dispatch/return_manager/utils.py +20 -0
  62. telegrinder/bot/dispatch/router/__init__.py +4 -0
  63. telegrinder/bot/dispatch/router/abc.py +15 -0
  64. telegrinder/bot/dispatch/router/base.py +154 -0
  65. telegrinder/bot/dispatch/view/__init__.py +15 -0
  66. telegrinder/bot/dispatch/view/abc.py +15 -0
  67. telegrinder/bot/dispatch/view/base.py +226 -0
  68. telegrinder/bot/dispatch/view/box.py +207 -0
  69. telegrinder/bot/dispatch/view/media_group.py +25 -0
  70. telegrinder/bot/dispatch/waiter_machine/__init__.py +25 -0
  71. telegrinder/bot/dispatch/waiter_machine/actions.py +16 -0
  72. telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +13 -0
  73. telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +53 -0
  74. telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +61 -0
  75. telegrinder/bot/dispatch/waiter_machine/hasher/message.py +49 -0
  76. telegrinder/bot/dispatch/waiter_machine/machine.py +264 -0
  77. telegrinder/bot/dispatch/waiter_machine/middleware.py +77 -0
  78. telegrinder/bot/dispatch/waiter_machine/short_state.py +105 -0
  79. telegrinder/bot/polling/__init__.py +4 -0
  80. telegrinder/bot/polling/abc.py +25 -0
  81. telegrinder/bot/polling/error_handler.py +93 -0
  82. telegrinder/bot/polling/polling.py +167 -0
  83. telegrinder/bot/polling/utils.py +12 -0
  84. telegrinder/bot/rules/__init__.py +166 -0
  85. telegrinder/bot/rules/abc.py +150 -0
  86. telegrinder/bot/rules/button.py +20 -0
  87. telegrinder/bot/rules/callback_data.py +109 -0
  88. telegrinder/bot/rules/chat_join.py +28 -0
  89. telegrinder/bot/rules/chat_member_updated.py +145 -0
  90. telegrinder/bot/rules/command.py +137 -0
  91. telegrinder/bot/rules/enum_text.py +29 -0
  92. telegrinder/bot/rules/func.py +21 -0
  93. telegrinder/bot/rules/fuzzy.py +21 -0
  94. telegrinder/bot/rules/inline.py +45 -0
  95. telegrinder/bot/rules/integer.py +19 -0
  96. telegrinder/bot/rules/is_from.py +213 -0
  97. telegrinder/bot/rules/logic.py +22 -0
  98. telegrinder/bot/rules/magic.py +60 -0
  99. telegrinder/bot/rules/markup.py +51 -0
  100. telegrinder/bot/rules/media.py +13 -0
  101. telegrinder/bot/rules/mention.py +15 -0
  102. telegrinder/bot/rules/message_entities.py +37 -0
  103. telegrinder/bot/rules/node.py +43 -0
  104. telegrinder/bot/rules/payload.py +89 -0
  105. telegrinder/bot/rules/payment_invoice.py +14 -0
  106. telegrinder/bot/rules/regex.py +34 -0
  107. telegrinder/bot/rules/rule_enum.py +71 -0
  108. telegrinder/bot/rules/start.py +73 -0
  109. telegrinder/bot/rules/state.py +35 -0
  110. telegrinder/bot/rules/text.py +27 -0
  111. telegrinder/bot/rules/update.py +14 -0
  112. telegrinder/bot/scenario/__init__.py +5 -0
  113. telegrinder/bot/scenario/abc.py +16 -0
  114. telegrinder/bot/scenario/checkbox.py +183 -0
  115. telegrinder/bot/scenario/choice.py +44 -0
  116. telegrinder/client/__init__.py +11 -0
  117. telegrinder/client/abc.py +136 -0
  118. telegrinder/client/form_data.py +34 -0
  119. telegrinder/client/rnet.py +198 -0
  120. telegrinder/model.py +133 -0
  121. telegrinder/model.pyi +57 -0
  122. telegrinder/modules.py +1081 -0
  123. telegrinder/msgspec_utils/__init__.py +42 -0
  124. telegrinder/msgspec_utils/abc.py +16 -0
  125. telegrinder/msgspec_utils/custom_types/__init__.py +6 -0
  126. telegrinder/msgspec_utils/custom_types/datetime.py +24 -0
  127. telegrinder/msgspec_utils/custom_types/enum_meta.py +61 -0
  128. telegrinder/msgspec_utils/custom_types/literal.py +25 -0
  129. telegrinder/msgspec_utils/custom_types/option.py +17 -0
  130. telegrinder/msgspec_utils/decoder.py +388 -0
  131. telegrinder/msgspec_utils/encoder.py +204 -0
  132. telegrinder/msgspec_utils/json.py +15 -0
  133. telegrinder/msgspec_utils/tools.py +80 -0
  134. telegrinder/node/__init__.py +80 -0
  135. telegrinder/node/compose.py +193 -0
  136. telegrinder/node/nodes/__init__.py +96 -0
  137. telegrinder/node/nodes/attachment.py +169 -0
  138. telegrinder/node/nodes/callback_query.py +25 -0
  139. telegrinder/node/nodes/channel.py +97 -0
  140. telegrinder/node/nodes/command.py +33 -0
  141. telegrinder/node/nodes/error.py +43 -0
  142. telegrinder/node/nodes/event.py +70 -0
  143. telegrinder/node/nodes/file.py +39 -0
  144. telegrinder/node/nodes/global_node.py +66 -0
  145. telegrinder/node/nodes/i18n.py +110 -0
  146. telegrinder/node/nodes/me.py +26 -0
  147. telegrinder/node/nodes/message_entities.py +15 -0
  148. telegrinder/node/nodes/payload.py +84 -0
  149. telegrinder/node/nodes/reply_message.py +14 -0
  150. telegrinder/node/nodes/source.py +172 -0
  151. telegrinder/node/nodes/state_mutator.py +71 -0
  152. telegrinder/node/nodes/text.py +62 -0
  153. telegrinder/node/scope.py +88 -0
  154. telegrinder/node/utils.py +38 -0
  155. telegrinder/py.typed +0 -0
  156. telegrinder/rules.py +1 -0
  157. telegrinder/tools/__init__.py +183 -0
  158. telegrinder/tools/aio.py +147 -0
  159. telegrinder/tools/final.py +21 -0
  160. telegrinder/tools/formatting/__init__.py +85 -0
  161. telegrinder/tools/formatting/deep_links/__init__.py +39 -0
  162. telegrinder/tools/formatting/deep_links/links.py +468 -0
  163. telegrinder/tools/formatting/deep_links/parsing.py +88 -0
  164. telegrinder/tools/formatting/deep_links/validators.py +8 -0
  165. telegrinder/tools/formatting/html.py +241 -0
  166. telegrinder/tools/fullname.py +82 -0
  167. telegrinder/tools/global_context/__init__.py +13 -0
  168. telegrinder/tools/global_context/abc.py +63 -0
  169. telegrinder/tools/global_context/builtin_context.py +45 -0
  170. telegrinder/tools/global_context/global_context.py +614 -0
  171. telegrinder/tools/input_file_directory.py +30 -0
  172. telegrinder/tools/keyboard/__init__.py +6 -0
  173. telegrinder/tools/keyboard/abc.py +84 -0
  174. telegrinder/tools/keyboard/base.py +108 -0
  175. telegrinder/tools/keyboard/button.py +181 -0
  176. telegrinder/tools/keyboard/data.py +31 -0
  177. telegrinder/tools/keyboard/keyboard.py +160 -0
  178. telegrinder/tools/keyboard/utils.py +95 -0
  179. telegrinder/tools/lifespan.py +188 -0
  180. telegrinder/tools/limited_dict.py +35 -0
  181. telegrinder/tools/loop_wrapper.py +271 -0
  182. telegrinder/tools/magic/__init__.py +29 -0
  183. telegrinder/tools/magic/annotations.py +172 -0
  184. telegrinder/tools/magic/descriptors.py +57 -0
  185. telegrinder/tools/magic/function.py +254 -0
  186. telegrinder/tools/magic/inspect.py +16 -0
  187. telegrinder/tools/magic/shortcut.py +107 -0
  188. telegrinder/tools/member_descriptor_proxy.py +95 -0
  189. telegrinder/tools/parse_mode.py +12 -0
  190. telegrinder/tools/serialization/__init__.py +5 -0
  191. telegrinder/tools/serialization/abc.py +34 -0
  192. telegrinder/tools/serialization/json_ser.py +60 -0
  193. telegrinder/tools/serialization/msgpack_ser.py +197 -0
  194. telegrinder/tools/serialization/utils.py +18 -0
  195. telegrinder/tools/singleton/__init__.py +4 -0
  196. telegrinder/tools/singleton/abc.py +14 -0
  197. telegrinder/tools/singleton/singleton.py +18 -0
  198. telegrinder/tools/state_mutator/__init__.py +4 -0
  199. telegrinder/tools/state_mutator/mutation.py +85 -0
  200. telegrinder/tools/state_storage/__init__.py +4 -0
  201. telegrinder/tools/state_storage/abc.py +38 -0
  202. telegrinder/tools/state_storage/memory.py +27 -0
  203. telegrinder/tools/strings.py +22 -0
  204. telegrinder/types/__init__.py +323 -0
  205. telegrinder/types/enums.py +754 -0
  206. telegrinder/types/input_file.py +51 -0
  207. telegrinder/types/methods.py +6143 -0
  208. telegrinder/types/methods_utils.py +66 -0
  209. telegrinder/types/objects.py +8184 -0
  210. telegrinder/types/webapp.py +129 -0
  211. telegrinder/verification_utils.py +35 -0
  212. telegrinder-1.0.0rc1.dist-info/METADATA +166 -0
  213. telegrinder-1.0.0rc1.dist-info/RECORD +215 -0
  214. telegrinder-1.0.0rc1.dist-info/WHEEL +4 -0
  215. telegrinder-1.0.0rc1.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,183 @@
1
+ from telegrinder.tools.aio import (
2
+ TaskGroup,
3
+ cancel_future,
4
+ get_tasks_results,
5
+ maybe_awaitable,
6
+ next_generator,
7
+ run_task,
8
+ send_generator_value,
9
+ stop_generator,
10
+ )
11
+ from telegrinder.tools.formatting import (
12
+ HTML,
13
+ blockquote,
14
+ bold,
15
+ code_inline,
16
+ escape,
17
+ italic,
18
+ link,
19
+ mention,
20
+ monospace,
21
+ pre_code,
22
+ spoiler,
23
+ strike,
24
+ tg_bot_attach_open_any_chat,
25
+ tg_bot_attach_open_current_chat,
26
+ tg_bot_attach_open_specific_chat,
27
+ tg_bot_start_link,
28
+ tg_bot_startchannel_link,
29
+ tg_bot_startgroup_link,
30
+ tg_chat_folder_link,
31
+ tg_chat_invite_link,
32
+ tg_direct_mini_app_link,
33
+ tg_emoji,
34
+ tg_emoji_link,
35
+ tg_emoji_stickerset_link,
36
+ tg_invoice_link,
37
+ tg_language_pack_link,
38
+ tg_main_mini_app_link,
39
+ tg_mention_link,
40
+ tg_open_message_link,
41
+ tg_premium_multigift_link,
42
+ tg_premium_offer_link,
43
+ tg_private_channel_boost_link,
44
+ tg_private_message_link,
45
+ tg_public_channel_boost_link,
46
+ tg_public_message_link,
47
+ tg_public_username_link,
48
+ tg_share_link,
49
+ tg_story_link,
50
+ underline,
51
+ )
52
+ from telegrinder.tools.fullname import fullname
53
+ from telegrinder.tools.global_context import (
54
+ ABCGlobalContext,
55
+ CtxVar,
56
+ GlobalContext,
57
+ GlobalCtxVar,
58
+ TelegrinderContext,
59
+ ctx_var,
60
+ runtime_init,
61
+ )
62
+ from telegrinder.tools.input_file_directory import InputFileDirectory
63
+ from telegrinder.tools.keyboard import ABCKeyboard, Button, InlineButton, InlineKeyboard, Keyboard, RowButtons
64
+ from telegrinder.tools.lifespan import Lifespan
65
+ from telegrinder.tools.limited_dict import LimitedDict
66
+ from telegrinder.tools.loop_wrapper import DelayedTask, LoopWrapper
67
+ from telegrinder.tools.magic import (
68
+ Annotations,
69
+ Bundle,
70
+ additional_property,
71
+ bundle,
72
+ get_default_args,
73
+ get_func_annotations,
74
+ get_func_parameters,
75
+ get_generic_parameters,
76
+ resolve_arg_names,
77
+ resolve_kwonly_arg_names,
78
+ resolve_posonly_arg_names,
79
+ shortcut,
80
+ )
81
+ from telegrinder.tools.parse_mode import ParseMode
82
+ from telegrinder.tools.serialization import (
83
+ ABCDataSerializer,
84
+ JSONSerializer,
85
+ MsgPackSerializer,
86
+ )
87
+ from telegrinder.tools.singleton import ABCSingleton, ABCSingletonMeta, Singleton, SingletonMeta
88
+ from telegrinder.tools.state_storage import ABCStateStorage, MemoryStateStorage, StateData
89
+ from telegrinder.tools.strings import to_utf16_map, utf16_to_py_index
90
+
91
+ __all__ = (
92
+ "HTML",
93
+ "ABCDataSerializer",
94
+ "ABCGlobalContext",
95
+ "ABCKeyboard",
96
+ "ABCSingleton",
97
+ "ABCSingletonMeta",
98
+ "ABCStateStorage",
99
+ "Annotations",
100
+ "Bundle",
101
+ "Button",
102
+ "CtxVar",
103
+ "DelayedTask",
104
+ "GlobalContext",
105
+ "GlobalCtxVar",
106
+ "InlineButton",
107
+ "InlineKeyboard",
108
+ "InputFileDirectory",
109
+ "JSONSerializer",
110
+ "Keyboard",
111
+ "Lifespan",
112
+ "LimitedDict",
113
+ "LoopWrapper",
114
+ "MemoryStateStorage",
115
+ "MsgPackSerializer",
116
+ "ParseMode",
117
+ "RowButtons",
118
+ "Singleton",
119
+ "SingletonMeta",
120
+ "StateData",
121
+ "TaskGroup",
122
+ "TelegrinderContext",
123
+ "additional_property",
124
+ "blockquote",
125
+ "bold",
126
+ "bundle",
127
+ "cancel_future",
128
+ "code_inline",
129
+ "ctx_var",
130
+ "escape",
131
+ "fullname",
132
+ "get_default_args",
133
+ "get_func_annotations",
134
+ "get_func_parameters",
135
+ "get_generic_parameters",
136
+ "get_tasks_results",
137
+ "italic",
138
+ "link",
139
+ "maybe_awaitable",
140
+ "mention",
141
+ "monospace",
142
+ "next_generator",
143
+ "pre_code",
144
+ "resolve_arg_names",
145
+ "resolve_kwonly_arg_names",
146
+ "resolve_posonly_arg_names",
147
+ "run_task",
148
+ "runtime_init",
149
+ "send_generator_value",
150
+ "shortcut",
151
+ "spoiler",
152
+ "stop_generator",
153
+ "strike",
154
+ "tg_bot_attach_open_any_chat",
155
+ "tg_bot_attach_open_current_chat",
156
+ "tg_bot_attach_open_specific_chat",
157
+ "tg_bot_start_link",
158
+ "tg_bot_startchannel_link",
159
+ "tg_bot_startgroup_link",
160
+ "tg_chat_folder_link",
161
+ "tg_chat_invite_link",
162
+ "tg_direct_mini_app_link",
163
+ "tg_emoji",
164
+ "tg_emoji_link",
165
+ "tg_emoji_stickerset_link",
166
+ "tg_invoice_link",
167
+ "tg_language_pack_link",
168
+ "tg_main_mini_app_link",
169
+ "tg_mention_link",
170
+ "tg_open_message_link",
171
+ "tg_premium_multigift_link",
172
+ "tg_premium_offer_link",
173
+ "tg_private_channel_boost_link",
174
+ "tg_private_message_link",
175
+ "tg_public_channel_boost_link",
176
+ "tg_public_message_link",
177
+ "tg_public_username_link",
178
+ "tg_share_link",
179
+ "tg_story_link",
180
+ "to_utf16_map",
181
+ "underline",
182
+ "utf16_to_py_index",
183
+ )
@@ -0,0 +1,147 @@
1
+ import asyncio
2
+ import typing
3
+ from contextlib import suppress
4
+ from inspect import isasyncgen, isawaitable
5
+
6
+ if typing.TYPE_CHECKING:
7
+ from contextvars import Context
8
+
9
+ type Generator[Yield, Send, Return] = typing.AsyncGenerator[Yield, Send] | typing.Generator[Yield, Send, Return]
10
+
11
+
12
+ def loop_is_running() -> bool:
13
+ with suppress(RuntimeError):
14
+ asyncio.get_running_loop()
15
+ return True
16
+
17
+ return False
18
+
19
+
20
+ def get_tasks_results[T](tasks: set[asyncio.Task[T]], /) -> tuple[T, ...]:
21
+ return tuple(task.result() for task in tasks if not task.cancelled() and not task.exception())
22
+
23
+
24
+ def run_task[T](
25
+ task: typing.Awaitable[T],
26
+ /,
27
+ *,
28
+ loop: asyncio.AbstractEventLoop | None = None,
29
+ ) -> T:
30
+ loop = loop or asyncio.get_event_loop()
31
+ return loop.run_until_complete(future=task)
32
+
33
+
34
+ async def next_generator[T](generator: Generator[T, typing.Any, typing.Any], /) -> T:
35
+ return await send_generator_value(generator, None)
36
+
37
+
38
+ async def send_generator_value[Yield, Send](
39
+ generator: Generator[Yield, Send, typing.Any],
40
+ value: Send | None,
41
+ /,
42
+ ) -> Yield:
43
+ try:
44
+ return (
45
+ await generator.asend(value) if isasyncgen(generator) else generator.send(value) # type: ignore
46
+ )
47
+ except StopIteration as exc:
48
+ raise StopGenerator(exc.value, exc.args) from exc
49
+
50
+
51
+ async def stop_generator[Send, Return](
52
+ generator: Generator[typing.Any, Send, Return],
53
+ with_value: Send | None = None,
54
+ /,
55
+ ) -> Return | None:
56
+ try:
57
+ await send_generator_value(generator, with_value)
58
+ except (StopGenerator, StopAsyncIteration) as exc:
59
+ return exc.value if isinstance(exc, StopGenerator) else None
60
+
61
+
62
+ async def maybe_awaitable[T](obj: T | typing.Awaitable[T], /) -> T:
63
+ if isawaitable(obj):
64
+ return await obj
65
+ return obj
66
+
67
+
68
+ # Source code: https://github.com/facebookincubator/later/blob/main/later/task.py#L68
69
+ async def cancel_future(fut: asyncio.Future[typing.Any], /) -> None:
70
+ if fut.done():
71
+ return
72
+
73
+ fut.cancel()
74
+ exc: asyncio.CancelledError | None = None
75
+
76
+ while not fut.done():
77
+ shielded = asyncio.shield(fut)
78
+ try:
79
+ await asyncio.wait([shielded])
80
+ except asyncio.CancelledError as ex:
81
+ exc = ex
82
+ finally:
83
+ # Insure we handle the exception/value that may exist on the shielded task
84
+ # This will prevent errors logged to the asyncio logger
85
+ if shielded.done() and not shielded.cancelled() and not shielded.exception():
86
+ shielded.result()
87
+
88
+ if fut.cancelled():
89
+ if exc is None:
90
+ return
91
+ raise exc from None
92
+
93
+ ex = fut.exception()
94
+ if ex is not None:
95
+ raise ex from None
96
+
97
+ raise asyncio.InvalidStateError(
98
+ f"Task did not raise CancelledError on cancel: {fut!r} had result {fut.result()!r}",
99
+ )
100
+
101
+
102
+ class StopGenerator(Exception):
103
+ value: typing.Any
104
+
105
+ def __init__(self, value: typing.Any, *args: object) -> None:
106
+ super().__init__(*args)
107
+ self.value = value
108
+
109
+
110
+ class TaskGroup[T](asyncio.TaskGroup):
111
+ _all_tasks: set[asyncio.Task[typing.Any]]
112
+
113
+ def __init__(self, loop: asyncio.AbstractEventLoop | None = None) -> None:
114
+ super().__init__()
115
+ self._all_tasks = set()
116
+ self._loop = loop
117
+
118
+ def results(self) -> typing.Iterable[T]:
119
+ while self._all_tasks:
120
+ task = self._all_tasks.pop()
121
+ if not task.cancelled() and task.exception() is None:
122
+ yield task.result()
123
+
124
+ def create_task(
125
+ self,
126
+ coro: typing.Coroutine[typing.Any, typing.Any, T],
127
+ /,
128
+ name: str | None = None,
129
+ context: Context | None = None,
130
+ ) -> asyncio.Task[T]:
131
+ task = super().create_task(coro)
132
+ self._all_tasks.add(task)
133
+ return task
134
+
135
+
136
+ __all__ = (
137
+ "StopGenerator",
138
+ "TaskGroup",
139
+ "cancel_future",
140
+ "get_tasks_results",
141
+ "loop_is_running",
142
+ "maybe_awaitable",
143
+ "next_generator",
144
+ "run_task",
145
+ "send_generator_value",
146
+ "stop_generator",
147
+ )
@@ -0,0 +1,21 @@
1
+ import typing
2
+
3
+ from telegrinder.tools.fullname import fullname
4
+
5
+
6
+ class Final:
7
+ if not typing.TYPE_CHECKING:
8
+
9
+ def __new__(cls, *args, **kwargs):
10
+ if cls is Final:
11
+ raise TypeError("Class Final cannot be instantiate.")
12
+ return super().__new__(cls, *args, **kwargs)
13
+
14
+ @typing.final
15
+ def __init_subclass__(cls, **kwargs: typing.Any) -> None:
16
+ for base in cls.__bases__:
17
+ if base is not Final and issubclass(base, Final):
18
+ raise TypeError(f"Final class `{fullname(base)}` cannot be subclassed.")
19
+
20
+
21
+ __all__ = ("Final",)
@@ -0,0 +1,85 @@
1
+ from telegrinder.tools.formatting.deep_links import (
2
+ tg_bot_attach_open_any_chat,
3
+ tg_bot_attach_open_current_chat,
4
+ tg_bot_attach_open_specific_chat,
5
+ tg_bot_start_link,
6
+ tg_bot_startchannel_link,
7
+ tg_bot_startgroup_link,
8
+ tg_chat_folder_link,
9
+ tg_chat_invite_link,
10
+ tg_direct_mini_app_link,
11
+ tg_emoji_link,
12
+ tg_emoji_stickerset_link,
13
+ tg_invoice_link,
14
+ tg_language_pack_link,
15
+ tg_main_mini_app_link,
16
+ tg_mention_link,
17
+ tg_open_message_link,
18
+ tg_premium_multigift_link,
19
+ tg_premium_offer_link,
20
+ tg_private_channel_boost_link,
21
+ tg_private_message_link,
22
+ tg_public_channel_boost_link,
23
+ tg_public_message_link,
24
+ tg_public_username_link,
25
+ tg_share_link,
26
+ tg_story_link,
27
+ )
28
+ from telegrinder.tools.formatting.html import (
29
+ HTML,
30
+ blockquote,
31
+ bold,
32
+ code_inline,
33
+ escape,
34
+ italic,
35
+ link,
36
+ mention,
37
+ monospace,
38
+ pre_code,
39
+ spoiler,
40
+ strike,
41
+ tg_emoji,
42
+ underline,
43
+ )
44
+
45
+ __all__ = (
46
+ "HTML",
47
+ "blockquote",
48
+ "bold",
49
+ "code_inline",
50
+ "escape",
51
+ "italic",
52
+ "link",
53
+ "mention",
54
+ "monospace",
55
+ "pre_code",
56
+ "spoiler",
57
+ "strike",
58
+ "tg_bot_attach_open_any_chat",
59
+ "tg_bot_attach_open_current_chat",
60
+ "tg_bot_attach_open_specific_chat",
61
+ "tg_bot_start_link",
62
+ "tg_bot_startchannel_link",
63
+ "tg_bot_startgroup_link",
64
+ "tg_chat_folder_link",
65
+ "tg_chat_invite_link",
66
+ "tg_direct_mini_app_link",
67
+ "tg_emoji",
68
+ "tg_emoji_link",
69
+ "tg_emoji_stickerset_link",
70
+ "tg_invoice_link",
71
+ "tg_language_pack_link",
72
+ "tg_main_mini_app_link",
73
+ "tg_mention_link",
74
+ "tg_open_message_link",
75
+ "tg_premium_multigift_link",
76
+ "tg_premium_offer_link",
77
+ "tg_private_channel_boost_link",
78
+ "tg_private_message_link",
79
+ "tg_public_channel_boost_link",
80
+ "tg_public_message_link",
81
+ "tg_public_username_link",
82
+ "tg_share_link",
83
+ "tg_story_link",
84
+ "underline",
85
+ )
@@ -0,0 +1,39 @@
1
+ from telegrinder.tools.formatting.deep_links.links import *
2
+ from telegrinder.tools.formatting.deep_links.parsing import *
3
+ from telegrinder.tools.formatting.deep_links.validators import *
4
+
5
+ __all__ = (
6
+ "NO_VALUE",
7
+ "NoValue",
8
+ "Parameter",
9
+ "get_parameter_metadata",
10
+ "get_query_params",
11
+ "parse_deep_link",
12
+ "parse_query_params",
13
+ "separate_by_plus_char",
14
+ "tg_bot_attach_open_any_chat",
15
+ "tg_bot_attach_open_current_chat",
16
+ "tg_bot_attach_open_specific_chat",
17
+ "tg_bot_start_link",
18
+ "tg_bot_startchannel_link",
19
+ "tg_bot_startgroup_link",
20
+ "tg_chat_folder_link",
21
+ "tg_chat_invite_link",
22
+ "tg_direct_mini_app_link",
23
+ "tg_emoji_link",
24
+ "tg_emoji_stickerset_link",
25
+ "tg_invoice_link",
26
+ "tg_language_pack_link",
27
+ "tg_main_mini_app_link",
28
+ "tg_mention_link",
29
+ "tg_open_message_link",
30
+ "tg_premium_multigift_link",
31
+ "tg_premium_offer_link",
32
+ "tg_private_channel_boost_link",
33
+ "tg_private_message_link",
34
+ "tg_public_channel_boost_link",
35
+ "tg_public_message_link",
36
+ "tg_public_username_link",
37
+ "tg_share_link",
38
+ "tg_story_link",
39
+ )