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.

Files changed (35) hide show
  1. telegrinder/api/api.py +4 -2
  2. telegrinder/api/error.py +3 -3
  3. telegrinder/bot/bot.py +8 -12
  4. telegrinder/bot/cute_types/base.py +1 -4
  5. telegrinder/bot/cute_types/message.py +140 -0
  6. telegrinder/bot/dispatch/composition.py +1 -1
  7. telegrinder/bot/dispatch/dispatch.py +3 -4
  8. telegrinder/bot/dispatch/view/box.py +6 -6
  9. telegrinder/bot/dispatch/waiter_machine/short_state.py +1 -1
  10. telegrinder/bot/rules/__init__.py +4 -0
  11. telegrinder/bot/rules/is_from.py +18 -3
  12. telegrinder/bot/scenario/checkbox.py +3 -4
  13. telegrinder/client/aiohttp.py +1 -2
  14. telegrinder/modules.py +5 -3
  15. telegrinder/msgspec_json.py +3 -3
  16. telegrinder/msgspec_utils.py +80 -38
  17. telegrinder/node/source.py +2 -3
  18. telegrinder/tools/__init__.py +6 -0
  19. telegrinder/tools/buttons.py +8 -13
  20. telegrinder/tools/error_handler/error_handler.py +2 -2
  21. telegrinder/tools/formatting/__init__.py +6 -0
  22. telegrinder/tools/formatting/html.py +10 -0
  23. telegrinder/tools/formatting/links.py +7 -0
  24. telegrinder/tools/formatting/spec_html_formats.py +27 -15
  25. telegrinder/tools/global_context/global_context.py +7 -5
  26. telegrinder/tools/keyboard.py +3 -3
  27. telegrinder/tools/loop_wrapper/abc.py +4 -4
  28. telegrinder/tools/magic.py +1 -1
  29. telegrinder/types/enums.py +4 -0
  30. telegrinder/types/methods.py +175 -41
  31. telegrinder/types/objects.py +442 -201
  32. {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/METADATA +1 -1
  33. {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/RECORD +35 -35
  34. {telegrinder-0.1.dev161.dist-info → telegrinder-0.1.dev163.dist-info}/WHEEL +1 -1
  35. {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
- "Mention",
8
+ "InviteChatLink",
9
9
  "Link",
10
+ "Mention",
10
11
  "PreCode",
11
- "TgEmoji",
12
+ "ResolveDomain",
13
+ "SpecialFormat",
12
14
  "StartBotLink",
13
15
  "StartGroupLink",
14
- "ResolveDomain",
15
- "InviteChatLink",
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}: {self.__formatter_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
- return (
27
- True
28
- if value_type in (typing.Any, object)
29
- else bool(msgspec_convert(value, value_type))
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:
@@ -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",)
@@ -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, ...]:
@@ -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):