telegrinder 0.1.dev170__py3-none-any.whl → 0.1.dev171__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 (79) hide show
  1. telegrinder/api/abc.py +7 -1
  2. telegrinder/api/api.py +12 -3
  3. telegrinder/api/error.py +2 -1
  4. telegrinder/bot/bot.py +6 -1
  5. telegrinder/bot/cute_types/base.py +144 -17
  6. telegrinder/bot/cute_types/callback_query.py +6 -1
  7. telegrinder/bot/cute_types/chat_member_updated.py +1 -2
  8. telegrinder/bot/cute_types/message.py +23 -11
  9. telegrinder/bot/cute_types/update.py +48 -0
  10. telegrinder/bot/cute_types/utils.py +2 -465
  11. telegrinder/bot/dispatch/__init__.py +2 -3
  12. telegrinder/bot/dispatch/abc.py +6 -3
  13. telegrinder/bot/dispatch/context.py +6 -6
  14. telegrinder/bot/dispatch/dispatch.py +61 -23
  15. telegrinder/bot/dispatch/handler/abc.py +2 -2
  16. telegrinder/bot/dispatch/handler/func.py +36 -17
  17. telegrinder/bot/dispatch/handler/message_reply.py +2 -2
  18. telegrinder/bot/dispatch/middleware/abc.py +2 -2
  19. telegrinder/bot/dispatch/process.py +10 -10
  20. telegrinder/bot/dispatch/return_manager/abc.py +3 -3
  21. telegrinder/bot/dispatch/view/abc.py +12 -15
  22. telegrinder/bot/dispatch/view/box.py +73 -62
  23. telegrinder/bot/dispatch/view/message.py +11 -3
  24. telegrinder/bot/dispatch/view/raw.py +3 -0
  25. telegrinder/bot/dispatch/waiter_machine/machine.py +2 -2
  26. telegrinder/bot/dispatch/waiter_machine/middleware.py +1 -1
  27. telegrinder/bot/dispatch/waiter_machine/short_state.py +2 -1
  28. telegrinder/bot/polling/polling.py +3 -3
  29. telegrinder/bot/rules/abc.py +11 -7
  30. telegrinder/bot/rules/adapter/event.py +7 -4
  31. telegrinder/bot/rules/adapter/node.py +1 -1
  32. telegrinder/bot/rules/command.py +5 -7
  33. telegrinder/bot/rules/func.py +1 -1
  34. telegrinder/bot/rules/fuzzy.py +1 -1
  35. telegrinder/bot/rules/integer.py +1 -2
  36. telegrinder/bot/rules/markup.py +3 -3
  37. telegrinder/bot/rules/message_entities.py +1 -1
  38. telegrinder/bot/rules/node.py +2 -2
  39. telegrinder/bot/rules/regex.py +1 -1
  40. telegrinder/bot/rules/rule_enum.py +1 -1
  41. telegrinder/bot/scenario/checkbox.py +2 -2
  42. telegrinder/model.py +85 -46
  43. telegrinder/modules.py +3 -3
  44. telegrinder/msgspec_utils.py +33 -5
  45. telegrinder/node/__init__.py +20 -11
  46. telegrinder/node/attachment.py +19 -16
  47. telegrinder/node/base.py +120 -24
  48. telegrinder/node/callback_query.py +5 -9
  49. telegrinder/node/command.py +6 -2
  50. telegrinder/node/composer.py +82 -54
  51. telegrinder/node/container.py +4 -4
  52. telegrinder/node/event.py +59 -0
  53. telegrinder/node/me.py +3 -0
  54. telegrinder/node/message.py +6 -10
  55. telegrinder/node/polymorphic.py +11 -12
  56. telegrinder/node/rule.py +27 -5
  57. telegrinder/node/source.py +10 -11
  58. telegrinder/node/text.py +4 -4
  59. telegrinder/node/update.py +1 -2
  60. telegrinder/py.typed +0 -0
  61. telegrinder/tools/__init__.py +2 -2
  62. telegrinder/tools/buttons.py +5 -10
  63. telegrinder/tools/error_handler/error.py +2 -0
  64. telegrinder/tools/error_handler/error_handler.py +1 -1
  65. telegrinder/tools/formatting/spec_html_formats.py +10 -10
  66. telegrinder/tools/global_context/__init__.py +2 -2
  67. telegrinder/tools/global_context/global_context.py +2 -2
  68. telegrinder/tools/global_context/telegrinder_ctx.py +4 -4
  69. telegrinder/tools/keyboard.py +2 -2
  70. telegrinder/tools/loop_wrapper/loop_wrapper.py +39 -5
  71. telegrinder/tools/magic.py +48 -15
  72. telegrinder/types/enums.py +1 -0
  73. telegrinder/types/methods.py +14 -5
  74. telegrinder/types/objects.py +3 -0
  75. {telegrinder-0.1.dev170.dist-info → telegrinder-0.1.dev171.dist-info}/METADATA +2 -2
  76. telegrinder-0.1.dev171.dist-info/RECORD +145 -0
  77. telegrinder-0.1.dev170.dist-info/RECORD +0 -143
  78. {telegrinder-0.1.dev170.dist-info → telegrinder-0.1.dev171.dist-info}/LICENSE +0 -0
  79. {telegrinder-0.1.dev170.dist-info → telegrinder-0.1.dev171.dist-info}/WHEEL +0 -0
