telegrinder 0.3.4.post1__py3-none-any.whl → 0.4.1__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 +30 -31
- telegrinder/api/__init__.py +2 -1
- telegrinder/api/api.py +28 -20
- telegrinder/api/error.py +8 -4
- telegrinder/api/response.py +2 -2
- telegrinder/api/token.py +2 -2
- telegrinder/bot/__init__.py +6 -0
- telegrinder/bot/bot.py +38 -31
- telegrinder/bot/cute_types/__init__.py +2 -0
- telegrinder/bot/cute_types/base.py +55 -129
- telegrinder/bot/cute_types/callback_query.py +76 -61
- telegrinder/bot/cute_types/chat_join_request.py +4 -3
- telegrinder/bot/cute_types/chat_member_updated.py +28 -31
- telegrinder/bot/cute_types/inline_query.py +5 -4
- telegrinder/bot/cute_types/message.py +555 -602
- telegrinder/bot/cute_types/pre_checkout_query.py +42 -0
- telegrinder/bot/cute_types/update.py +20 -12
- telegrinder/bot/cute_types/utils.py +3 -36
- telegrinder/bot/dispatch/__init__.py +4 -0
- telegrinder/bot/dispatch/abc.py +8 -9
- telegrinder/bot/dispatch/context.py +5 -7
- telegrinder/bot/dispatch/dispatch.py +85 -33
- telegrinder/bot/dispatch/handler/abc.py +5 -6
- telegrinder/bot/dispatch/handler/audio_reply.py +2 -2
- telegrinder/bot/dispatch/handler/base.py +3 -3
- telegrinder/bot/dispatch/handler/document_reply.py +2 -2
- telegrinder/bot/dispatch/handler/func.py +36 -42
- telegrinder/bot/dispatch/handler/media_group_reply.py +5 -4
- telegrinder/bot/dispatch/handler/message_reply.py +2 -2
- telegrinder/bot/dispatch/handler/photo_reply.py +2 -2
- telegrinder/bot/dispatch/handler/sticker_reply.py +2 -2
- telegrinder/bot/dispatch/handler/video_reply.py +2 -2
- telegrinder/bot/dispatch/middleware/abc.py +83 -8
- telegrinder/bot/dispatch/middleware/global_middleware.py +70 -0
- telegrinder/bot/dispatch/process.py +44 -50
- telegrinder/bot/dispatch/return_manager/__init__.py +2 -0
- telegrinder/bot/dispatch/return_manager/abc.py +6 -10
- telegrinder/bot/dispatch/return_manager/pre_checkout_query.py +20 -0
- telegrinder/bot/dispatch/view/__init__.py +2 -0
- telegrinder/bot/dispatch/view/abc.py +10 -6
- telegrinder/bot/dispatch/view/base.py +81 -50
- telegrinder/bot/dispatch/view/box.py +20 -9
- telegrinder/bot/dispatch/view/callback_query.py +3 -4
- telegrinder/bot/dispatch/view/chat_join_request.py +2 -7
- telegrinder/bot/dispatch/view/chat_member.py +3 -5
- telegrinder/bot/dispatch/view/inline_query.py +3 -4
- telegrinder/bot/dispatch/view/message.py +3 -4
- telegrinder/bot/dispatch/view/pre_checkout_query.py +16 -0
- telegrinder/bot/dispatch/view/raw.py +42 -40
- telegrinder/bot/dispatch/waiter_machine/actions.py +5 -4
- telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +9 -7
- telegrinder/bot/dispatch/waiter_machine/hasher/message.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/hasher/state.py +3 -2
- telegrinder/bot/dispatch/waiter_machine/machine.py +113 -34
- telegrinder/bot/dispatch/waiter_machine/middleware.py +15 -10
- telegrinder/bot/dispatch/waiter_machine/short_state.py +7 -18
- telegrinder/bot/polling/polling.py +62 -54
- telegrinder/bot/rules/__init__.py +24 -1
- telegrinder/bot/rules/abc.py +17 -10
- telegrinder/bot/rules/callback_data.py +20 -61
- telegrinder/bot/rules/chat_join.py +6 -4
- telegrinder/bot/rules/command.py +4 -4
- telegrinder/bot/rules/enum_text.py +1 -4
- telegrinder/bot/rules/func.py +5 -3
- telegrinder/bot/rules/fuzzy.py +1 -1
- telegrinder/bot/rules/id.py +24 -0
- telegrinder/bot/rules/inline.py +6 -4
- telegrinder/bot/rules/integer.py +2 -1
- telegrinder/bot/rules/logic.py +18 -0
- telegrinder/bot/rules/markup.py +5 -6
- telegrinder/bot/rules/message.py +2 -4
- telegrinder/bot/rules/message_entities.py +1 -3
- telegrinder/bot/rules/node.py +15 -9
- telegrinder/bot/rules/payload.py +81 -0
- telegrinder/bot/rules/payment_invoice.py +29 -0
- telegrinder/bot/rules/regex.py +5 -6
- telegrinder/bot/rules/state.py +1 -3
- telegrinder/bot/rules/text.py +10 -5
- telegrinder/bot/rules/update.py +0 -0
- telegrinder/bot/scenario/abc.py +2 -4
- telegrinder/bot/scenario/checkbox.py +12 -14
- telegrinder/bot/scenario/choice.py +6 -9
- telegrinder/client/__init__.py +9 -1
- telegrinder/client/abc.py +35 -10
- telegrinder/client/aiohttp.py +28 -24
- telegrinder/client/form_data.py +31 -0
- telegrinder/client/sonic.py +212 -0
- telegrinder/model.py +38 -145
- telegrinder/modules.py +3 -1
- telegrinder/msgspec_utils.py +136 -68
- telegrinder/node/__init__.py +74 -13
- telegrinder/node/attachment.py +92 -16
- telegrinder/node/base.py +196 -68
- telegrinder/node/callback_query.py +17 -16
- telegrinder/node/command.py +3 -2
- telegrinder/node/composer.py +40 -75
- telegrinder/node/container.py +13 -7
- telegrinder/node/either.py +82 -0
- telegrinder/node/event.py +20 -31
- telegrinder/node/file.py +51 -0
- telegrinder/node/me.py +4 -5
- telegrinder/node/payload.py +78 -0
- telegrinder/node/polymorphic.py +28 -9
- telegrinder/node/rule.py +2 -6
- telegrinder/node/scope.py +4 -6
- telegrinder/node/source.py +37 -21
- telegrinder/node/text.py +20 -8
- telegrinder/node/tools/generator.py +7 -11
- telegrinder/py.typed +0 -0
- telegrinder/rules.py +0 -61
- telegrinder/tools/__init__.py +97 -38
- telegrinder/tools/adapter/__init__.py +19 -0
- telegrinder/tools/adapter/abc.py +49 -0
- telegrinder/tools/adapter/dataclass.py +56 -0
- telegrinder/{bot/rules → tools}/adapter/event.py +8 -10
- telegrinder/{bot/rules → tools}/adapter/node.py +8 -10
- telegrinder/{bot/rules → tools}/adapter/raw_event.py +2 -2
- telegrinder/{bot/rules → tools}/adapter/raw_update.py +2 -2
- telegrinder/tools/buttons.py +52 -26
- telegrinder/tools/callback_data_serilization/__init__.py +5 -0
- telegrinder/tools/callback_data_serilization/abc.py +51 -0
- telegrinder/tools/callback_data_serilization/json_ser.py +60 -0
- telegrinder/tools/callback_data_serilization/msgpack_ser.py +172 -0
- telegrinder/tools/error_handler/abc.py +4 -7
- telegrinder/tools/error_handler/error.py +0 -0
- telegrinder/tools/error_handler/error_handler.py +34 -48
- telegrinder/tools/formatting/__init__.py +57 -37
- telegrinder/tools/formatting/deep_links.py +541 -0
- telegrinder/tools/formatting/{html.py → html_formatter.py} +51 -79
- telegrinder/tools/formatting/spec_html_formats.py +14 -60
- telegrinder/tools/functional.py +1 -5
- telegrinder/tools/global_context/global_context.py +26 -51
- telegrinder/tools/global_context/telegrinder_ctx.py +3 -3
- telegrinder/tools/i18n/abc.py +0 -0
- telegrinder/tools/i18n/middleware/abc.py +3 -6
- telegrinder/tools/input_file_directory.py +30 -0
- telegrinder/tools/keyboard.py +9 -9
- telegrinder/tools/lifespan.py +105 -0
- telegrinder/tools/limited_dict.py +5 -10
- telegrinder/tools/loop_wrapper/abc.py +7 -2
- telegrinder/tools/loop_wrapper/loop_wrapper.py +40 -95
- telegrinder/tools/magic.py +236 -60
- telegrinder/tools/state_storage/__init__.py +0 -0
- telegrinder/tools/state_storage/abc.py +5 -9
- telegrinder/tools/state_storage/memory.py +1 -1
- telegrinder/tools/strings.py +13 -0
- telegrinder/types/__init__.py +8 -0
- telegrinder/types/enums.py +31 -21
- telegrinder/types/input_file.py +51 -0
- telegrinder/types/methods.py +531 -109
- telegrinder/types/objects.py +934 -826
- telegrinder/verification_utils.py +0 -2
- {telegrinder-0.3.4.post1.dist-info → telegrinder-0.4.1.dist-info}/LICENSE +2 -2
- telegrinder-0.4.1.dist-info/METADATA +143 -0
- telegrinder-0.4.1.dist-info/RECORD +182 -0
- {telegrinder-0.3.4.post1.dist-info → telegrinder-0.4.1.dist-info}/WHEEL +1 -1
- telegrinder/bot/rules/adapter/__init__.py +0 -17
- telegrinder/bot/rules/adapter/abc.py +0 -31
- telegrinder/node/message.py +0 -14
- telegrinder/node/update.py +0 -15
- telegrinder/tools/formatting/links.py +0 -38
- telegrinder/tools/kb_set/__init__.py +0 -4
- telegrinder/tools/kb_set/base.py +0 -15
- telegrinder/tools/kb_set/yaml.py +0 -63
- telegrinder-0.3.4.post1.dist-info/METADATA +0 -110
- telegrinder-0.3.4.post1.dist-info/RECORD +0 -165
- /telegrinder/{bot/rules → tools}/adapter/errors.py +0 -0
|
@@ -4,8 +4,9 @@ from datetime import datetime
|
|
|
4
4
|
from fntypes.result import Result
|
|
5
5
|
|
|
6
6
|
from telegrinder.api.api import API, APIError
|
|
7
|
-
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params
|
|
7
|
+
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params
|
|
8
8
|
from telegrinder.model import get_params
|
|
9
|
+
from telegrinder.tools.magic import shortcut
|
|
9
10
|
from telegrinder.types.objects import *
|
|
10
11
|
|
|
11
12
|
|
|
@@ -14,8 +15,6 @@ async def chat_member_interaction(
|
|
|
14
15
|
method_name: str,
|
|
15
16
|
params: dict[str, typing.Any],
|
|
16
17
|
) -> Result[typing.Any, APIError]:
|
|
17
|
-
if isinstance(params.get("permissions"), dict):
|
|
18
|
-
params["permissions"] = ChatPermissions(**params["permissions"])
|
|
19
18
|
params = compose_method_params(
|
|
20
19
|
get_params(locals()),
|
|
21
20
|
update,
|
|
@@ -30,10 +29,11 @@ class ChatMemberShortcuts:
|
|
|
30
29
|
@shortcut("ban_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
|
|
31
30
|
async def ban_chat_member(
|
|
32
31
|
self,
|
|
32
|
+
*,
|
|
33
33
|
chat_id: int | str | None = None,
|
|
34
|
-
user_id: int | None = None,
|
|
35
|
-
until_date: datetime | int | None = None,
|
|
36
34
|
revoke_messages: bool | None = None,
|
|
35
|
+
until_date: datetime | int | None = None,
|
|
36
|
+
user_id: int | None = None,
|
|
37
37
|
**other: typing.Any,
|
|
38
38
|
) -> Result[bool, APIError]:
|
|
39
39
|
"""Shortcut `API.ban_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#banchatmember)
|
|
@@ -43,15 +43,15 @@ class ChatMemberShortcuts:
|
|
|
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
45
|
administrator rights. Returns True on success."""
|
|
46
|
-
|
|
47
46
|
...
|
|
48
47
|
|
|
49
48
|
@shortcut("unban_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
|
|
50
49
|
async def unban_chat_member(
|
|
51
50
|
self,
|
|
51
|
+
*,
|
|
52
52
|
chat_id: int | str | None = None,
|
|
53
|
-
user_id: int | None = None,
|
|
54
53
|
only_if_banned: bool | None = None,
|
|
54
|
+
user_id: int | None = None,
|
|
55
55
|
**other: typing.Any,
|
|
56
56
|
) -> Result[bool, APIError]:
|
|
57
57
|
"""Shortcut `API.unban_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#unbanchatmember)
|
|
@@ -63,21 +63,21 @@ class ChatMemberShortcuts:
|
|
|
63
63
|
not a member of the chat, but will be able to join it. So if the user is a member
|
|
64
64
|
of the chat they will also be removed from the chat. If you don't want this,
|
|
65
65
|
use the parameter only_if_banned. Returns True on success."""
|
|
66
|
-
|
|
67
66
|
...
|
|
68
67
|
|
|
69
68
|
@shortcut(
|
|
70
69
|
"restrict_chat_member",
|
|
71
70
|
executor=chat_member_interaction,
|
|
72
|
-
custom_params={"
|
|
71
|
+
custom_params={"chat_id", "user_id"},
|
|
73
72
|
)
|
|
74
73
|
async def restrict_chat_member(
|
|
75
74
|
self,
|
|
76
|
-
|
|
75
|
+
*,
|
|
76
|
+
permissions: ChatPermissions,
|
|
77
77
|
chat_id: int | str | None = None,
|
|
78
|
-
user_id: int | None = None,
|
|
79
|
-
use_independent_chat_permissions: bool | None = None,
|
|
80
78
|
until_date: datetime | int | None = None,
|
|
79
|
+
use_independent_chat_permissions: bool | None = None,
|
|
80
|
+
user_id: int | None = None,
|
|
81
81
|
**other: typing.Any,
|
|
82
82
|
) -> Result[bool, APIError]:
|
|
83
83
|
"""Shortcut `API.restrict_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#restrictchatmember)
|
|
@@ -86,29 +86,29 @@ class ChatMemberShortcuts:
|
|
|
86
86
|
in the supergroup for this to work and must have the appropriate administrator
|
|
87
87
|
rights. Pass True for all permissions to lift restrictions from a user.
|
|
88
88
|
Returns True on success."""
|
|
89
|
-
|
|
90
89
|
...
|
|
91
90
|
|
|
92
91
|
@shortcut("promote_chat_member", executor=chat_member_interaction, custom_params={"chat_id", "user_id"})
|
|
93
92
|
async def promote_chat_member(
|
|
94
93
|
self,
|
|
95
|
-
|
|
96
|
-
user_id: int | None = None,
|
|
97
|
-
is_anonymous: bool | None = None,
|
|
98
|
-
can_manage_chat: bool | None = None,
|
|
99
|
-
can_delete_messages: bool | None = None,
|
|
100
|
-
can_manage_video_chats: bool | None = None,
|
|
101
|
-
can_restrict_members: bool | None = None,
|
|
102
|
-
can_promote_members: bool | None = None,
|
|
94
|
+
*,
|
|
103
95
|
can_change_info: bool | None = None,
|
|
104
|
-
|
|
105
|
-
can_post_stories: bool | None = None,
|
|
106
|
-
can_edit_stories: bool | None = None,
|
|
96
|
+
can_delete_messages: bool | None = None,
|
|
107
97
|
can_delete_stories: bool | None = None,
|
|
108
|
-
can_post_messages: bool | None = None,
|
|
109
98
|
can_edit_messages: bool | None = None,
|
|
110
|
-
|
|
99
|
+
can_edit_stories: bool | None = None,
|
|
100
|
+
can_invite_users: bool | None = None,
|
|
101
|
+
can_manage_chat: bool | None = None,
|
|
111
102
|
can_manage_topics: bool | None = None,
|
|
103
|
+
can_manage_video_chats: bool | None = None,
|
|
104
|
+
can_pin_messages: bool | None = None,
|
|
105
|
+
can_post_messages: bool | None = None,
|
|
106
|
+
can_post_stories: bool | None = None,
|
|
107
|
+
can_promote_members: bool | None = None,
|
|
108
|
+
can_restrict_members: bool | None = None,
|
|
109
|
+
chat_id: int | str | None = None,
|
|
110
|
+
is_anonymous: bool | None = None,
|
|
111
|
+
user_id: int | None = None,
|
|
112
112
|
**other: typing.Any,
|
|
113
113
|
) -> Result[bool, APIError]:
|
|
114
114
|
"""Shortcut `API.promote_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#promotechatmember)
|
|
@@ -117,7 +117,6 @@ class ChatMemberShortcuts:
|
|
|
117
117
|
bot must be an administrator in the chat for this to work and must have the
|
|
118
118
|
appropriate administrator rights. Pass False for all boolean parameters
|
|
119
119
|
to demote a user. Returns True on success."""
|
|
120
|
-
|
|
121
120
|
...
|
|
122
121
|
|
|
123
122
|
@shortcut(
|
|
@@ -127,6 +126,7 @@ class ChatMemberShortcuts:
|
|
|
127
126
|
)
|
|
128
127
|
async def set_chat_administrator_custom_title(
|
|
129
128
|
self,
|
|
129
|
+
*,
|
|
130
130
|
custom_title: str,
|
|
131
131
|
chat_id: int | str | None = None,
|
|
132
132
|
user_id: int | None = None,
|
|
@@ -136,13 +136,10 @@ class ChatMemberShortcuts:
|
|
|
136
136
|
|
|
137
137
|
Use this method to set a custom title for an administrator in a supergroup
|
|
138
138
|
promoted by the bot. Returns True on success."""
|
|
139
|
-
|
|
140
139
|
...
|
|
141
140
|
|
|
142
141
|
|
|
143
|
-
class ChatMemberUpdatedCute(
|
|
144
|
-
BaseCute[ChatMemberUpdated], ChatMemberUpdated, ChatMemberShortcuts, kw_only=True
|
|
145
|
-
):
|
|
142
|
+
class ChatMemberUpdatedCute(BaseCute[ChatMemberUpdated], ChatMemberUpdated, ChatMemberShortcuts, kw_only=True):
|
|
146
143
|
api: API
|
|
147
144
|
|
|
148
145
|
@property
|
|
@@ -3,8 +3,9 @@ import typing
|
|
|
3
3
|
from fntypes.result import Result
|
|
4
4
|
|
|
5
5
|
from telegrinder.api.api import API, APIError
|
|
6
|
-
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params
|
|
6
|
+
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params
|
|
7
7
|
from telegrinder.model import get_params
|
|
8
|
+
from telegrinder.tools.magic import shortcut
|
|
8
9
|
from telegrinder.types.objects import *
|
|
9
10
|
|
|
10
11
|
|
|
@@ -19,18 +20,18 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
|
|
|
19
20
|
async def answer(
|
|
20
21
|
self,
|
|
21
22
|
results: InlineQueryResult | list[InlineQueryResult],
|
|
22
|
-
|
|
23
|
+
*,
|
|
24
|
+
button: InlineQueryResultsButton | None = None,
|
|
23
25
|
cache_time: int | None = None,
|
|
26
|
+
inline_query_id: str | None = None,
|
|
24
27
|
is_personal: bool | None = None,
|
|
25
28
|
next_offset: str | None = None,
|
|
26
|
-
button: InlineQueryResultsButton | None = None,
|
|
27
29
|
**other: typing.Any,
|
|
28
30
|
) -> Result[bool, APIError]:
|
|
29
31
|
"""Shortcut `API.answer_inline_query()`, see the [documentation](https://core.telegram.org/bots/api#answerinlinequery)
|
|
30
32
|
|
|
31
33
|
Use this method to send answers to an inline query. On success, True is returned.
|
|
32
34
|
No more than 50 results per query are allowed."""
|
|
33
|
-
|
|
34
35
|
params = compose_method_params(
|
|
35
36
|
get_params(locals()),
|
|
36
37
|
self,
|