telegrinder 0.2.1__py3-none-any.whl → 0.3.0__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.
- telegrinder/__init__.py +45 -12
- telegrinder/bot/__init__.py +32 -4
- telegrinder/bot/cute_types/callback_query.py +60 -146
- telegrinder/bot/cute_types/chat_join_request.py +12 -16
- telegrinder/bot/cute_types/chat_member_updated.py +15 -105
- telegrinder/bot/cute_types/inline_query.py +5 -14
- telegrinder/bot/cute_types/message.py +623 -1238
- telegrinder/bot/dispatch/__init__.py +40 -3
- telegrinder/bot/dispatch/abc.py +8 -1
- telegrinder/bot/dispatch/context.py +2 -2
- telegrinder/bot/dispatch/dispatch.py +8 -1
- telegrinder/bot/dispatch/handler/__init__.py +17 -1
- telegrinder/bot/dispatch/handler/audio_reply.py +44 -0
- telegrinder/bot/dispatch/handler/base.py +57 -0
- telegrinder/bot/dispatch/handler/document_reply.py +44 -0
- telegrinder/bot/dispatch/handler/func.py +3 -3
- telegrinder/bot/dispatch/handler/media_group_reply.py +43 -0
- telegrinder/bot/dispatch/handler/message_reply.py +12 -35
- telegrinder/bot/dispatch/handler/photo_reply.py +44 -0
- telegrinder/bot/dispatch/handler/sticker_reply.py +37 -0
- telegrinder/bot/dispatch/handler/video_reply.py +44 -0
- telegrinder/bot/dispatch/process.py +2 -2
- telegrinder/bot/dispatch/return_manager/abc.py +11 -8
- telegrinder/bot/dispatch/return_manager/callback_query.py +2 -2
- telegrinder/bot/dispatch/return_manager/inline_query.py +2 -2
- telegrinder/bot/dispatch/return_manager/message.py +3 -3
- telegrinder/bot/dispatch/view/__init__.py +2 -1
- telegrinder/bot/dispatch/view/abc.py +2 -181
- telegrinder/bot/dispatch/view/base.py +200 -0
- telegrinder/bot/dispatch/view/callback_query.py +3 -3
- telegrinder/bot/dispatch/view/chat_join_request.py +2 -2
- telegrinder/bot/dispatch/view/chat_member.py +2 -3
- telegrinder/bot/dispatch/view/inline_query.py +2 -2
- telegrinder/bot/dispatch/view/message.py +5 -4
- telegrinder/bot/dispatch/view/raw.py +4 -3
- telegrinder/bot/dispatch/waiter_machine/__init__.py +18 -0
- telegrinder/bot/dispatch/waiter_machine/actions.py +10 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +15 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +60 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +49 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/message.py +54 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/state.py +19 -0
- telegrinder/bot/dispatch/waiter_machine/machine.py +88 -101
- telegrinder/bot/dispatch/waiter_machine/middleware.py +23 -41
- telegrinder/bot/dispatch/waiter_machine/short_state.py +9 -9
- telegrinder/bot/polling/polling.py +5 -2
- telegrinder/bot/rules/__init__.py +3 -3
- telegrinder/bot/rules/abc.py +6 -5
- telegrinder/bot/rules/adapter/__init__.py +1 -1
- telegrinder/bot/rules/integer.py +1 -1
- telegrinder/bot/rules/is_from.py +19 -0
- telegrinder/bot/rules/state.py +9 -6
- telegrinder/bot/scenario/checkbox.py +5 -5
- telegrinder/bot/scenario/choice.py +2 -2
- telegrinder/client/aiohttp.py +5 -7
- telegrinder/model.py +6 -11
- telegrinder/modules.py +16 -25
- telegrinder/msgspec_json.py +1 -1
- telegrinder/msgspec_utils.py +56 -5
- telegrinder/node/base.py +2 -2
- telegrinder/node/composer.py +5 -9
- telegrinder/node/container.py +6 -1
- telegrinder/node/event.py +2 -0
- telegrinder/node/polymorphic.py +7 -7
- telegrinder/node/rule.py +6 -4
- telegrinder/node/scope.py +3 -3
- telegrinder/node/source.py +4 -2
- telegrinder/node/tools/generator.py +7 -6
- telegrinder/rules.py +2 -2
- telegrinder/tools/__init__.py +10 -10
- telegrinder/tools/functional.py +9 -0
- telegrinder/tools/keyboard.py +6 -1
- telegrinder/tools/loop_wrapper/loop_wrapper.py +4 -5
- telegrinder/tools/magic.py +17 -19
- telegrinder/tools/state_storage/__init__.py +3 -3
- telegrinder/tools/state_storage/abc.py +12 -10
- telegrinder/tools/state_storage/memory.py +9 -6
- telegrinder/types/__init__.py +1 -0
- telegrinder/types/methods.py +10 -2
- telegrinder/types/objects.py +47 -5
- {telegrinder-0.2.1.dist-info → telegrinder-0.3.0.dist-info}/METADATA +4 -5
- telegrinder-0.3.0.dist-info/RECORD +164 -0
- telegrinder-0.2.1.dist-info/RECORD +0 -149
- {telegrinder-0.2.1.dist-info → telegrinder-0.3.0.dist-info}/LICENSE +0 -0
- {telegrinder-0.2.1.dist-info → telegrinder-0.3.0.dist-info}/WHEEL +0 -0
|
@@ -19,7 +19,11 @@ class ChatJoinRequestCute(BaseCute[ChatJoinRequest], ChatJoinRequest, ChatMember
|
|
|
19
19
|
def user_id(self) -> int:
|
|
20
20
|
return self.from_user.id
|
|
21
21
|
|
|
22
|
-
@shortcut(
|
|
22
|
+
@shortcut(
|
|
23
|
+
"approve_chat_join_request",
|
|
24
|
+
executor=chat_member_interaction,
|
|
25
|
+
custom_params={"chat_id", "user_id"},
|
|
26
|
+
)
|
|
23
27
|
async def approve(
|
|
24
28
|
self,
|
|
25
29
|
chat_id: int | str | None = None,
|
|
@@ -30,17 +34,15 @@ class ChatJoinRequestCute(BaseCute[ChatJoinRequest], ChatJoinRequest, ChatMember
|
|
|
30
34
|
|
|
31
35
|
Use this method to approve a chat join request. The bot must be an administrator
|
|
32
36
|
in the chat for this to work and must have the can_invite_users administrator
|
|
33
|
-
right. Returns True on success.
|
|
34
|
-
|
|
35
|
-
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
36
|
-
(in the format @channelusername).
|
|
37
|
-
|
|
38
|
-
:param user_id: Unique identifier of the target user.
|
|
39
|
-
"""
|
|
37
|
+
right. Returns True on success."""
|
|
40
38
|
|
|
41
39
|
...
|
|
42
40
|
|
|
43
|
-
@shortcut(
|
|
41
|
+
@shortcut(
|
|
42
|
+
"decline_chat_join_request",
|
|
43
|
+
executor=chat_member_interaction,
|
|
44
|
+
custom_params={"chat_id", "user_id"},
|
|
45
|
+
)
|
|
44
46
|
async def decline(
|
|
45
47
|
self,
|
|
46
48
|
chat_id: int | str | None = None,
|
|
@@ -51,13 +53,7 @@ class ChatJoinRequestCute(BaseCute[ChatJoinRequest], ChatJoinRequest, ChatMember
|
|
|
51
53
|
|
|
52
54
|
Use this method to decline a chat join request. The bot must be an administrator
|
|
53
55
|
in the chat for this to work and must have the can_invite_users administrator
|
|
54
|
-
right. Returns True on success.
|
|
55
|
-
|
|
56
|
-
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
57
|
-
(in the format @channelusername).
|
|
58
|
-
|
|
59
|
-
:param user_id: Unique identifier of the target user.
|
|
60
|
-
"""
|
|
56
|
+
right. Returns True on success."""
|
|
61
57
|
|
|
62
58
|
...
|
|
63
59
|
|
|
@@ -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(
|
|
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
|
|
|
@@ -245,6 +155,6 @@ class ChatMemberUpdatedCute(
|
|
|
245
155
|
|
|
246
156
|
|
|
247
157
|
__all__ = (
|
|
248
|
-
"ChatMemberUpdatedCute",
|
|
249
158
|
"ChatMemberShortcuts",
|
|
159
|
+
"ChatMemberUpdatedCute",
|
|
250
160
|
)
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
55
|
-
|
|
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()),
|