telegrinder 0.1.dev161__py3-none-any.whl → 0.1.dev163__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/api/api.py +4 -2
- telegrinder/api/error.py +3 -3
- telegrinder/bot/bot.py +8 -12
- telegrinder/bot/cute_types/base.py +1 -4
- telegrinder/bot/cute_types/message.py +140 -0
- telegrinder/bot/dispatch/composition.py +1 -1
- telegrinder/bot/dispatch/dispatch.py +3 -4
- telegrinder/bot/dispatch/view/box.py +6 -6
- telegrinder/bot/dispatch/waiter_machine/short_state.py +1 -1
- telegrinder/bot/rules/__init__.py +4 -0
- telegrinder/bot/rules/is_from.py +18 -3
- telegrinder/bot/scenario/checkbox.py +3 -4
- telegrinder/client/aiohttp.py +1 -2
- telegrinder/modules.py +5 -3
- telegrinder/msgspec_json.py +3 -3
- telegrinder/msgspec_utils.py +80 -38
- telegrinder/node/source.py +2 -3
- telegrinder/tools/__init__.py +6 -0
- telegrinder/tools/buttons.py +8 -13
- telegrinder/tools/error_handler/error_handler.py +2 -2
- telegrinder/tools/formatting/__init__.py +6 -0
- telegrinder/tools/formatting/html.py +10 -0
- telegrinder/tools/formatting/links.py +7 -0
- telegrinder/tools/formatting/spec_html_formats.py +27 -15
- telegrinder/tools/global_context/global_context.py +7 -5
- telegrinder/tools/keyboard.py +3 -3
- telegrinder/tools/loop_wrapper/abc.py +4 -4
- telegrinder/tools/magic.py +1 -1
- telegrinder/types/enums.py +4 -0
- telegrinder/types/methods.py +175 -41
- telegrinder/types/objects.py +442 -201
- {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/METADATA +1 -1
- {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/RECORD +35 -35
- {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/WHEEL +1 -1
- {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/LICENSE +0 -0
|
@@ -5,14 +5,16 @@ from telegrinder.types.enums import ProgrammingLanguage
|
|
|
5
5
|
|
|
6
6
|
SpecialFormat = typing.Union[
|
|
7
7
|
"ChannelBoostLink",
|
|
8
|
-
"
|
|
8
|
+
"InviteChatLink",
|
|
9
9
|
"Link",
|
|
10
|
+
"Mention",
|
|
10
11
|
"PreCode",
|
|
11
|
-
"
|
|
12
|
+
"ResolveDomain",
|
|
13
|
+
"SpecialFormat",
|
|
12
14
|
"StartBotLink",
|
|
13
15
|
"StartGroupLink",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
+
"TgEmoji",
|
|
17
|
+
"UserOpenMessage",
|
|
16
18
|
]
|
|
17
19
|
|
|
18
20
|
|
|
@@ -26,13 +28,13 @@ def is_spec_format(obj: typing.Any) -> typing.TypeGuard[SpecialFormat]:
|
|
|
26
28
|
|
|
27
29
|
@dataclasses.dataclass(repr=False)
|
|
28
30
|
class BaseSpecFormat:
|
|
29
|
-
__formatter_name__: typing.ClassVar[str]
|
|
31
|
+
__formatter_name__: typing.ClassVar[str] = dataclasses.field(init=False, repr=False)
|
|
30
32
|
|
|
31
33
|
def __repr__(self) -> str:
|
|
32
|
-
return f"<{self.__class__.__name__!r}
|
|
34
|
+
return f"<Special formatter {self.__class__.__name__!r} -> {self.__formatter_name__!r}>"
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
@dataclasses.dataclass
|
|
37
|
+
@dataclasses.dataclass(repr=False)
|
|
36
38
|
class ChannelBoostLink(BaseSpecFormat):
|
|
37
39
|
__formatter_name__ = "channel_boost_link"
|
|
38
40
|
|
|
@@ -40,7 +42,7 @@ class ChannelBoostLink(BaseSpecFormat):
|
|
|
40
42
|
string: str | None = None
|
|
41
43
|
|
|
42
44
|
|
|
43
|
-
@dataclasses.dataclass
|
|
45
|
+
@dataclasses.dataclass(repr=False)
|
|
44
46
|
class InviteChatLink(BaseSpecFormat):
|
|
45
47
|
__formatter_name__ = "invite_chat_link"
|
|
46
48
|
|
|
@@ -48,7 +50,7 @@ class InviteChatLink(BaseSpecFormat):
|
|
|
48
50
|
string: str | None = None
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
@dataclasses.dataclass
|
|
53
|
+
@dataclasses.dataclass(repr=False)
|
|
52
54
|
class Mention(BaseSpecFormat):
|
|
53
55
|
__formatter_name__ = "mention"
|
|
54
56
|
|
|
@@ -56,7 +58,7 @@ class Mention(BaseSpecFormat):
|
|
|
56
58
|
user_id: int
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
@dataclasses.dataclass
|
|
61
|
+
@dataclasses.dataclass(repr=False)
|
|
60
62
|
class Link(BaseSpecFormat):
|
|
61
63
|
__formatter_name__ = "link"
|
|
62
64
|
|
|
@@ -64,7 +66,7 @@ class Link(BaseSpecFormat):
|
|
|
64
66
|
string: str | None = None
|
|
65
67
|
|
|
66
68
|
|
|
67
|
-
@dataclasses.dataclass
|
|
69
|
+
@dataclasses.dataclass(repr=False)
|
|
68
70
|
class PreCode(BaseSpecFormat):
|
|
69
71
|
__formatter_name__ = "pre_code"
|
|
70
72
|
|
|
@@ -72,7 +74,7 @@ class PreCode(BaseSpecFormat):
|
|
|
72
74
|
lang: str | ProgrammingLanguage | None = None
|
|
73
75
|
|
|
74
76
|
|
|
75
|
-
@dataclasses.dataclass
|
|
77
|
+
@dataclasses.dataclass(repr=False)
|
|
76
78
|
class TgEmoji(BaseSpecFormat):
|
|
77
79
|
__formatter_name__ = "tg_emoji"
|
|
78
80
|
|
|
@@ -80,7 +82,7 @@ class TgEmoji(BaseSpecFormat):
|
|
|
80
82
|
emoji_id: int
|
|
81
83
|
|
|
82
84
|
|
|
83
|
-
@dataclasses.dataclass
|
|
85
|
+
@dataclasses.dataclass(repr=False)
|
|
84
86
|
class StartBotLink(BaseSpecFormat):
|
|
85
87
|
__formatter_name__ = "start_bot_link"
|
|
86
88
|
|
|
@@ -89,7 +91,7 @@ class StartBotLink(BaseSpecFormat):
|
|
|
89
91
|
string: str | None
|
|
90
92
|
|
|
91
93
|
|
|
92
|
-
@dataclasses.dataclass
|
|
94
|
+
@dataclasses.dataclass(repr=False)
|
|
93
95
|
class StartGroupLink(BaseSpecFormat):
|
|
94
96
|
__formatter_name__ = "start_group_link"
|
|
95
97
|
|
|
@@ -98,7 +100,7 @@ class StartGroupLink(BaseSpecFormat):
|
|
|
98
100
|
string: str | None = None
|
|
99
101
|
|
|
100
102
|
|
|
101
|
-
@dataclasses.dataclass
|
|
103
|
+
@dataclasses.dataclass(repr=False)
|
|
102
104
|
class ResolveDomain(BaseSpecFormat):
|
|
103
105
|
__formatter_name__ = "resolve_domain"
|
|
104
106
|
|
|
@@ -106,6 +108,15 @@ class ResolveDomain(BaseSpecFormat):
|
|
|
106
108
|
string: str | None = None
|
|
107
109
|
|
|
108
110
|
|
|
111
|
+
@dataclasses.dataclass(repr=False)
|
|
112
|
+
class UserOpenMessage(BaseSpecFormat):
|
|
113
|
+
__formatter_name__ = "user_open_message"
|
|
114
|
+
|
|
115
|
+
user_id: int
|
|
116
|
+
message: str | None = None
|
|
117
|
+
string: str | None = None
|
|
118
|
+
|
|
119
|
+
|
|
109
120
|
__all__ = (
|
|
110
121
|
"BaseSpecFormat",
|
|
111
122
|
"ChannelBoostLink",
|
|
@@ -118,4 +129,5 @@ __all__ = (
|
|
|
118
129
|
"StartBotLink",
|
|
119
130
|
"StartGroupLink",
|
|
120
131
|
"TgEmoji",
|
|
132
|
+
"UserOpenMessage",
|
|
121
133
|
)
|
|
@@ -23,11 +23,13 @@ else:
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def type_check(value: object, value_type: type[T]) -> typing.TypeGuard[T]:
|
|
26
|
-
|
|
27
|
-
True
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
if value_type in (typing.Any, object):
|
|
27
|
+
return True
|
|
28
|
+
match msgspec_convert(value, value_type):
|
|
29
|
+
case Ok(v):
|
|
30
|
+
return type(value) is type(v)
|
|
31
|
+
case Error(_):
|
|
32
|
+
return False
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def is_dunder(name: str) -> bool:
|
telegrinder/tools/keyboard.py
CHANGED
|
@@ -91,9 +91,6 @@ class Keyboard(ABCMarkup[Button], KeyboardModel):
|
|
|
91
91
|
selective: bool = dataclasses.field(default=False)
|
|
92
92
|
is_persistent: bool = dataclasses.field(default=False)
|
|
93
93
|
|
|
94
|
-
def get_empty_markup(self, *, selective: bool = False) -> ReplyKeyboardRemove:
|
|
95
|
-
return ReplyKeyboardRemove(remove_keyboard=True, selective=selective) # type: ignore
|
|
96
|
-
|
|
97
94
|
def dict(self) -> DictStrAny:
|
|
98
95
|
self.keyboard = [row for row in self.keyboard if row]
|
|
99
96
|
return {
|
|
@@ -105,6 +102,9 @@ class Keyboard(ABCMarkup[Button], KeyboardModel):
|
|
|
105
102
|
def get_markup(self) -> ReplyKeyboardMarkup:
|
|
106
103
|
return ReplyKeyboardMarkup(**self.dict())
|
|
107
104
|
|
|
105
|
+
def get_empty_markup(self, *, selective: bool = False) -> ReplyKeyboardRemove:
|
|
106
|
+
return ReplyKeyboardRemove(remove_keyboard=True, selective=Some(selective))
|
|
107
|
+
|
|
108
108
|
|
|
109
109
|
class InlineKeyboard(ABCMarkup[InlineButton]):
|
|
110
110
|
BUTTON = InlineButton
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
3
|
|
|
4
|
-
CoroutineTask = typing.Coroutine[typing.Any, typing.Any, typing.Any]
|
|
5
|
-
CoroutineFunc = typing.Callable[..., CoroutineTask]
|
|
4
|
+
CoroutineTask: typing.TypeAlias = typing.Coroutine[typing.Any, typing.Any, typing.Any]
|
|
5
|
+
CoroutineFunc: typing.TypeAlias = typing.Callable[..., CoroutineTask]
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class ABCLoopWrapper(ABC):
|
|
9
9
|
@abstractmethod
|
|
10
10
|
def add_task(self, task: CoroutineFunc | CoroutineTask) -> None:
|
|
11
|
-
|
|
11
|
+
pass
|
|
12
12
|
|
|
13
13
|
@abstractmethod
|
|
14
14
|
def run_event_loop(self) -> None:
|
|
15
|
-
|
|
15
|
+
pass
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
__all__ = ("ABCLoopWrapper",)
|
telegrinder/tools/magic.py
CHANGED
|
@@ -9,7 +9,7 @@ if typing.TYPE_CHECKING:
|
|
|
9
9
|
T = typing.TypeVar("T", bound=ABCRule)
|
|
10
10
|
|
|
11
11
|
FuncType: typing.TypeAlias = types.FunctionType | typing.Callable[..., typing.Any]
|
|
12
|
-
TRANSLATIONS_KEY = "_translations"
|
|
12
|
+
TRANSLATIONS_KEY: typing.Final[str] = "_translations"
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def resolve_arg_names(func: FuncType, start_idx: int = 1) -> tuple[str, ...]:
|
telegrinder/types/enums.py
CHANGED
|
@@ -415,6 +415,10 @@ class UpdateType(str, enum.Enum):
|
|
|
415
415
|
CHAT_JOIN_REQUEST = "chat_join_request"
|
|
416
416
|
CHAT_BOOST = "chat_boost"
|
|
417
417
|
REMOVED_CHAT_BOOST = "removed_chat_boost"
|
|
418
|
+
BUSINESS_CONNECTION = "business_connection"
|
|
419
|
+
BUSINESS_MESSAGE = "business_message"
|
|
420
|
+
EDITED_BUSINESS_MESSAGE = "edited_business_message"
|
|
421
|
+
DELETE_BUSINESS_MESSAGE = "delete_business_messages"
|
|
418
422
|
|
|
419
423
|
|
|
420
424
|
class BotCommandScopeType(str, enum.Enum):
|