telegrinder 0.2.2__py3-none-any.whl → 0.3.0.post1__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 (31) hide show
  1. telegrinder/__init__.py +24 -2
  2. telegrinder/bot/__init__.py +16 -0
  3. telegrinder/bot/cute_types/callback_query.py +60 -146
  4. telegrinder/bot/cute_types/chat_join_request.py +12 -16
  5. telegrinder/bot/cute_types/chat_member_updated.py +14 -104
  6. telegrinder/bot/cute_types/inline_query.py +5 -14
  7. telegrinder/bot/cute_types/message.py +605 -1227
  8. telegrinder/bot/dispatch/__init__.py +22 -1
  9. telegrinder/bot/dispatch/abc.py +7 -0
  10. telegrinder/bot/dispatch/dispatch.py +7 -0
  11. telegrinder/bot/dispatch/waiter_machine/__init__.py +18 -0
  12. telegrinder/bot/dispatch/waiter_machine/actions.py +10 -0
  13. telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +15 -0
  14. telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +60 -0
  15. telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +49 -0
  16. telegrinder/bot/dispatch/waiter_machine/hasher/message.py +54 -0
  17. telegrinder/bot/dispatch/waiter_machine/hasher/state.py +19 -0
  18. telegrinder/bot/dispatch/waiter_machine/machine.py +87 -99
  19. telegrinder/bot/dispatch/waiter_machine/middleware.py +23 -35
  20. telegrinder/bot/dispatch/waiter_machine/short_state.py +9 -9
  21. telegrinder/bot/scenario/checkbox.py +2 -2
  22. telegrinder/model.py +6 -4
  23. telegrinder/msgspec_json.py +1 -1
  24. telegrinder/msgspec_utils.py +51 -0
  25. telegrinder/node/event.py +2 -0
  26. telegrinder/tools/functional.py +9 -0
  27. telegrinder/tools/state_storage/memory.py +3 -3
  28. {telegrinder-0.2.2.dist-info → telegrinder-0.3.0.post1.dist-info}/METADATA +2 -2
  29. {telegrinder-0.2.2.dist-info → telegrinder-0.3.0.post1.dist-info}/RECORD +31 -24
  30. {telegrinder-0.2.2.dist-info → telegrinder-0.3.0.post1.dist-info}/LICENSE +0 -0
  31. {telegrinder-0.2.2.dist-info → telegrinder-0.3.0.post1.dist-info}/WHEEL +0 -0
