telegrinder 0.1.dev168__py3-none-any.whl → 0.1.dev170__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 +9 -3
- telegrinder/bot/__init__.py +7 -5
- telegrinder/bot/cute_types/base.py +12 -14
- telegrinder/bot/cute_types/callback_query.py +54 -43
- telegrinder/bot/cute_types/chat_join_request.py +8 -7
- telegrinder/bot/cute_types/chat_member_updated.py +23 -17
- telegrinder/bot/cute_types/inline_query.py +1 -1
- telegrinder/bot/cute_types/message.py +331 -183
- telegrinder/bot/cute_types/update.py +4 -8
- telegrinder/bot/cute_types/utils.py +1 -5
- telegrinder/bot/dispatch/__init__.py +2 -3
- telegrinder/bot/dispatch/abc.py +4 -0
- telegrinder/bot/dispatch/context.py +9 -4
- telegrinder/bot/dispatch/dispatch.py +35 -33
- telegrinder/bot/dispatch/handler/func.py +34 -13
- telegrinder/bot/dispatch/handler/message_reply.py +6 -3
- telegrinder/bot/dispatch/middleware/abc.py +4 -4
- telegrinder/bot/dispatch/process.py +40 -13
- telegrinder/bot/dispatch/return_manager/abc.py +12 -12
- telegrinder/bot/dispatch/return_manager/callback_query.py +1 -3
- telegrinder/bot/dispatch/return_manager/inline_query.py +1 -3
- telegrinder/bot/dispatch/view/abc.py +37 -45
- telegrinder/bot/dispatch/view/box.py +66 -50
- telegrinder/bot/dispatch/view/message.py +1 -5
- telegrinder/bot/dispatch/view/raw.py +6 -6
- telegrinder/bot/dispatch/waiter_machine/__init__.py +2 -1
- telegrinder/bot/dispatch/waiter_machine/machine.py +77 -35
- telegrinder/bot/dispatch/waiter_machine/middleware.py +31 -7
- telegrinder/bot/dispatch/waiter_machine/short_state.py +17 -8
- telegrinder/bot/polling/polling.py +4 -4
- telegrinder/bot/rules/__init__.py +9 -6
- telegrinder/bot/rules/abc.py +99 -22
- telegrinder/bot/rules/adapter/__init__.py +4 -1
- telegrinder/bot/rules/adapter/abc.py +11 -6
- telegrinder/bot/rules/adapter/errors.py +1 -2
- telegrinder/bot/rules/adapter/event.py +14 -9
- telegrinder/bot/rules/adapter/node.py +42 -0
- telegrinder/bot/rules/callback_data.py +4 -4
- telegrinder/bot/rules/chat_join.py +3 -2
- telegrinder/bot/rules/command.py +26 -14
- telegrinder/bot/rules/enum_text.py +5 -5
- telegrinder/bot/rules/func.py +6 -6
- telegrinder/bot/rules/fuzzy.py +5 -7
- telegrinder/bot/rules/inline.py +4 -5
- telegrinder/bot/rules/integer.py +10 -8
- telegrinder/bot/rules/is_from.py +63 -91
- telegrinder/bot/rules/markup.py +5 -5
- telegrinder/bot/rules/mention.py +4 -4
- telegrinder/bot/rules/message.py +1 -1
- telegrinder/bot/rules/node.py +27 -0
- telegrinder/bot/rules/regex.py +5 -5
- telegrinder/bot/rules/rule_enum.py +4 -4
- telegrinder/bot/rules/start.py +5 -5
- telegrinder/bot/rules/text.py +9 -13
- telegrinder/bot/rules/update.py +4 -4
- telegrinder/bot/scenario/__init__.py +3 -3
- telegrinder/bot/scenario/choice.py +2 -3
- telegrinder/model.py +51 -16
- telegrinder/modules.py +14 -6
- telegrinder/msgspec_utils.py +67 -23
- telegrinder/node/__init__.py +26 -8
- telegrinder/node/attachment.py +13 -9
- telegrinder/node/base.py +27 -14
- telegrinder/node/callback_query.py +18 -0
- telegrinder/node/command.py +29 -0
- telegrinder/node/composer.py +119 -30
- telegrinder/node/me.py +14 -0
- telegrinder/node/message.py +2 -4
- telegrinder/node/polymorphic.py +44 -0
- telegrinder/node/rule.py +26 -22
- telegrinder/node/scope.py +36 -0
- telegrinder/node/source.py +37 -10
- telegrinder/node/text.py +11 -5
- telegrinder/node/tools/__init__.py +2 -2
- telegrinder/node/tools/generator.py +6 -6
- telegrinder/tools/__init__.py +8 -13
- telegrinder/tools/buttons.py +23 -17
- telegrinder/tools/error_handler/error_handler.py +11 -14
- telegrinder/tools/formatting/__init__.py +0 -6
- telegrinder/tools/formatting/html.py +10 -12
- telegrinder/tools/formatting/links.py +0 -5
- telegrinder/tools/formatting/spec_html_formats.py +0 -11
- telegrinder/tools/global_context/abc.py +1 -3
- telegrinder/tools/global_context/global_context.py +6 -16
- telegrinder/tools/i18n/simple.py +1 -3
- telegrinder/tools/kb_set/yaml.py +1 -2
- telegrinder/tools/keyboard.py +7 -8
- telegrinder/tools/limited_dict.py +1 -1
- telegrinder/tools/loop_wrapper/loop_wrapper.py +6 -5
- telegrinder/tools/magic.py +27 -5
- telegrinder/types/__init__.py +20 -0
- telegrinder/types/enums.py +37 -31
- telegrinder/types/methods.py +608 -327
- telegrinder/types/objects.py +1139 -716
- {telegrinder-0.1.dev168.dist-info → telegrinder-0.1.dev170.dist-info}/LICENSE +1 -1
- {telegrinder-0.1.dev168.dist-info → telegrinder-0.1.dev170.dist-info}/METADATA +6 -5
- telegrinder-0.1.dev170.dist-info/RECORD +143 -0
- telegrinder/bot/dispatch/composition.py +0 -88
- telegrinder-0.1.dev168.dist-info/RECORD +0 -137
- {telegrinder-0.1.dev168.dist-info → telegrinder-0.1.dev170.dist-info}/WHEEL +0 -0
telegrinder/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Telegrinder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern visionary telegram bot framework.
|
|
4
4
|
|
|
5
5
|
* Type hinted
|
|
6
6
|
* Customizable and extensible
|
|
@@ -51,16 +51,20 @@ from .bot import (
|
|
|
51
51
|
BaseView,
|
|
52
52
|
CallbackQueryCute,
|
|
53
53
|
CallbackQueryReturnManager,
|
|
54
|
+
CallbackQueryRule,
|
|
54
55
|
CallbackQueryView,
|
|
55
56
|
ChatJoinRequestCute,
|
|
57
|
+
ChatJoinRequestRule,
|
|
56
58
|
ChatJoinRequestView,
|
|
57
59
|
ChatMemberUpdatedCute,
|
|
58
60
|
ChatMemberView,
|
|
59
61
|
Checkbox,
|
|
62
|
+
Choice,
|
|
60
63
|
Dispatch,
|
|
61
64
|
FuncHandler,
|
|
62
65
|
InlineQueryCute,
|
|
63
66
|
InlineQueryReturnManager,
|
|
67
|
+
InlineQueryRule,
|
|
64
68
|
MessageCute,
|
|
65
69
|
MessageReplyHandler,
|
|
66
70
|
MessageReturnManager,
|
|
@@ -69,7 +73,6 @@ from .bot import (
|
|
|
69
73
|
Polling,
|
|
70
74
|
RawEventView,
|
|
71
75
|
ShortState,
|
|
72
|
-
SingleChoice,
|
|
73
76
|
Telegrinder,
|
|
74
77
|
UpdateCute,
|
|
75
78
|
ViewBox,
|
|
@@ -152,6 +155,9 @@ __all__ = (
|
|
|
152
155
|
"CallbackQueryView",
|
|
153
156
|
"ChatJoinRequest",
|
|
154
157
|
"ChatJoinRequestCute",
|
|
158
|
+
"CallbackQueryRule",
|
|
159
|
+
"ChatJoinRequestRule",
|
|
160
|
+
"InlineQueryRule",
|
|
155
161
|
"ChatJoinRequestView",
|
|
156
162
|
"ChatMemberUpdated",
|
|
157
163
|
"ChatMemberUpdatedCute",
|
|
@@ -190,7 +196,7 @@ __all__ = (
|
|
|
190
196
|
"ShortState",
|
|
191
197
|
"SimpleI18n",
|
|
192
198
|
"SimpleTranslator",
|
|
193
|
-
"
|
|
199
|
+
"Choice",
|
|
194
200
|
"Telegrinder",
|
|
195
201
|
"Token",
|
|
196
202
|
"Update",
|
telegrinder/bot/__init__.py
CHANGED
|
@@ -22,7 +22,6 @@ from .dispatch import (
|
|
|
22
22
|
CallbackQueryView,
|
|
23
23
|
ChatJoinRequestView,
|
|
24
24
|
ChatMemberView,
|
|
25
|
-
CompositionDispatch,
|
|
26
25
|
Context,
|
|
27
26
|
Dispatch,
|
|
28
27
|
FuncHandler,
|
|
@@ -35,11 +34,12 @@ from .dispatch import (
|
|
|
35
34
|
ShortState,
|
|
36
35
|
ViewBox,
|
|
37
36
|
WaiterMachine,
|
|
37
|
+
clear_wm_storage_worker,
|
|
38
38
|
register_manager,
|
|
39
39
|
)
|
|
40
40
|
from .polling import ABCPolling, Polling
|
|
41
|
-
from .rules import ABCRule, CallbackQueryRule, MessageRule
|
|
42
|
-
from .scenario import ABCScenario, Checkbox,
|
|
41
|
+
from .rules import ABCRule, CallbackQueryRule, ChatJoinRequestRule, InlineQueryRule, MessageRule
|
|
42
|
+
from .scenario import ABCScenario, Checkbox, Choice
|
|
43
43
|
|
|
44
44
|
__all__ = (
|
|
45
45
|
"ABCDispatch",
|
|
@@ -59,12 +59,13 @@ __all__ = (
|
|
|
59
59
|
"CallbackQueryReturnManager",
|
|
60
60
|
"CallbackQueryRule",
|
|
61
61
|
"CallbackQueryView",
|
|
62
|
+
"ChatJoinRequestRule",
|
|
63
|
+
"InlineQueryRule",
|
|
62
64
|
"ChatJoinRequestCute",
|
|
63
65
|
"ChatJoinRequestView",
|
|
64
66
|
"ChatMemberUpdatedCute",
|
|
65
67
|
"ChatMemberView",
|
|
66
68
|
"Checkbox",
|
|
67
|
-
"CompositionDispatch",
|
|
68
69
|
"Context",
|
|
69
70
|
"Dispatch",
|
|
70
71
|
"FuncHandler",
|
|
@@ -79,10 +80,11 @@ __all__ = (
|
|
|
79
80
|
"Polling",
|
|
80
81
|
"RawEventView",
|
|
81
82
|
"ShortState",
|
|
82
|
-
"
|
|
83
|
+
"Choice",
|
|
83
84
|
"Telegrinder",
|
|
84
85
|
"UpdateCute",
|
|
85
86
|
"ViewBox",
|
|
86
87
|
"WaiterMachine",
|
|
87
88
|
"register_manager",
|
|
89
|
+
"clear_wm_storage_worker",
|
|
88
90
|
)
|
|
@@ -9,28 +9,28 @@ from telegrinder.api import ABCAPI, API
|
|
|
9
9
|
from telegrinder.model import Model, get_params
|
|
10
10
|
|
|
11
11
|
F = typing.TypeVar("F", bound=typing.Callable[..., typing.Any])
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Cute = typing.TypeVar("Cute", bound="BaseCute")
|
|
13
|
+
Update = typing.TypeVar("Update", bound=Model)
|
|
14
14
|
|
|
15
15
|
Executor: typing.TypeAlias = typing.Callable[
|
|
16
|
-
[
|
|
16
|
+
[Cute, str, dict[str, typing.Any]],
|
|
17
17
|
typing.Awaitable[Result[typing.Any, typing.Any]],
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
if typing.TYPE_CHECKING:
|
|
21
21
|
|
|
22
|
-
class BaseCute(Model, typing.Generic[
|
|
22
|
+
class BaseCute(Model, typing.Generic[Update]):
|
|
23
23
|
api: ABCAPI
|
|
24
24
|
|
|
25
25
|
@classmethod
|
|
26
|
-
def from_update(cls, update:
|
|
26
|
+
def from_update(cls, update: Update, bound_api: ABCAPI) -> typing.Self: ...
|
|
27
27
|
|
|
28
28
|
@property
|
|
29
29
|
def ctx_api(self) -> API: ...
|
|
30
30
|
|
|
31
31
|
else:
|
|
32
32
|
|
|
33
|
-
class BaseCute(typing.Generic[
|
|
33
|
+
class BaseCute(typing.Generic[Update]):
|
|
34
34
|
@classmethod
|
|
35
35
|
def from_update(cls, update, bound_api):
|
|
36
36
|
return cls(**update.to_dict(), api=bound_api)
|
|
@@ -47,13 +47,13 @@ else:
|
|
|
47
47
|
|
|
48
48
|
def compose_method_params(
|
|
49
49
|
params: dict[str, typing.Any],
|
|
50
|
-
update:
|
|
50
|
+
update: Cute,
|
|
51
51
|
*,
|
|
52
52
|
default_params: set[str | tuple[str, str]] | None = None,
|
|
53
|
-
validators: dict[str, typing.Callable[[
|
|
53
|
+
validators: dict[str, typing.Callable[[Cute], bool]] | None = None,
|
|
54
54
|
) -> dict[str, typing.Any]:
|
|
55
55
|
"""Compose method `params` from `update` by `default_params` and `validators`.
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
:param params: Method params.
|
|
58
58
|
:param update: Update object.
|
|
59
59
|
:param default_params: Default params. \
|
|
@@ -84,21 +84,19 @@ def compose_method_params(
|
|
|
84
84
|
def shortcut(
|
|
85
85
|
method_name: str,
|
|
86
86
|
*,
|
|
87
|
-
executor: Executor[
|
|
87
|
+
executor: Executor[Cute] | None = None,
|
|
88
88
|
custom_params: set[str] | None = None,
|
|
89
89
|
):
|
|
90
90
|
def wrapper(func: F) -> F:
|
|
91
91
|
@wraps(func)
|
|
92
92
|
async def inner(
|
|
93
|
-
self:
|
|
93
|
+
self: Cute,
|
|
94
94
|
*args: typing.Any,
|
|
95
95
|
**kwargs: typing.Any,
|
|
96
96
|
) -> typing.Any:
|
|
97
97
|
if executor is None:
|
|
98
98
|
return await func(self, *args, **kwargs)
|
|
99
|
-
signature_params = {
|
|
100
|
-
k: p for k, p in inspect.signature(func).parameters.items() if k != "self"
|
|
101
|
-
}
|
|
99
|
+
signature_params = {k: p for k, p in inspect.signature(func).parameters.items() if k != "self"}
|
|
102
100
|
params: dict[str, typing.Any] = {}
|
|
103
101
|
index = 0
|
|
104
102
|
|
|
@@ -9,6 +9,7 @@ from telegrinder.model import get_params
|
|
|
9
9
|
from telegrinder.msgspec_utils import Option, decoder
|
|
10
10
|
from telegrinder.types import (
|
|
11
11
|
CallbackQuery,
|
|
12
|
+
Chat,
|
|
12
13
|
InlineKeyboardMarkup,
|
|
13
14
|
InputFile,
|
|
14
15
|
InputMedia,
|
|
@@ -44,7 +45,7 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
44
45
|
by the bot with the callback button that originated the query."""
|
|
45
46
|
|
|
46
47
|
return self.message.map(
|
|
47
|
-
lambda m: m.only().map(lambda m: m.is_topic_message.unwrap_or(False)).unwrap_or(False)
|
|
48
|
+
lambda m: m.only().map(lambda m: m.is_topic_message.unwrap_or(False)).unwrap_or(False),
|
|
48
49
|
)
|
|
49
50
|
|
|
50
51
|
@property
|
|
@@ -54,12 +55,7 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
54
55
|
This will be present if the message is sent
|
|
55
56
|
by the bot with the callback button that originated the query."""
|
|
56
57
|
|
|
57
|
-
return (
|
|
58
|
-
self.message.unwrap()
|
|
59
|
-
.only()
|
|
60
|
-
.map(lambda m: m.message_thread_id.unwrap())
|
|
61
|
-
.cast(Some, Nothing)
|
|
62
|
-
)
|
|
58
|
+
return self.message.unwrap().only().map(lambda m: m.message_thread_id.unwrap()).cast(Some, Nothing)
|
|
63
59
|
|
|
64
60
|
@property
|
|
65
61
|
def message_id(self) -> Option[int]:
|
|
@@ -69,6 +65,14 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
69
65
|
|
|
70
66
|
return self.message.map(lambda m: m.v.message_id)
|
|
71
67
|
|
|
68
|
+
@property
|
|
69
|
+
def chat(self) -> Option[Chat]:
|
|
70
|
+
"""Optional. Chat the callback query originated from. This will be present
|
|
71
|
+
if the message is sent by the bot with the callback button that originated the query.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
return self.message.map(lambda m: m.v.chat)
|
|
75
|
+
|
|
72
76
|
def decode_callback_data(self) -> Option[dict[str, typing.Any]]:
|
|
73
77
|
if "cached_callback_data" in self.__dict__:
|
|
74
78
|
return self.__dict__["cached_callback_data"]
|
|
@@ -78,7 +82,7 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
78
82
|
self.__dict__["cached_callback_data"] = data
|
|
79
83
|
return data
|
|
80
84
|
|
|
81
|
-
@shortcut("answer_callback_query")
|
|
85
|
+
@shortcut("answer_callback_query", custom_params={"callback_query_id"})
|
|
82
86
|
async def answer(
|
|
83
87
|
self,
|
|
84
88
|
text: str | None = None,
|
|
@@ -90,8 +94,8 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
90
94
|
) -> Result[bool, APIError]:
|
|
91
95
|
"""Shortcut `API.answer_callback_query()`, see the [documentation](https://core.telegram.org/bots/api#answercallbackquery)
|
|
92
96
|
|
|
93
|
-
Use this method to send answers to callback queries sent from inline keyboards.
|
|
94
|
-
The answer will be displayed to the user as a notification at the top of the
|
|
97
|
+
Use this method to send answers to callback queries sent from inline keyboards.
|
|
98
|
+
The answer will be displayed to the user as a notification at the top of the
|
|
95
99
|
chat screen or as an alert. On success, True is returned.
|
|
96
100
|
|
|
97
101
|
:param callback_query_id: Unique identifier for the query to be answered.
|
|
@@ -119,7 +123,14 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
119
123
|
|
|
120
124
|
@shortcut(
|
|
121
125
|
"copy_message",
|
|
122
|
-
custom_params={
|
|
126
|
+
custom_params={
|
|
127
|
+
"reply_parameters",
|
|
128
|
+
"message_thread_id",
|
|
129
|
+
"chat_id",
|
|
130
|
+
"message_id",
|
|
131
|
+
"from_chat_id",
|
|
132
|
+
"reply_markup",
|
|
133
|
+
},
|
|
123
134
|
)
|
|
124
135
|
async def copy(
|
|
125
136
|
self,
|
|
@@ -138,11 +149,11 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
138
149
|
) -> Result[MessageId, APIError]:
|
|
139
150
|
"""Shortcut `API.copy_message()`, see the [documentation](https://core.telegram.org/bots/api#copymessage)
|
|
140
151
|
|
|
141
|
-
Use this method to copy messages of any kind. Service messages, giveaway
|
|
142
|
-
messages, giveaway winners messages, and invoice messages can't be copied.
|
|
143
|
-
A quiz poll can be copied only if the value of the field correct_option_id
|
|
144
|
-
is known to the bot. The method is analogous to the method forwardMessage,
|
|
145
|
-
but the copied message doesn't have a link to the original message. Returns
|
|
152
|
+
Use this method to copy messages of any kind. Service messages, giveaway
|
|
153
|
+
messages, giveaway winners messages, and invoice messages can't be copied.
|
|
154
|
+
A quiz poll can be copied only if the value of the field correct_option_id
|
|
155
|
+
is known to the bot. The method is analogous to the method forwardMessage,
|
|
156
|
+
but the copied message doesn't have a link to the original message. Returns
|
|
146
157
|
the MessageId of the sent message on success.
|
|
147
158
|
|
|
148
159
|
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
@@ -178,7 +189,7 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
178
189
|
|
|
179
190
|
return await MessageCute.copy(self, **get_params(locals())) # type: ignore
|
|
180
191
|
|
|
181
|
-
@shortcut("delete_message", custom_params={"message_thread_id"})
|
|
192
|
+
@shortcut("delete_message", custom_params={"message_thread_id", "chat_id", "message_id"})
|
|
182
193
|
async def delete(
|
|
183
194
|
self,
|
|
184
195
|
chat_id: int | None = None,
|
|
@@ -188,16 +199,16 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
188
199
|
) -> Result[bool, APIError]:
|
|
189
200
|
"""Shortcut `API.delete_message()`, see the [documentation](https://core.telegram.org/bots/api#deletemessage)
|
|
190
201
|
|
|
191
|
-
Use this method to delete a message, including service messages, with the
|
|
192
|
-
following limitations: - A message can only be deleted if it was sent less
|
|
193
|
-
than 48 hours ago. - Service messages about a supergroup, channel, or forum
|
|
194
|
-
topic creation can't be deleted. - A dice message in a private chat can only
|
|
195
|
-
be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing
|
|
196
|
-
messages in private chats, groups, and supergroups. - Bots can delete incoming
|
|
197
|
-
messages in private chats. - Bots granted can_post_messages permissions
|
|
198
|
-
can delete outgoing messages in channels. - If the bot is an administrator
|
|
199
|
-
of a group, it can delete any message there. - If the bot has can_delete_messages
|
|
200
|
-
permission in a supergroup or a channel, it can delete any message there.
|
|
202
|
+
Use this method to delete a message, including service messages, with the
|
|
203
|
+
following limitations: - A message can only be deleted if it was sent less
|
|
204
|
+
than 48 hours ago. - Service messages about a supergroup, channel, or forum
|
|
205
|
+
topic creation can't be deleted. - A dice message in a private chat can only
|
|
206
|
+
be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing
|
|
207
|
+
messages in private chats, groups, and supergroups. - Bots can delete incoming
|
|
208
|
+
messages in private chats. - Bots granted can_post_messages permissions
|
|
209
|
+
can delete outgoing messages in channels. - If the bot is an administrator
|
|
210
|
+
of a group, it can delete any message there. - If the bot has can_delete_messages
|
|
211
|
+
permission in a supergroup or a channel, it can delete any message there.
|
|
201
212
|
Returns True on success.
|
|
202
213
|
|
|
203
214
|
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
@@ -230,8 +241,8 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
230
241
|
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
231
242
|
"""Shortcut `API.edit_message_text()`, see the [documentation](https://core.telegram.org/bots/api#editmessagetext)
|
|
232
243
|
|
|
233
|
-
Use this method to edit text and game messages. On success, if the edited
|
|
234
|
-
message is not an inline message, the edited Message is returned, otherwise
|
|
244
|
+
Use this method to edit text and game messages. On success, if the edited
|
|
245
|
+
message is not an inline message, the edited Message is returned, otherwise
|
|
235
246
|
True is returned.
|
|
236
247
|
|
|
237
248
|
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
@@ -281,9 +292,9 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
281
292
|
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
282
293
|
"""Shortcut `API.edit_message_live_location()`, see the [documentation](https://core.telegram.org/bots/api#editmessagelivelocation)
|
|
283
294
|
|
|
284
|
-
Use this method to edit live location messages. A location can be edited
|
|
285
|
-
until its live_period expires or editing is explicitly disabled by a call
|
|
286
|
-
to stopMessageLiveLocation. On success, if the edited message is not an
|
|
295
|
+
Use this method to edit live location messages. A location can be edited
|
|
296
|
+
until its live_period expires or editing is explicitly disabled by a call
|
|
297
|
+
to stopMessageLiveLocation. On success, if the edited message is not an
|
|
287
298
|
inline message, the edited Message is returned, otherwise True is returned.
|
|
288
299
|
|
|
289
300
|
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
@@ -333,8 +344,8 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
333
344
|
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
334
345
|
"""Shortcut `API.edit_message_caption()`, see the [documentation](https://core.telegram.org/bots/api#editmessagecaption)
|
|
335
346
|
|
|
336
|
-
Use this method to edit captions of messages. On success, if the edited message
|
|
337
|
-
is not an inline message, the edited Message is returned, otherwise True
|
|
347
|
+
Use this method to edit captions of messages. On success, if the edited message
|
|
348
|
+
is not an inline message, the edited Message is returned, otherwise True
|
|
338
349
|
is returned.
|
|
339
350
|
|
|
340
351
|
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
@@ -388,12 +399,12 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
388
399
|
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
389
400
|
"""Shortcut `API.edit_message_media()`, see the [documentation](https://core.telegram.org/bots/api#editmessagemedia)
|
|
390
401
|
|
|
391
|
-
Use this method to edit animation, audio, document, photo, or video messages.
|
|
392
|
-
If a message is part of a message album, then it can be edited only to an audio
|
|
393
|
-
for audio albums, only to a document for document albums and to a photo or
|
|
394
|
-
a video otherwise. When an inline message is edited, a new file can't be uploaded;
|
|
395
|
-
use a previously uploaded file via its file_id or specify a URL. On success,
|
|
396
|
-
if the edited message is not an inline message, the edited Message is returned,
|
|
402
|
+
Use this method to edit animation, audio, document, photo, or video messages.
|
|
403
|
+
If a message is part of a message album, then it can be edited only to an audio
|
|
404
|
+
for audio albums, only to a document for document albums and to a photo or
|
|
405
|
+
a video otherwise. When an inline message is edited, a new file can't be uploaded;
|
|
406
|
+
use a previously uploaded file via its file_id or specify a URL. On success,
|
|
407
|
+
if the edited message is not an inline message, the edited Message is returned,
|
|
397
408
|
otherwise True is returned.
|
|
398
409
|
|
|
399
410
|
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
@@ -417,7 +428,7 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
417
428
|
|
|
418
429
|
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, \
|
|
419
430
|
which can be specified instead of parse_mode.
|
|
420
|
-
|
|
431
|
+
|
|
421
432
|
:param type: Required if media is not an `str | InputMedia` object. Type of the media, \
|
|
422
433
|
must be one of `photo`, `video`, `animation`, `audio`, `document`.
|
|
423
434
|
|
|
@@ -441,8 +452,8 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
441
452
|
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
442
453
|
"""Shortcut `API.edit_message_reply_markup()`, see the [documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)
|
|
443
454
|
|
|
444
|
-
Use this method to edit only the reply markup of messages. On success, if
|
|
445
|
-
the edited message is not an inline message, the edited Message is returned,
|
|
455
|
+
Use this method to edit only the reply markup of messages. On success, if
|
|
456
|
+
the edited message is not an inline message, the edited Message is returned,
|
|
446
457
|
otherwise True is returned.
|
|
447
458
|
|
|
448
459
|
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
@@ -9,9 +9,7 @@ from .base import BaseCute, shortcut
|
|
|
9
9
|
from .chat_member_updated import ChatMemberShortcuts, chat_member_interaction
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class ChatJoinRequestCute(
|
|
13
|
-
BaseCute[ChatJoinRequest], ChatJoinRequest, ChatMemberShortcuts, kw_only=True
|
|
14
|
-
):
|
|
12
|
+
class ChatJoinRequestCute(BaseCute[ChatJoinRequest], ChatJoinRequest, ChatMemberShortcuts, kw_only=True):
|
|
15
13
|
api: ABCAPI
|
|
16
14
|
|
|
17
15
|
@property
|
|
@@ -31,8 +29,8 @@ class ChatJoinRequestCute(
|
|
|
31
29
|
) -> Result[bool, APIError]:
|
|
32
30
|
"""Shortcut `API.approve_chat_join_request()`, see the [documentation](https://core.telegram.org/bots/api#approvechatjoinrequest)
|
|
33
31
|
|
|
34
|
-
Use this method to approve a chat join request. The bot must be an administrator
|
|
35
|
-
in the chat for this to work and must have the can_invite_users administrator
|
|
32
|
+
Use this method to approve a chat join request. The bot must be an administrator
|
|
33
|
+
in the chat for this to work and must have the can_invite_users administrator
|
|
36
34
|
right. Returns True on success.
|
|
37
35
|
|
|
38
36
|
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
@@ -52,8 +50,8 @@ class ChatJoinRequestCute(
|
|
|
52
50
|
) -> Result[bool, APIError]:
|
|
53
51
|
"""Shortcut `API.decline_chat_join_request()`, see the [documentation](https://core.telegram.org/bots/api#declinechatjoinrequest)
|
|
54
52
|
|
|
55
|
-
Use this method to decline a chat join request. The bot must be an administrator
|
|
56
|
-
in the chat for this to work and must have the can_invite_users administrator
|
|
53
|
+
Use this method to decline a chat join request. The bot must be an administrator
|
|
54
|
+
in the chat for this to work and must have the can_invite_users administrator
|
|
57
55
|
right. Returns True on success.
|
|
58
56
|
|
|
59
57
|
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
@@ -63,3 +61,6 @@ class ChatJoinRequestCute(
|
|
|
63
61
|
"""
|
|
64
62
|
|
|
65
63
|
...
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
__all__ = ("ChatJoinRequestCute",)
|
|
@@ -40,10 +40,10 @@ class ChatMemberShortcuts:
|
|
|
40
40
|
) -> Result[bool, APIError]:
|
|
41
41
|
"""Shortcut `API.ban_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#banchatmember)
|
|
42
42
|
|
|
43
|
-
Use this method to ban a user in a group, a supergroup or a channel. In the case
|
|
44
|
-
of supergroups and channels, the user will not be able to return to the chat
|
|
45
|
-
on their own using invite links, etc., unless unbanned first. The bot must
|
|
46
|
-
be an administrator in the chat for this to work and must have the appropriate
|
|
43
|
+
Use this method to ban a user in a group, a supergroup or a channel. In the case
|
|
44
|
+
of supergroups and channels, the user will not be able to return to the chat
|
|
45
|
+
on their own using invite links, etc., unless unbanned first. The bot must
|
|
46
|
+
be an administrator in the chat for this to work and must have the appropriate
|
|
47
47
|
administrator rights. Returns True on success.
|
|
48
48
|
|
|
49
49
|
:param chat_id: Unique identifier for the target group or username of the target supergroup \
|
|
@@ -72,12 +72,12 @@ class ChatMemberShortcuts:
|
|
|
72
72
|
) -> Result[bool, APIError]:
|
|
73
73
|
"""Shortcut `API.unban_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#unbanchatmember)
|
|
74
74
|
|
|
75
|
-
Use this method to unban a previously banned user in a supergroup or channel.
|
|
76
|
-
The user will not return to the group or channel automatically, but will
|
|
77
|
-
be able to join via link, etc. The bot must be an administrator for this to
|
|
78
|
-
work. By default, this method guarantees that after the call the user is
|
|
79
|
-
not a member of the chat, but will be able to join it. So if the user is a member
|
|
80
|
-
of the chat they will also be removed from the chat. If you don't want this,
|
|
75
|
+
Use this method to unban a previously banned user in a supergroup or channel.
|
|
76
|
+
The user will not return to the group or channel automatically, but will
|
|
77
|
+
be able to join via link, etc. The bot must be an administrator for this to
|
|
78
|
+
work. By default, this method guarantees that after the call the user is
|
|
79
|
+
not a member of the chat, but will be able to join it. So if the user is a member
|
|
80
|
+
of the chat they will also be removed from the chat. If you don't want this,
|
|
81
81
|
use the parameter only_if_banned. Returns True on success.
|
|
82
82
|
|
|
83
83
|
:param chat_id: Unique identifier for the target group or username of the target supergroup \
|
|
@@ -106,9 +106,9 @@ class ChatMemberShortcuts:
|
|
|
106
106
|
) -> Result[bool, APIError]:
|
|
107
107
|
"""Shortcut `API.restrict_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#restrictchatmember)
|
|
108
108
|
|
|
109
|
-
Use this method to restrict a user in a supergroup. The bot must be an administrator
|
|
110
|
-
in the supergroup for this to work and must have the appropriate administrator
|
|
111
|
-
rights. Pass True for all permissions to lift restrictions from a user.
|
|
109
|
+
Use this method to restrict a user in a supergroup. The bot must be an administrator
|
|
110
|
+
in the supergroup for this to work and must have the appropriate administrator
|
|
111
|
+
rights. Pass True for all permissions to lift restrictions from a user.
|
|
112
112
|
Returns True on success.
|
|
113
113
|
|
|
114
114
|
:param chat_id: Unique identifier for the target chat or username of the target supergroup \
|
|
@@ -155,9 +155,9 @@ class ChatMemberShortcuts:
|
|
|
155
155
|
) -> Result[bool, APIError]:
|
|
156
156
|
"""Shortcut `API.promote_chat_member()`, see the [documentation](https://core.telegram.org/bots/api#promotechatmember)
|
|
157
157
|
|
|
158
|
-
Use this method to promote or demote a user in a supergroup or a channel. The
|
|
159
|
-
bot must be an administrator in the chat for this to work and must have the
|
|
160
|
-
appropriate administrator rights. Pass False for all boolean parameters
|
|
158
|
+
Use this method to promote or demote a user in a supergroup or a channel. The
|
|
159
|
+
bot must be an administrator in the chat for this to work and must have the
|
|
160
|
+
appropriate administrator rights. Pass False for all boolean parameters
|
|
161
161
|
to demote a user. Returns True on success.
|
|
162
162
|
|
|
163
163
|
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
@@ -217,7 +217,7 @@ class ChatMemberShortcuts:
|
|
|
217
217
|
) -> Result[bool, APIError]:
|
|
218
218
|
"""Shortcut `API.set_chat_administrator_custom_title()`, see the [documentation](https://core.telegram.org/bots/api#setchatadministratorcustomtitle)
|
|
219
219
|
|
|
220
|
-
Use this method to set a custom title for an administrator in a supergroup
|
|
220
|
+
Use this method to set a custom title for an administrator in a supergroup
|
|
221
221
|
promoted by the bot. Returns True on success.
|
|
222
222
|
|
|
223
223
|
:param chat_id: Unique identifier for the target chat or username of the target supergroup \
|
|
@@ -244,3 +244,9 @@ class ChatMemberUpdatedCute(
|
|
|
244
244
|
@property
|
|
245
245
|
def user_id(self) -> int:
|
|
246
246
|
return self.from_user.id
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
__all__ = (
|
|
250
|
+
"ChatMemberUpdatedCute",
|
|
251
|
+
"ChatMemberShortcuts",
|
|
252
|
+
)
|
|
@@ -34,7 +34,7 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
|
|
|
34
34
|
) -> Result[bool, APIError]:
|
|
35
35
|
"""Shortcut `API.answer_inline_query()`, see the [documentation](https://core.telegram.org/bots/api#answerinlinequery)
|
|
36
36
|
|
|
37
|
-
Use this method to send answers to an inline query. On success, True is returned.
|
|
37
|
+
Use this method to send answers to an inline query. On success, True is returned.
|
|
38
38
|
No more than 50 results per query are allowed.
|
|
39
39
|
|
|
40
40
|
:param inline_query_id: Unique identifier for the answered query.
|