telegrinder 0.1.dev165__py3-none-any.whl → 0.1.dev166__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 +22 -0
- telegrinder/api/abc.py +1 -1
- telegrinder/api/api.py +8 -6
- telegrinder/api/error.py +2 -3
- telegrinder/bot/__init__.py +14 -0
- telegrinder/bot/bot.py +5 -3
- telegrinder/bot/cute_types/__init__.py +4 -0
- telegrinder/bot/cute_types/base.py +22 -13
- telegrinder/bot/cute_types/chat_join_request.py +63 -0
- telegrinder/bot/cute_types/chat_member_updated.py +244 -0
- telegrinder/bot/cute_types/message.py +34 -7
- telegrinder/bot/cute_types/update.py +5 -4
- telegrinder/bot/cute_types/utils.py +39 -17
- telegrinder/bot/dispatch/__init__.py +9 -1
- telegrinder/bot/dispatch/composition.py +10 -8
- telegrinder/bot/dispatch/context.py +9 -10
- telegrinder/bot/dispatch/dispatch.py +29 -19
- telegrinder/bot/dispatch/handler/abc.py +1 -0
- telegrinder/bot/dispatch/handler/func.py +29 -6
- telegrinder/bot/dispatch/handler/message_reply.py +2 -3
- telegrinder/bot/dispatch/middleware/abc.py +2 -4
- telegrinder/bot/dispatch/process.py +4 -3
- telegrinder/bot/dispatch/return_manager/__init__.py +1 -1
- telegrinder/bot/dispatch/return_manager/abc.py +33 -21
- telegrinder/bot/dispatch/return_manager/callback_query.py +4 -2
- telegrinder/bot/dispatch/return_manager/inline_query.py +4 -2
- telegrinder/bot/dispatch/return_manager/message.py +12 -6
- telegrinder/bot/dispatch/view/__init__.py +8 -2
- telegrinder/bot/dispatch/view/abc.py +26 -20
- telegrinder/bot/dispatch/view/box.py +72 -1
- telegrinder/bot/dispatch/view/callback_query.py +1 -3
- telegrinder/bot/dispatch/view/chat_join_request.py +17 -0
- telegrinder/bot/dispatch/view/chat_member.py +26 -0
- telegrinder/bot/dispatch/view/message.py +23 -1
- telegrinder/bot/dispatch/view/raw.py +116 -0
- telegrinder/bot/dispatch/waiter_machine/__init__.py +2 -1
- telegrinder/bot/dispatch/waiter_machine/machine.py +73 -19
- telegrinder/bot/dispatch/waiter_machine/middleware.py +3 -3
- telegrinder/bot/dispatch/waiter_machine/short_state.py +6 -3
- telegrinder/bot/polling/polling.py +4 -2
- telegrinder/bot/rules/__init__.py +20 -12
- telegrinder/bot/rules/abc.py +0 -9
- telegrinder/bot/rules/adapter/event.py +31 -22
- telegrinder/bot/rules/callback_data.py +15 -20
- telegrinder/bot/rules/chat_join.py +47 -0
- telegrinder/bot/rules/enum_text.py +7 -2
- telegrinder/bot/rules/inline.py +3 -3
- telegrinder/bot/rules/is_from.py +36 -50
- telegrinder/bot/rules/message.py +17 -0
- telegrinder/bot/rules/message_entities.py +1 -1
- telegrinder/bot/rules/start.py +6 -4
- telegrinder/bot/rules/text.py +2 -1
- telegrinder/bot/rules/update.py +16 -0
- telegrinder/bot/scenario/checkbox.py +9 -7
- telegrinder/client/aiohttp.py +4 -4
- telegrinder/model.py +33 -19
- telegrinder/modules.py +16 -32
- telegrinder/msgspec_utils.py +37 -36
- telegrinder/node/__init__.py +12 -12
- telegrinder/node/attachment.py +15 -5
- telegrinder/node/base.py +24 -16
- telegrinder/node/composer.py +8 -6
- telegrinder/node/container.py +1 -1
- telegrinder/node/rule.py +4 -4
- telegrinder/node/source.py +4 -2
- telegrinder/node/tools/generator.py +1 -1
- telegrinder/tools/__init__.py +1 -1
- telegrinder/tools/error_handler/abc.py +4 -3
- telegrinder/tools/error_handler/error_handler.py +22 -16
- telegrinder/tools/formatting/html.py +15 -7
- telegrinder/tools/formatting/spec_html_formats.py +1 -1
- telegrinder/tools/global_context/abc.py +5 -1
- telegrinder/tools/global_context/telegrinder_ctx.py +1 -1
- telegrinder/tools/i18n/base.py +4 -3
- telegrinder/tools/i18n/simple.py +1 -3
- telegrinder/tools/keyboard.py +1 -1
- telegrinder/tools/loop_wrapper/loop_wrapper.py +24 -16
- telegrinder/tools/magic.py +1 -1
- telegrinder/types/__init__.py +206 -0
- telegrinder/types/enums.py +34 -0
- telegrinder/types/methods.py +52 -47
- telegrinder/types/objects.py +531 -88
- telegrinder/verification_utils.py +3 -1
- {telegrinder-0.1.dev165.dist-info → telegrinder-0.1.dev166.dist-info}/METADATA +1 -1
- telegrinder-0.1.dev166.dist-info/RECORD +136 -0
- telegrinder-0.1.dev165.dist-info/RECORD +0 -128
- {telegrinder-0.1.dev165.dist-info → telegrinder-0.1.dev166.dist-info}/LICENSE +0 -0
- {telegrinder-0.1.dev165.dist-info → telegrinder-0.1.dev166.dist-info}/WHEEL +0 -0
telegrinder/types/methods.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import typing
|
|
2
|
+
from datetime import datetime
|
|
2
3
|
|
|
3
4
|
from fntypes.co import Result, Variative
|
|
4
5
|
|
|
5
6
|
from telegrinder.api.error import APIError
|
|
6
7
|
from telegrinder.model import full_result, get_params
|
|
8
|
+
from telegrinder.types.enums import * # noqa: F403
|
|
7
9
|
from telegrinder.types.objects import * # noqa: F403
|
|
8
10
|
|
|
9
11
|
if typing.TYPE_CHECKING:
|
|
@@ -11,7 +13,7 @@ if typing.TYPE_CHECKING:
|
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class APIMethods:
|
|
14
|
-
"""Telegram Bot API 7.
|
|
16
|
+
"""Telegram Bot API 7.3 methods, released `May 6, 2024`."""
|
|
15
17
|
|
|
16
18
|
def __init__(self, api: "ABCAPI") -> None:
|
|
17
19
|
self.api = api
|
|
@@ -252,8 +254,7 @@ class APIMethods:
|
|
|
252
254
|
|
|
253
255
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
254
256
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
255
|
-
or to force a reply from the user.
|
|
256
|
-
of a business account.
|
|
257
|
+
or to force a reply from the user.
|
|
257
258
|
"""
|
|
258
259
|
|
|
259
260
|
method_response = await self.api.request_raw(
|
|
@@ -400,7 +401,7 @@ class APIMethods:
|
|
|
400
401
|
:param reply_parameters: Description of the message to reply to.
|
|
401
402
|
|
|
402
403
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
403
|
-
keyboard, custom reply keyboard, instructions to remove reply keyboard \
|
|
404
|
+
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
404
405
|
or to force a reply from the user.
|
|
405
406
|
"""
|
|
406
407
|
|
|
@@ -519,8 +520,7 @@ class APIMethods:
|
|
|
519
520
|
|
|
520
521
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
521
522
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
522
|
-
or to force a reply from the user.
|
|
523
|
-
of a business account.
|
|
523
|
+
or to force a reply from the user.
|
|
524
524
|
"""
|
|
525
525
|
|
|
526
526
|
method_response = await self.api.request_raw(
|
|
@@ -606,8 +606,7 @@ class APIMethods:
|
|
|
606
606
|
|
|
607
607
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
608
608
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
609
|
-
or to force a reply from the user.
|
|
610
|
-
of a business account.
|
|
609
|
+
or to force a reply from the user.
|
|
611
610
|
"""
|
|
612
611
|
|
|
613
612
|
method_response = await self.api.request_raw(
|
|
@@ -687,8 +686,7 @@ class APIMethods:
|
|
|
687
686
|
|
|
688
687
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
689
688
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
690
|
-
or to force a reply from the user.
|
|
691
|
-
of a business account.
|
|
689
|
+
or to force a reply from the user.
|
|
692
690
|
"""
|
|
693
691
|
|
|
694
692
|
method_response = await self.api.request_raw(
|
|
@@ -780,8 +778,7 @@ class APIMethods:
|
|
|
780
778
|
|
|
781
779
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
782
780
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
783
|
-
or to force a reply from the user.
|
|
784
|
-
of a business account.
|
|
781
|
+
or to force a reply from the user.
|
|
785
782
|
"""
|
|
786
783
|
|
|
787
784
|
method_response = await self.api.request_raw(
|
|
@@ -869,8 +866,7 @@ class APIMethods:
|
|
|
869
866
|
|
|
870
867
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
871
868
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
872
|
-
or to force a reply from the user.
|
|
873
|
-
of a business account.
|
|
869
|
+
or to force a reply from the user.
|
|
874
870
|
"""
|
|
875
871
|
|
|
876
872
|
method_response = await self.api.request_raw(
|
|
@@ -905,9 +901,10 @@ class APIMethods:
|
|
|
905
901
|
|
|
906
902
|
Use this method to send audio files, if you want Telegram clients to display
|
|
907
903
|
the file as a playable voice message. For this to work, your audio must be
|
|
908
|
-
in an .OGG file encoded with OPUS
|
|
909
|
-
|
|
910
|
-
messages of up to 50 MB in size, this
|
|
904
|
+
in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other
|
|
905
|
+
formats may be sent as Audio or Document). On success, the sent Message is
|
|
906
|
+
returned. Bots can currently send voice messages of up to 50 MB in size, this
|
|
907
|
+
limit may be changed in the future.
|
|
911
908
|
|
|
912
909
|
:param business_connection_id: Unique identifier of the business connection on behalf of which the message \
|
|
913
910
|
will be sent.
|
|
@@ -941,8 +938,7 @@ class APIMethods:
|
|
|
941
938
|
|
|
942
939
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
943
940
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
944
|
-
or to force a reply from the user.
|
|
945
|
-
of a business account.
|
|
941
|
+
or to force a reply from the user.
|
|
946
942
|
"""
|
|
947
943
|
|
|
948
944
|
method_response = await self.api.request_raw(
|
|
@@ -1012,8 +1008,7 @@ class APIMethods:
|
|
|
1012
1008
|
|
|
1013
1009
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1014
1010
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1015
|
-
or to force a reply from the user.
|
|
1016
|
-
of a business account.
|
|
1011
|
+
or to force a reply from the user.
|
|
1017
1012
|
"""
|
|
1018
1013
|
|
|
1019
1014
|
method_response = await self.api.request_raw(
|
|
@@ -1108,8 +1103,9 @@ class APIMethods:
|
|
|
1108
1103
|
|
|
1109
1104
|
:param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500. \
|
|
1110
1105
|
|
|
1111
|
-
:param live_period: Period in seconds
|
|
1112
|
-
should be between 60 and 86400
|
|
1106
|
+
:param live_period: Period in seconds during which the location will be updated (see Live Locations, \
|
|
1107
|
+
should be between 60 and 86400, or 0x7FFFFFFF for live locations that can \
|
|
1108
|
+
be edited indefinitely.
|
|
1113
1109
|
|
|
1114
1110
|
:param heading: For live locations, a direction in which the user is moving, in degrees. \
|
|
1115
1111
|
Must be between 1 and 360 if specified.
|
|
@@ -1125,8 +1121,7 @@ class APIMethods:
|
|
|
1125
1121
|
|
|
1126
1122
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1127
1123
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1128
|
-
or to force a reply from the user.
|
|
1129
|
-
of a business account.
|
|
1124
|
+
or to force a reply from the user.
|
|
1130
1125
|
"""
|
|
1131
1126
|
|
|
1132
1127
|
method_response = await self.api.request_raw(
|
|
@@ -1199,8 +1194,7 @@ class APIMethods:
|
|
|
1199
1194
|
|
|
1200
1195
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1201
1196
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1202
|
-
or to force a reply from the user.
|
|
1203
|
-
of a business account.
|
|
1197
|
+
or to force a reply from the user.
|
|
1204
1198
|
"""
|
|
1205
1199
|
|
|
1206
1200
|
method_response = await self.api.request_raw(
|
|
@@ -1259,8 +1253,7 @@ class APIMethods:
|
|
|
1259
1253
|
|
|
1260
1254
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1261
1255
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1262
|
-
or to force a reply from the user.
|
|
1263
|
-
of a business account.
|
|
1256
|
+
or to force a reply from the user.
|
|
1264
1257
|
"""
|
|
1265
1258
|
|
|
1266
1259
|
method_response = await self.api.request_raw(
|
|
@@ -1273,9 +1266,11 @@ class APIMethods:
|
|
|
1273
1266
|
self,
|
|
1274
1267
|
chat_id: int | str,
|
|
1275
1268
|
question: str,
|
|
1276
|
-
options: list[
|
|
1269
|
+
options: list[InputPollOption],
|
|
1277
1270
|
business_connection_id: str | None = None,
|
|
1278
1271
|
message_thread_id: int | None = None,
|
|
1272
|
+
question_parse_mode: str | None = None,
|
|
1273
|
+
question_entities: list[MessageEntity] | None = None,
|
|
1279
1274
|
is_anonymous: bool | None = None,
|
|
1280
1275
|
type: typing.Literal["quiz", "regular"] | None = None,
|
|
1281
1276
|
allows_multiple_answers: bool | None = None,
|
|
@@ -1313,8 +1308,13 @@ class APIMethods:
|
|
|
1313
1308
|
|
|
1314
1309
|
:param question: Poll question, 1-300 characters.
|
|
1315
1310
|
|
|
1316
|
-
:param
|
|
1317
|
-
|
|
1311
|
+
:param question_parse_mode: Mode for parsing entities in the question. See formatting options for more \
|
|
1312
|
+
details. Currently, only custom emoji entities are allowed.
|
|
1313
|
+
|
|
1314
|
+
:param question_entities: A JSON-serialized list of special entities that appear in the poll question. \
|
|
1315
|
+
It can be specified instead of question_parse_mode.
|
|
1316
|
+
|
|
1317
|
+
:param options: A JSON-serialized list of 2-10 answer options.
|
|
1318
1318
|
|
|
1319
1319
|
:param is_anonymous: True, if the poll needs to be anonymous, defaults to True.
|
|
1320
1320
|
|
|
@@ -1333,8 +1333,8 @@ class APIMethods:
|
|
|
1333
1333
|
:param explanation_parse_mode: Mode for parsing entities in the explanation. See formatting options for \
|
|
1334
1334
|
more details.
|
|
1335
1335
|
|
|
1336
|
-
:param explanation_entities: A JSON-serialized list of special entities that appear in the poll explanation
|
|
1337
|
-
|
|
1336
|
+
:param explanation_entities: A JSON-serialized list of special entities that appear in the poll explanation. \
|
|
1337
|
+
It can be specified instead of explanation_parse_mode.
|
|
1338
1338
|
|
|
1339
1339
|
:param open_period: Amount of time in seconds the poll will be active after creation, 5-600. \
|
|
1340
1340
|
Can't be used together with close_date.
|
|
@@ -1354,8 +1354,7 @@ class APIMethods:
|
|
|
1354
1354
|
|
|
1355
1355
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1356
1356
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1357
|
-
or to force a reply from the user.
|
|
1358
|
-
of a business account.
|
|
1357
|
+
or to force a reply from the user.
|
|
1359
1358
|
"""
|
|
1360
1359
|
|
|
1361
1360
|
method_response = await self.api.request_raw(
|
|
@@ -1408,8 +1407,7 @@ class APIMethods:
|
|
|
1408
1407
|
|
|
1409
1408
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
1410
1409
|
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
1411
|
-
or to force a reply from the user.
|
|
1412
|
-
of a business account.
|
|
1410
|
+
or to force a reply from the user.
|
|
1413
1411
|
"""
|
|
1414
1412
|
|
|
1415
1413
|
method_response = await self.api.request_raw(
|
|
@@ -1707,7 +1705,8 @@ class APIMethods:
|
|
|
1707
1705
|
|
|
1708
1706
|
:param can_post_stories: Pass True if the administrator can post stories to the chat.
|
|
1709
1707
|
|
|
1710
|
-
:param can_edit_stories: Pass True if the administrator can edit stories posted by other users
|
|
1708
|
+
:param can_edit_stories: Pass True if the administrator can edit stories posted by other users, post \
|
|
1709
|
+
stories to the chat page, pin chat stories, and access the chat's story archive. \
|
|
1711
1710
|
|
|
1712
1711
|
:param can_delete_stories: Pass True if the administrator can delete stories posted by other users. \
|
|
1713
1712
|
|
|
@@ -2208,11 +2207,11 @@ class APIMethods:
|
|
|
2208
2207
|
self,
|
|
2209
2208
|
chat_id: int | str,
|
|
2210
2209
|
**other: typing.Any,
|
|
2211
|
-
) -> Result[
|
|
2210
|
+
) -> Result[ChatFullInfo, APIError]:
|
|
2212
2211
|
"""Method `getChat`, see the [documentation](https://core.telegram.org/bots/api#getchat)
|
|
2213
2212
|
|
|
2214
|
-
Use this method to get up
|
|
2215
|
-
object on success.
|
|
2213
|
+
Use this method to get up-to-date information about the chat. Returns a
|
|
2214
|
+
ChatFullInfo object on success.
|
|
2216
2215
|
|
|
2217
2216
|
:param chat_id: Unique identifier for the target chat or username of the target supergroup \
|
|
2218
2217
|
or channel (in the format @channelusername).
|
|
@@ -2222,7 +2221,7 @@ class APIMethods:
|
|
|
2222
2221
|
"getChat",
|
|
2223
2222
|
get_params(locals()),
|
|
2224
2223
|
)
|
|
2225
|
-
return full_result(method_response,
|
|
2224
|
+
return full_result(method_response, ChatFullInfo)
|
|
2226
2225
|
|
|
2227
2226
|
async def get_chat_administrators(
|
|
2228
2227
|
self,
|
|
@@ -3216,6 +3215,7 @@ class APIMethods:
|
|
|
3216
3215
|
chat_id: int | str | None = None,
|
|
3217
3216
|
message_id: int | None = None,
|
|
3218
3217
|
inline_message_id: str | None = None,
|
|
3218
|
+
live_period: int | None = None,
|
|
3219
3219
|
horizontal_accuracy: float | None = None,
|
|
3220
3220
|
heading: int | None = None,
|
|
3221
3221
|
proximity_alert_radius: int | None = None,
|
|
@@ -3242,6 +3242,13 @@ class APIMethods:
|
|
|
3242
3242
|
|
|
3243
3243
|
:param longitude: Longitude of new location.
|
|
3244
3244
|
|
|
3245
|
+
:param live_period: New period in seconds during which the location can be updated, starting \
|
|
3246
|
+
from the message send date. If 0x7FFFFFFF is specified, then the location \
|
|
3247
|
+
can be updated forever. Otherwise, the new value must not exceed the current \
|
|
3248
|
+
live_period by more than a day, and the live location expiration date must \
|
|
3249
|
+
remain within the next 90 days. If not specified, then live_period remains \
|
|
3250
|
+
unchanged.
|
|
3251
|
+
|
|
3245
3252
|
:param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500. \
|
|
3246
3253
|
|
|
3247
3254
|
:param heading: Direction in which the user is moving, in degrees. Must be between 1 and 360 \
|
|
@@ -3455,9 +3462,8 @@ class APIMethods:
|
|
|
3455
3462
|
:param reply_parameters: Description of the message to reply to.
|
|
3456
3463
|
|
|
3457
3464
|
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
3458
|
-
keyboard, custom reply keyboard, instructions to remove reply keyboard \
|
|
3459
|
-
or to force a reply from the user.
|
|
3460
|
-
of a business account.
|
|
3465
|
+
keyboard, custom reply keyboard, instructions to remove a reply keyboard \
|
|
3466
|
+
or to force a reply from the user.
|
|
3461
3467
|
"""
|
|
3462
3468
|
|
|
3463
3469
|
method_response = await self.api.request_raw(
|
|
@@ -4246,7 +4252,6 @@ class APIMethods:
|
|
|
4246
4252
|
|
|
4247
4253
|
:param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' \
|
|
4248
4254
|
button will be shown. If not empty, the first button must launch the game. \
|
|
4249
|
-
Not supported for messages sent on behalf of a business account.
|
|
4250
4255
|
"""
|
|
4251
4256
|
|
|
4252
4257
|
method_response = await self.api.request_raw(
|