@@ -27,7 +27,7 @@ async def chat_member_interaction(
27
27
  class ChatMemberShortcuts:
28
28
  """Shortcut methods for `ChatMemberUpdatedCute`, `ChatJoinRequestCute` objects."""
29
29
 
30
- @shortcut("ban_chat_member", executor=chat_member_interaction)
30
+ @shortcut("ban_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
31
31
  async def ban_chat_member(
32
32
  self,
33
33
  chat_id: int | str | None = None,
@@ -42,25 +42,11 @@ class ChatMemberShortcuts:
42
42
  of supergroups and channels, the user will not be able to return to the chat
43
43
  on their own using invite links, etc., unless unbanned first. The bot must
44
44
  be an administrator in the chat for this to work and must have the appropriate
45
- administrator rights. Returns True on success.
46
-
47
- :param chat_id: Unique identifier for the target group or username of the target supergroup \
48
- or channel (in the format @channelusername).
49
-
50
- :param user_id: Unique identifier of the target user.
51
-
52
- :param until_date: Date when the user will be unbanned; Unix time. If user is banned for more \
53
- than 366 days or less than 30 seconds from the current time they are considered \
54
- to be banned forever. Applied for supergroups and channels only.
55
-
56
- :param revoke_messages: Pass True to delete all messages from the chat for the user that is being removed. \
57
- If False, the user will be able to see messages in the group that were sent \
58
- before the user was removed. Always True for supergroups and channels. \
59
- """
45
+ administrator rights. Returns True on success."""
60
46
 
61
47
  ...
62
48
 
63
- @shortcut("unban_chat_member", executor=chat_member_interaction)
49
+ @shortcut("unban_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
64
50
  async def unban_chat_member(
65
51
  self,
66
52
  chat_id: int | str | None = None,
@@ -76,22 +62,14 @@ class ChatMemberShortcuts:
76
62
  work. By default, this method guarantees that after the call the user is
77
63
  not a member of the chat, but will be able to join it. So if the user is a member
78
64
  of the chat they will also be removed from the chat. If you don't want this,
79
- use the parameter only_if_banned. Returns True on success.
80
-
81
- :param chat_id: Unique identifier for the target group or username of the target supergroup \
82
- or channel (in the format @channelusername).
83
-
84
- :param user_id: Unique identifier of the target user.
85
-
86
- :param only_if_banned: Do nothing if the user is not banned.
87
- """
65
+ use the parameter only_if_banned. Returns True on success."""
88
66
 
89
67
  ...
90
68
 
91
69
  @shortcut(
92
70
  "restrict_chat_member",
93
71
  executor=chat_member_interaction,
94
- custom_params={"permissions"},
72
+ custom_params={"permissions", "chat_id", "user_id"},
95
73
  )
96
74
  async def restrict_chat_member(
97
75
  self,
@@ -107,29 +85,11 @@ class ChatMemberShortcuts:
107
85
  Use this method to restrict a user in a supergroup. The bot must be an administrator
108
86
  in the supergroup for this to work and must have the appropriate administrator
109
87
  rights. Pass True for all permissions to lift restrictions from a user.
110
- Returns True on success.
111
-
112
- :param chat_id: Unique identifier for the target chat or username of the target supergroup \
113
- (in the format @supergroupusername).
114
-
115
- :param user_id: Unique identifier of the target user.
116
-
117
- :param permissions: A JSON-serialized object for new user permissions.
118
-
119
- :param use_independent_chat_permissions: Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages \
120
- and can_add_web_page_previews permissions will imply the can_send_messages, \
121
- can_send_audios, can_send_documents, can_send_photos, can_send_videos, \
122
- can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls \
123
- permission will imply the can_send_messages permission.
124
-
125
- :param until_date: Date when restrictions will be lifted for the user; Unix time. If user is \
126
- restricted for more than 366 days or less than 30 seconds from the current \
127
- time, they are considered to be restricted forever.
128
- """
88
+ Returns True on success."""
129
89
 
130
90
  ...
131
91
 
132
- @shortcut("promote_chat_member", executor=chat_member_interaction)
92
+ @shortcut("promote_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
133
93
  async def promote_chat_member(
134
94
  self,
135
95
  chat_id: int | str | None = None,
@@ -156,56 +116,15 @@ class ChatMemberShortcuts:
156
116
  Use this method to promote or demote a user in a supergroup or a channel. The
157
117
  bot must be an administrator in the chat for this to work and must have the
158
118
  appropriate administrator rights. Pass False for all boolean parameters
159
- to demote a user. Returns True on success.
160
-
161
- :param chat_id: Unique identifier for the target chat or username of the target channel \
162
- (in the format @channelusername).
163
-
164
- :param user_id: Unique identifier of the target user.
165
-
166
- :param is_anonymous: Pass True if the administrator's presence in the chat is hidden.
167
-
168
- :param can_manage_chat: Pass True if the administrator can access the chat event log, get boost list, \
169
- see hidden supergroup and channel members, report spam messages and ignore \
170
- slow mode. Implied by any other administrator privilege.
171
-
172
- :param can_delete_messages: Pass True if the administrator can delete messages of other users.
173
-
174
- :param can_manage_video_chats: Pass True if the administrator can manage video chats.
175
-
176
- :param can_restrict_members: Pass True if the administrator can restrict, ban or unban chat members, \
177
- or access supergroup statistics.
178
-
179
- :param can_promote_members: Pass True if the administrator can add new administrators with a subset \
180
- of their own privileges or demote administrators that they have promoted, \
181
- directly or indirectly (promoted by administrators that were appointed \
182
- by him).
183
-
184
- :param can_change_info: Pass True if the administrator can change chat title, photo and other settings. \
185
-
186
- :param can_invite_users: Pass True if the administrator can invite new users to the chat.
187
-
188
- :param can_post_stories: Pass True if the administrator can post stories to the chat.
189
-
190
- :param can_edit_stories: Pass True if the administrator can edit stories posted by other users.
191
-
192
- :param can_delete_stories: Pass True if the administrator can delete stories posted by other users. \
193
-
194
- :param can_post_messages: Pass True if the administrator can post messages in the channel, or access \
195
- channel statistics; for channels only.
196
-
197
- :param can_edit_messages: Pass True if the administrator can edit messages of other users and can pin \
198
- messages; for channels only.
199
-
200
- :param can_pin_messages: Pass True if the administrator can pin messages; for supergroups only. \
201
-
202
- :param can_manage_topics: Pass True if the user is allowed to create, rename, close, and reopen forum \
203
- topics; for supergroups only.
204
- """
119
+ to demote a user. Returns True on success."""
205
120
 
206
121
  ...
207
122
 
208
- @shortcut("set_chat_administrator_custom_title", executor=chat_member_interaction)
123
+ @shortcut(
124
+ "set_chat_administrator_custom_title",
125
+ executor=chat_member_interaction,
126
+ custom_params={"chat_id", "user_id"},
127
+ )
209
128
  async def set_chat_administrator_custom_title(
210
129
  self,
211
130
  custom_title: str,
@@ -216,16 +135,7 @@ class ChatMemberShortcuts:
216
135
  """Shortcut `API.set_chat_administrator_custom_title()`, see the [documentation](https://core.telegram.org/bots/api#setchatadministratorcustomtitle)
217
136
 
218
137
  Use this method to set a custom title for an administrator in a supergroup
219
- promoted by the bot. Returns True on success.
220
-
221
- :param chat_id: Unique identifier for the target chat or username of the target supergroup \
222
- (in the format @supergroupusername).
223
-
224
- :param user_id: Unique identifier of the target user.
225
-
226
- :param custom_title: New custom title for the administrator; 0-16 characters, emoji are not \
227
- allowed.
228
- """
138
+ promoted by the bot. Returns True on success."""
229
139
 
230
140
  ...
231
141
 
@@ -24,7 +24,7 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
24
24
  async def answer(
25
25
  self,
26
26
  results: InlineQueryResult | list[InlineQueryResult],
27
- inline_query_id: str | None = None,
27
+ inline_query_id: str,
28
28
  cache_time: int | None = None,
29
29
  is_personal: bool | None = None,
30
30
  next_offset: str | None = None,
@@ -35,25 +35,16 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
35
35
 
36
36
  Use this method to send answers to an inline query. On success, True is returned.
37
37
  No more than 50 results per query are allowed.
38
-
39
38
  :param inline_query_id: Unique identifier for the answered query.
40
39
 
41
40
  :param results: A JSON-serialized array of results for the inline query.
42
41
 
43
- :param cache_time: The maximum amount of time in seconds that the result of the inline query \
44
- may be cached on the server. Defaults to 300.
45
-
46
- :param is_personal: Pass True if results may be cached on the server side only for the user that \
47
- sent the query. By default, results may be returned to any user who sends \
48
- the same query.
42
+ :param cache_time: The maximum amount of time in seconds that the result of the inline querymay be cached on the server. Defaults to 300.
49
43
 
50
- :param next_offset: Pass the offset that a client should send in the next query with the same text \
51
- to receive more results. Pass an empty string if there are no more results \
52
- or if you don't support pagination. Offset length can't exceed 64 bytes. \
44
+ :param is_personal: Pass True if results may be cached on the server side only for the user thatsent the query. By default, results may be returned to any user who sendsthe same query.
53
45
 
54
- :param button: A JSON-serialized object describing a button to be shown above inline query \
55
- results.
56
- """
46
+ :param next_offset: Pass the offset that a client should send in the next query with the same textto receive more results. Pass an empty string if there are no more resultsor if you don't support pagination. Offset length can't exceed 64 bytes.
47
+ :param button: A JSON-serialized object describing a button to be shown above inline queryresults."""
57
48
 
58
49
  params = compose_method_params(
59
50
  get_params(locals()),