@@ -2,40 +2,12 @@ import typing
2
2
 
3
3
  from telegrinder.model import get_params
4
4
  from telegrinder.types import (
5
- ChatPermissions,
6
- InlineKeyboardMarkup,
7
- InlineQueryResultArticle,
8
- InlineQueryResultAudio,
9
- InlineQueryResultCachedAudio,
10
- InlineQueryResultCachedDocument,
11
- InlineQueryResultCachedGif,
12
- InlineQueryResultCachedMpeg4Gif,
13
- InlineQueryResultCachedPhoto,
14
- InlineQueryResultCachedSticker,
15
- InlineQueryResultCachedVideo,
16
- InlineQueryResultCachedVoice,
17
- InlineQueryResultContact,
18
- InlineQueryResultDocument,
19
- InlineQueryResultGame,
20
- InlineQueryResultGif,
21
- InlineQueryResultLocation,
22
- InlineQueryResultMpeg4Gif,
23
- InlineQueryResultPhoto,
24
- InlineQueryResultVenue,
25
- InlineQueryResultVideo,
26
- InlineQueryResultVoice,
27
- InputContactMessageContent,
28
5
  InputFile,
29
- InputInvoiceMessageContent,
30
- InputLocationMessageContent,
31
6
  InputMediaAnimation,
32
7
  InputMediaAudio,
33
8
  InputMediaDocument,
34
9
  InputMediaPhoto,
35
10
  InputMediaVideo,
36
- InputTextMessageContent,
37
- InputVenueMessageContent,
38
- LabeledPrice,
39
11
  LinkPreviewOptions,
40
12
  MessageEntity,
41
13
  ReactionEmoji,
@@ -51,13 +23,6 @@ InputMedia: typing.TypeAlias = typing.Union[
51
23
  InputMediaPhoto,
52
24
  InputMediaVideo,
53
25
  ]
54
- InputMessageContent: typing.TypeAlias = typing.Union[
55
- InputTextMessageContent,
56
- InputLocationMessageContent,
57
- InputVenueMessageContent,
58
- InputContactMessageContent,
59
- InputInvoiceMessageContent,
60
- ]
61
26
 
62
27
  INPUT_MEDIA_TYPES: typing.Final[dict[str, type[InputMedia]]] = {
63
28
  "animation": InputMediaAnimation,
@@ -69,7 +34,7 @@ INPUT_MEDIA_TYPES: typing.Final[dict[str, type[InputMedia]]] = {
69
34
 
70
35
 
71
36
  def compose_reactions(
72
- reactions: (str | ReactionEmoji | ReactionType | list[str | ReactionEmoji | ReactionType]),
37
+ reactions: str | ReactionEmoji | ReactionType | list[str | ReactionEmoji | ReactionType],
73
38
  /,
74
39
  ) -> list[ReactionType]:
75
40
  if not isinstance(reactions, list):
@@ -80,7 +45,7 @@ def compose_reactions(
80
45
  if isinstance(emoji, ReactionEmoji)
81
46
  else (ReactionTypeEmoji("emoji", ReactionEmoji(emoji)) if isinstance(emoji, str) else emoji)
82
47
  )
83
- for emoji in ([reactions] if isinstance(reactions, str) else reactions)
48
+ for emoji in ([reactions] if isinstance(reactions, str) else reactions) # type: ignore
84
49
  ]
85
50
 
86
51
 
@@ -110,26 +75,6 @@ def compose_link_preview_options(
110
75
  return LinkPreviewOptions(**get_params(locals()))
111
76
 
112
77
 
113
- def compose_chat_permissions(
114
- *,
115
- can_send_messages: bool | None = None,
116
- can_send_audios: bool | None = None,
117
- can_send_documents: bool | None = None,
118
- can_send_photos: bool | None = None,
119
- can_send_videos: bool | None = None,
120
- can_send_video_notes: bool | None = None,
121
- can_send_voice_notes: bool | None = None,
122
- can_send_polls: bool | None = None,
123
- can_send_other_messages: bool | None = None,
124
- can_add_web_page_previews: bool | None = None,
125
- can_change_info: bool | None = None,
126
- can_invite_users: bool | None = None,
127
- can_pin_messages: bool | None = None,
128
- can_manage_topics: bool | None = None,
129
- ) -> ChatPermissions:
130
- return ChatPermissions(**get_params(locals()))
131
-
132
-
133
78
  def input_media(
134
79
  type: typing.Literal["animation", "audio", "document", "photo", "video"],
135
80
  media: str | InputFile,
@@ -142,417 +87,9 @@ def input_media(
142
87
  return INPUT_MEDIA_TYPES[type](**get_params(locals()))
143
88
 
144
89
 
145
- def input_contact_message_content(
146
- phone_number: str,
147
- first_name: str,
148
- *,
149
- last_name: str | None = None,
150
- vcard: str | None = None,
151
- ) -> InputContactMessageContent:
152
- return InputContactMessageContent(**get_params(locals()))
153
-
154
-
155
- def input_invoice_message_content(
156
- title: str,
157
- description: str,
158
- payload: str,
159
- provider_token: str,
160
- currency: str,
161
- prices: list[LabeledPrice],
162
- *,
163
- max_tip_amount: int | None = None,
164
- suggested_tip_amounts: list[int] | None = None,
165
- provider_data: str | None = None,
166
- photo_url: str | None = None,
167
- photo_size: int | None = None,
168
- photo_width: int | None = None,
169
- photo_height: int | None = None,
170
- need_name: bool | None = None,
171
- need_phone_number: bool | None = None,
172
- need_email: bool | None = None,
173
- need_shipping_address: bool | None = None,
174
- send_phone_number_to_provider: bool | None = None,
175
- ) -> InputInvoiceMessageContent:
176
- return InputInvoiceMessageContent(**get_params(locals()))
177
-
178
-
179
- def input_location_message_content(
180
- latitude: float,
181
- longitude: float,
182
- *,
183
- horizontal_accuracy: float | None = None,
184
- live_period: int | None = None,
185
- heading: int | None = None,
186
- proximity_alert_radius: int | None = None,
187
- ) -> InputLocationMessageContent:
188
- return InputLocationMessageContent(**get_params(locals()))
189
-
190
-
191
- def input_text_message_content(
192
- message_text: str,
193
- *,
194
- parse_mode: str | None = None,
195
- entities: list[MessageEntity] | None = None,
196
- disable_web_page_preview: bool | None = None,
197
- ) -> InputTextMessageContent:
198
- return InputTextMessageContent(**get_params(locals()))
199
-
200
-
201
- def input_venue_message_content(
202
- latitude: float,
203
- longitude: float,
204
- title: str,
205
- address: str,
206
- *,
207
- foursquare_id: str | None = None,
208
- foursquare_type: str | None = None,
209
- google_place_id: str | None = None,
210
- google_place_type: str | None = None,
211
- ) -> InputVenueMessageContent:
212
- return InputVenueMessageContent(**get_params(locals()))
213
-
214
-
215
- def inline_query_article(
216
- id: str,
217
- title: str,
218
- input_message_content: InputMessageContent,
219
- *,
220
- reply_markup: InlineKeyboardMarkup | None = None,
221
- url: str | None = None,
222
- hide_url: bool | None = None,
223
- description: str | None = None,
224
- thumbnail_url: str | None = None,
225
- thumbnail_width: int | None = None,
226
- thumbnail_height: int | None = None,
227
- ) -> InlineQueryResultArticle:
228
- return InlineQueryResultArticle(type="article", **get_params(locals()))
229
-
230
-
231
- def inline_query_audio(
232
- id: str,
233
- audio_url: str,
234
- *,
235
- title: str | None = None,
236
- caption: str | None = None,
237
- parse_mode: str | None = None,
238
- caption_entities: list[MessageEntity] | None = None,
239
- performer: str | None = None,
240
- audio_duration: int | None = None,
241
- reply_markup: InlineKeyboardMarkup | None = None,
242
- input_message_content: InputMessageContent | None = None,
243
- ) -> InlineQueryResultAudio:
244
- return InlineQueryResultAudio(type="audio", **get_params(locals()))
245
-
246
-
247
- def inline_query_contact(
248
- id: str,
249
- phone_number: str,
250
- first_name: str,
251
- *,
252
- last_name: str | None = None,
253
- vcard: str | None = None,
254
- reply_markup: InlineKeyboardMarkup | None = None,
255
- input_message_content: InputMessageContent | None = None,
256
- thumbnail_url: str | None = None,
257
- thumbnail_width: int | None = None,
258
- thumbnail_height: int | None = None,
259
- ) -> InlineQueryResultContact:
260
- return InlineQueryResultContact(type="contact", **get_params(locals()))
261
-
262
-
263
- def inline_query_document(
264
- id: str,
265
- title: str,
266
- document_url: str,
267
- mime_type: str,
268
- *,
269
- description: str | None = None,
270
- caption: str | None = None,
271
- parse_mode: str | None = None,
272
- caption_entities: list[MessageEntity] | None = None,
273
- reply_markup: InlineKeyboardMarkup | None = None,
274
- input_message_content: InputMessageContent | None = None,
275
- thumbnail_url: str | None = None,
276
- thumbnail_width: int | None = None,
277
- thumbnail_height: int | None = None,
278
- ) -> InlineQueryResultDocument:
279
- return InlineQueryResultDocument(type="document", **get_params(locals()))
280
-
281
-
282
- def inline_query_gif(
283
- id: str,
284
- gif_url: str,
285
- *,
286
- gif_width: int | None = None,
287
- gif_height: int | None = None,
288
- gif_duration: int | None = None,
289
- title: str | None = None,
290
- caption: str | None = None,
291
- parse_mode: str | None = None,
292
- caption_entities: list[MessageEntity] | None = None,
293
- reply_markup: InlineKeyboardMarkup | None = None,
294
- input_message_content: InputMessageContent | None = None,
295
- thumbnail_url: str | None = None,
296
- thumbnail_mime_type: str | None = None,
297
- ) -> InlineQueryResultGif:
298
- return InlineQueryResultGif(type="gif", **get_params(locals()))
299
-
300
-
301
- def inline_query_location(
302
- id: str,
303
- latitude: float,
304
- longitude: float,
305
- *,
306
- title: str | None = None,
307
- horizontal_accuracy: float | None = None,
308
- live_period: int | None = None,
309
- heading: int | None = None,
310
- proximity_alert_radius: int | None = None,
311
- reply_markup: InlineKeyboardMarkup | None = None,
312
- input_message_content: InputMessageContent | None = None,
313
- thumbnail_url: str | None = None,
314
- thumbnail_width: int | None = None,
315
- thumbnail_height: int | None = None,
316
- ) -> InlineQueryResultLocation:
317
- return InlineQueryResultLocation(type="location", **get_params(locals()))
318
-
319
-
320
- def inline_query_venue(
321
- id: str,
322
- latitude: float,
323
- longitude: float,
324
- title: str,
325
- address: str,
326
- *,
327
- foursquare_id: str | None = None,
328
- foursquare_type: str | None = None,
329
- google_place_id: str | None = None,
330
- google_place_type: str | None = None,
331
- reply_markup: InlineKeyboardMarkup | None = None,
332
- input_message_content: InputMessageContent | None = None,
333
- thumbnail_url: str | None = None,
334
- thumbnail_width: int | None = None,
335
- thumbnail_height: int | None = None,
336
- ) -> InlineQueryResultVenue:
337
- return InlineQueryResultVenue(type="venue", **get_params(locals()))
338
-
339
-
340
- def inline_query_video(
341
- id: str,
342
- video_url: str,
343
- mime_type: str,
344
- thumb_url: str,
345
- *,
346
- title: str | None = None,
347
- caption: str | None = None,
348
- parse_mode: str | None = None,
349
- caption_entities: list[MessageEntity] | None = None,
350
- video_width: int | None = None,
351
- video_height: int | None = None,
352
- video_duration: int | None = None,
353
- description: str | None = None,
354
- reply_markup: InlineKeyboardMarkup | None = None,
355
- input_message_content: InputMessageContent | None = None,
356
- thumbnail_url: str | None = None,
357
- thumbnail_width: int | None = None,
358
- thumbnail_height: int | None = None,
359
- ) -> InlineQueryResultVideo:
360
- return InlineQueryResultVideo(type="video", **get_params(locals()))
361
-
362
-
363
- def inline_query_game(
364
- id: str,
365
- game_short_name: str,
366
- *,
367
- reply_markup: InlineKeyboardMarkup | None = None,
368
- ) -> InlineQueryResultGame:
369
- return InlineQueryResultGame(type="game", **get_params(locals()))
370
-
371
-
372
- def inline_query_voice(
373
- id: str,
374
- voice_url: str,
375
- title: str,
376
- *,
377
- caption: str | None = None,
378
- parse_mode: str | None = None,
379
- caption_entities: list[MessageEntity] | None = None,
380
- reply_markup: InlineKeyboardMarkup | None = None,
381
- input_message_content: InputMessageContent | None = None,
382
- duration: int | None = None,
383
- ) -> InlineQueryResultVoice:
384
- return InlineQueryResultVoice(type="voice", **get_params(locals()))
385
-
386
-
387
- def inline_query_photo(
388
- id: str,
389
- photo_url: str,
390
- thumb_url: str,
391
- *,
392
- photo_width: int | None = None,
393
- photo_height: int | None = None,
394
- title: str | None = None,
395
- description: str | None = None,
396
- caption: str | None = None,
397
- parse_mode: str | None = None,
398
- caption_entities: list[MessageEntity] | None = None,
399
- reply_markup: InlineKeyboardMarkup | None = None,
400
- input_message_content: InputMessageContent | None = None,
401
- ) -> InlineQueryResultPhoto:
402
- return InlineQueryResultPhoto(type="photo", **get_params(locals()))
403
-
404
-
405
- def inline_query_mpeg4_gif(
406
- id: str,
407
- mpeg4_url: str,
408
- *,
409
- mpeg4_width: int | None = None,
410
- mpeg4_height: int | None = None,
411
- mpeg4_duration: int | None = None,
412
- thumb_url: str | None = None,
413
- reply_markup: InlineKeyboardMarkup | None = None,
414
- input_message_content: InputMessageContent | None = None,
415
- ) -> InlineQueryResultMpeg4Gif:
416
- return InlineQueryResultMpeg4Gif(type="mpeg4_gif", **get_params(locals()))
417
-
418
-
419
- def inline_query_cached_sticker(
420
- id: str,
421
- sticker_file_id: str,
422
- *,
423
- reply_markup: InlineKeyboardMarkup | None = None,
424
- ) -> InlineQueryResultCachedSticker:
425
- return InlineQueryResultCachedSticker(type="sticker", **get_params(locals()))
426
-
427
-
428
- def inline_query_cached_document(
429
- id: str,
430
- document_file_id: str,
431
- *,
432
- title: str | None = None,
433
- description: str | None = None,
434
- caption: str | None = None,
435
- parse_mode: str | None = None,
436
- caption_entities: list[MessageEntity] | None = None,
437
- reply_markup: InlineKeyboardMarkup | None = None,
438
- input_message_content: InputMessageContent | None = None,
439
- ) -> InlineQueryResultCachedDocument:
440
- return InlineQueryResultCachedDocument(type="document", **get_params(locals()))
441
-
442
-
443
- def inline_query_cached_audio(
444
- id: str,
445
- audio_file_id: str,
446
- *,
447
- caption: str | None = None,
448
- parse_mode: str | None = None,
449
- caption_entities: list[MessageEntity] | None = None,
450
- reply_markup: InlineKeyboardMarkup | None = None,
451
- input_message_content: InputMessageContent | None = None,
452
- ) -> InlineQueryResultCachedAudio:
453
- return InlineQueryResultCachedAudio(type="audio", **get_params(locals()))
454
-
455
-
456
- def inline_query_cached_video(
457
- id: str,
458
- video_file_id: str,
459
- *,
460
- title: str | None = None,
461
- description: str | None = None,
462
- caption: str | None = None,
463
- parse_mode: str | None = None,
464
- caption_entities: list[MessageEntity] | None = None,
465
- reply_markup: InlineKeyboardMarkup | None = None,
466
- input_message_content: InputMessageContent | None = None,
467
- ) -> InlineQueryResultCachedVideo:
468
- return InlineQueryResultCachedVideo(type="video", **get_params(locals()))
469
-
470
-
471
- def inline_query_cached_gif(
472
- id: str,
473
- gif_file_id: str,
474
- *,
475
- title: str | None = None,
476
- caption: str | None = None,
477
- parse_mode: str | None = None,
478
- caption_entities: list[MessageEntity] | None = None,
479
- reply_markup: InlineKeyboardMarkup | None = None,
480
- input_message_content: InputMessageContent | None = None,
481
- ) -> InlineQueryResultCachedGif:
482
- return InlineQueryResultCachedGif(type="gif", **get_params(locals()))
483
-
484
-
485
- def inline_query_cached_mpeg4_gif(
486
- id: str,
487
- mpeg4_file_id: str,
488
- *,
489
- title: str | None = None,
490
- caption: str | None = None,
491
- parse_mode: str | None = None,
492
- caption_entities: list[MessageEntity] | None = None,
493
- reply_markup: InlineKeyboardMarkup | None = None,
494
- input_message_content: InputMessageContent | None = None,
495
- ) -> InlineQueryResultCachedMpeg4Gif:
496
- return InlineQueryResultCachedMpeg4Gif(type="mpeg4_gif", **get_params(locals()))
497
-
498
-
499
- def inline_query_cached_voice(
500
- id: str,
501
- voice_file_id: str,
502
- *,
503
- caption: str | None = None,
504
- parse_mode: str | None = None,
505
- caption_entities: list[MessageEntity] | None = None,
506
- reply_markup: InlineKeyboardMarkup | None = None,
507
- input_message_content: InputMessageContent | None = None,
508
- ) -> InlineQueryResultCachedVoice:
509
- return InlineQueryResultCachedVoice(type="voice", **get_params(locals()))
510
-
511
-
512
- def inline_query_cached_photo(
513
- id: str,
514
- photo_file_id: str,
515
- *,
516
- title: str | None = None,
517
- description: str | None = None,
518
- caption: str | None = None,
519
- parse_mode: str | None = None,
520
- caption_entities: list[MessageEntity] | None = None,
521
- reply_markup: InlineKeyboardMarkup | None = None,
522
- input_message_content: InputMessageContent | None = None,
523
- ) -> InlineQueryResultCachedPhoto:
524
- return InlineQueryResultCachedPhoto(type="photo", **get_params(locals()))
525
-
526
-
527
90
  __all__ = (
528
- "compose_chat_permissions",
529
91
  "compose_link_preview_options",
530
92
  "compose_reactions",
531
93
  "compose_reply_params",
532
- "inline_query_article",
533
- "inline_query_audio",
534
- "inline_query_cached_audio",
535
- "inline_query_cached_document",
536
- "inline_query_cached_gif",
537
- "inline_query_cached_mpeg4_gif",
538
- "inline_query_cached_photo",
539
- "inline_query_cached_sticker",
540
- "inline_query_cached_video",
541
- "inline_query_cached_voice",
542
- "inline_query_contact",
543
- "inline_query_document",
544
- "inline_query_game",
545
- "inline_query_gif",
546
- "inline_query_location",
547
- "inline_query_mpeg4_gif",
548
- "inline_query_photo",
549
- "inline_query_venue",
550
- "inline_query_video",
551
- "inline_query_voice",
552
- "input_contact_message_content",
553
- "input_invoice_message_content",
554
- "input_location_message_content",
555
94
  "input_media",
556
- "input_text_message_content",
557
- "input_venue_message_content",
558
95
  )
@@ -1,6 +1,6 @@
1
1
  from .abc import ABCDispatch
2
2
  from .context import Context
3
- from .dispatch import ABCRule, Dispatch, TelegrinderCtx
3
+ from .dispatch import Dispatch, TelegrinderContext
4
4
  from .handler import ABCHandler, FuncHandler, MessageReplyHandler
5
5
  from .middleware import ABCMiddleware
6
6
  from .process import check_rule, process_inner
@@ -33,7 +33,6 @@ __all__ = (
33
33
  "ABCHandler",
34
34
  "ABCMiddleware",
35
35
  "ABCReturnManager",
36
- "ABCRule",
37
36
  "ABCStateView",
38
37
  "ABCView",
39
38
  "BaseReturnManager",
@@ -54,7 +53,7 @@ __all__ = (
54
53
  "MessageView",
55
54
  "RawEventView",
56
55
  "ShortState",
57
- "TelegrinderCtx",
56
+ "TelegrinderContext",
58
57
  "ViewBox",
59
58
  "WaiterMachine",
60
59
  "check_rule",
@@ -2,12 +2,15 @@ import typing
2
2
  from abc import ABC, abstractmethod
3
3
 
4
4
  from telegrinder.api.abc import ABCAPI
5
- from telegrinder.tools.global_context import ABCGlobalContext
6
- from telegrinder.types import Update
5
+ from telegrinder.tools.global_context.abc import ABCGlobalContext
6
+ from telegrinder.types.objects import Update
7
7
 
8
8
 
9
9
  class ABCDispatch(ABC):
10
- global_context: ABCGlobalContext
10
+ @property
11
+ @abstractmethod
12
+ def global_context(self) -> ABCGlobalContext:
13
+ pass
11
14
 
12
15
  @abstractmethod
13
16
  async def feed(self, event: Update, api: ABCAPI) -> bool:
@@ -10,15 +10,15 @@ Key: typing.TypeAlias = str | enum.Enum
10
10
  AnyValue: typing.TypeAlias = typing.Any
11
11
 
12
12
 
13
- @typing.dataclass_transform(kw_only_default=True, order_default=True)
14
13
  class Context(dict[str, AnyValue]):
15
- """Context class for rules and middlewares.
16
- ```
17
- class MyRule(ABCRule[T]):
18
- adapter = RawUpdateAdapter()
14
+ """Context class like dict & dotdict.
19
15
 
16
+ For example:
17
+ ```python
18
+ class MyRule(ABCRule[T]):
20
19
  async def check(self, event: T, ctx: Context) -> bool:
21
- ctx.set("value", (await event.ctx_api.get_me()).unwrap())
20
+ ctx.me = (await event.ctx_api.get_me()).unwrap()
21
+ ctx["items"] = [1, 2, 3]
22
22
  return True
23
23
  ```
24
24
  """