telegrinder 0.2.0.post2__tar.gz → 0.2.1__tar.gz
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-0.2.0.post2 → telegrinder-0.2.1}/PKG-INFO +1 -1
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/pyproject.toml +1 -1
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/__init__.py +8 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/machine.py +17 -5
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/middleware.py +0 -2
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/__init__.py +3 -0
- telegrinder-0.2.1/telegrinder/bot/rules/state.py +34 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/__init__.py +4 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/keyboard.py +1 -6
- telegrinder-0.2.1/telegrinder/tools/state_storage/__init__.py +4 -0
- telegrinder-0.2.1/telegrinder/tools/state_storage/abc.py +33 -0
- telegrinder-0.2.1/telegrinder/tools/state_storage/memory.py +22 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/types/methods.py +2 -2
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/types/objects.py +10 -1
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/LICENSE +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/readme.md +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/api/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/api/api.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/api/error.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/api/response.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/api/token.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/bot.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/base.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/callback_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/chat_join_request.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/chat_member_updated.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/inline_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/message.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/update.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/utils.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/context.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/dispatch.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/handler/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/handler/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/handler/func.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/handler/message_reply.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/middleware/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/middleware/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/process.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/message.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/box.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/callback_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/chat_join_request.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/chat_member.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/inline_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/message.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/raw.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/short_state.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/polling/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/polling/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/polling/polling.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/errors.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/event.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/node.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/adapter/raw_update.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/callback_data.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/chat_join.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/command.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/enum_text.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/func.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/fuzzy.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/inline.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/integer.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/is_from.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/markup.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/mention.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/message.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/message_entities.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/node.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/regex.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/rule_enum.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/start.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/text.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/rules/update.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/scenario/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/scenario/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/scenario/checkbox.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/scenario/choice.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/client/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/client/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/client/aiohttp.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/model.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/modules.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/msgspec_json.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/msgspec_utils.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/attachment.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/base.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/callback_query.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/command.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/composer.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/container.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/event.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/me.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/message.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/polymorphic.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/rule.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/scope.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/source.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/text.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/tools/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/tools/generator.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/node/update.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/py.typed +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/rules.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/buttons.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/error_handler/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/error_handler/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/error_handler/error.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/error_handler/error_handler.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/formatting/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/formatting/html.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/formatting/links.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/formatting/spec_html_formats.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/global_context.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/telegrinder_ctx.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/i18n/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/i18n/base.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/i18n/middleware/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/i18n/middleware/base.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/i18n/simple.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/kb_set/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/kb_set/base.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/kb_set/yaml.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/limited_dict.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/loop_wrapper/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/loop_wrapper/abc.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/loop_wrapper/loop_wrapper.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/magic.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/parse_mode.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/types/__init__.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/types/enums.py +0 -0
- {telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/verification_utils.py +0 -0
|
@@ -79,6 +79,7 @@ from .bot import (
|
|
|
79
79
|
WaiterMachine,
|
|
80
80
|
register_manager,
|
|
81
81
|
)
|
|
82
|
+
from .bot.rules import StateMeta
|
|
82
83
|
from .client import ABCClient, AiohttpClient
|
|
83
84
|
from .model import Model
|
|
84
85
|
from .modules import logger
|
|
@@ -86,6 +87,7 @@ from .tools import (
|
|
|
86
87
|
ABCErrorHandler,
|
|
87
88
|
ABCGlobalContext,
|
|
88
89
|
ABCLoopWrapper,
|
|
90
|
+
ABCStateStorage,
|
|
89
91
|
ABCTranslator,
|
|
90
92
|
ABCTranslatorMiddleware,
|
|
91
93
|
AnyMarkup,
|
|
@@ -104,10 +106,12 @@ from .tools import (
|
|
|
104
106
|
KeyboardSetYAML,
|
|
105
107
|
Lifespan,
|
|
106
108
|
LoopWrapper,
|
|
109
|
+
MemoryStateStorage,
|
|
107
110
|
ParseMode,
|
|
108
111
|
RowButtons,
|
|
109
112
|
SimpleI18n,
|
|
110
113
|
SimpleTranslator,
|
|
114
|
+
StateData,
|
|
111
115
|
ctx_var,
|
|
112
116
|
magic_bundle,
|
|
113
117
|
)
|
|
@@ -207,4 +211,8 @@ __all__ = (
|
|
|
207
211
|
"logger",
|
|
208
212
|
"magic_bundle",
|
|
209
213
|
"register_manager",
|
|
214
|
+
"ABCStateStorage",
|
|
215
|
+
"MemoryStateStorage",
|
|
216
|
+
"StateData",
|
|
217
|
+
"StateMeta",
|
|
210
218
|
)
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/machine.py
RENAMED
|
@@ -45,13 +45,13 @@ class WaiterMachine:
|
|
|
45
45
|
|
|
46
46
|
async def drop(
|
|
47
47
|
self,
|
|
48
|
-
state_view: "ABCStateView[EventModel]",
|
|
48
|
+
state_view: "ABCStateView[EventModel] | str",
|
|
49
49
|
id: Identificator,
|
|
50
50
|
event: EventModel,
|
|
51
51
|
update: Update,
|
|
52
52
|
**context: typing.Any,
|
|
53
53
|
) -> None:
|
|
54
|
-
view_name = state_view.__class__.__name__
|
|
54
|
+
view_name = state_view if isinstance(state_view, str) else state_view.__class__.__name__
|
|
55
55
|
if view_name not in self.storage:
|
|
56
56
|
raise LookupError("No record of view {!r} found.".format(view_name))
|
|
57
57
|
|
|
@@ -61,13 +61,26 @@ class WaiterMachine:
|
|
|
61
61
|
|
|
62
62
|
short_state.cancel()
|
|
63
63
|
await self.call_behaviour(
|
|
64
|
-
state_view,
|
|
65
64
|
event,
|
|
66
65
|
update,
|
|
67
66
|
behaviour=short_state.on_drop_behaviour,
|
|
68
67
|
**context,
|
|
69
68
|
)
|
|
70
69
|
|
|
70
|
+
async def drop_all(self) -> None:
|
|
71
|
+
"""Drops all waiters in storage"""
|
|
72
|
+
for view_name in self.storage:
|
|
73
|
+
for ident, short_state in self.storage[view_name].items():
|
|
74
|
+
if short_state.context:
|
|
75
|
+
await self.drop(
|
|
76
|
+
view_name,
|
|
77
|
+
ident,
|
|
78
|
+
short_state.context.event,
|
|
79
|
+
short_state.context.context.raw_update
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
short_state.cancel()
|
|
83
|
+
|
|
71
84
|
async def wait(
|
|
72
85
|
self,
|
|
73
86
|
state_view: "BaseStateView[EventModel]",
|
|
@@ -114,7 +127,6 @@ class WaiterMachine:
|
|
|
114
127
|
|
|
115
128
|
async def call_behaviour(
|
|
116
129
|
self,
|
|
117
|
-
view: "ABCStateView[EventModel]",
|
|
118
130
|
event: EventModel,
|
|
119
131
|
update: Update,
|
|
120
132
|
behaviour: Behaviour[EventModel] | None = None,
|
|
@@ -147,7 +159,7 @@ class WaiterMachine:
|
|
|
147
159
|
now = datetime.datetime.now()
|
|
148
160
|
for ident, short_state in self.storage.get(view_name, {}).copy().items():
|
|
149
161
|
if short_state.expiration_date is not None and now > short_state.expiration_date:
|
|
150
|
-
assert short_state.context
|
|
162
|
+
assert short_state.context # FIXME: why???
|
|
151
163
|
await self.drop(
|
|
152
164
|
view,
|
|
153
165
|
ident,
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/middleware.py
RENAMED
|
@@ -59,7 +59,6 @@ class WaiterMiddleware(ABCMiddleware[EventType]):
|
|
|
59
59
|
|
|
60
60
|
# before running the handler we check if the user wants to exit waiting
|
|
61
61
|
if short_state.exit_behaviour is not None and await self.machine.call_behaviour(
|
|
62
|
-
self.view,
|
|
63
62
|
event,
|
|
64
63
|
ctx.raw_update,
|
|
65
64
|
behaviour=short_state.exit_behaviour,
|
|
@@ -87,7 +86,6 @@ class WaiterMiddleware(ABCMiddleware[EventType]):
|
|
|
87
86
|
|
|
88
87
|
elif short_state.default_behaviour is not None:
|
|
89
88
|
await self.machine.call_behaviour(
|
|
90
|
-
self.view,
|
|
91
89
|
event,
|
|
92
90
|
ctx.raw_update,
|
|
93
91
|
behaviour=short_state.default_behaviour,
|
|
@@ -53,6 +53,7 @@ from telegrinder.bot.rules.node import NodeRule
|
|
|
53
53
|
from telegrinder.bot.rules.regex import Regex
|
|
54
54
|
from telegrinder.bot.rules.rule_enum import RuleEnum
|
|
55
55
|
from telegrinder.bot.rules.start import StartCommand
|
|
56
|
+
from telegrinder.bot.rules.state import State, StateMeta
|
|
56
57
|
from telegrinder.bot.rules.text import HasText, Text
|
|
57
58
|
from telegrinder.bot.rules.update import IsUpdateType
|
|
58
59
|
|
|
@@ -113,4 +114,6 @@ __all__ = (
|
|
|
113
114
|
"StartCommand",
|
|
114
115
|
"Text",
|
|
115
116
|
"NodeRule",
|
|
117
|
+
"State",
|
|
118
|
+
"StateMeta",
|
|
116
119
|
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from telegrinder.bot.dispatch.context import Context
|
|
5
|
+
from telegrinder.bot.rules.abc import ABCRule
|
|
6
|
+
from telegrinder.node import Source
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from telegrinder.tools.state_storage import ABCStateStorage
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StateMeta(enum.Enum):
|
|
13
|
+
NO_STATE = enum.auto()
|
|
14
|
+
ANY = enum.auto()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class State(ABCRule):
|
|
18
|
+
def __init__(self, storage: "ABCStateStorage", key: str | StateMeta = StateMeta.ANY):
|
|
19
|
+
self.storage = storage
|
|
20
|
+
self.key = key
|
|
21
|
+
|
|
22
|
+
async def check(self, source: Source, ctx: Context) -> bool:
|
|
23
|
+
state = await self.storage.get(source.from_user.id)
|
|
24
|
+
if not state:
|
|
25
|
+
return self.key == StateMeta.NO_STATE
|
|
26
|
+
|
|
27
|
+
if self.key != StateMeta.ANY and self.key != state.unwrap().key:
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
ctx["state"] = state.unwrap()
|
|
31
|
+
return True
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = ("State", "StateMeta")
|
|
@@ -67,6 +67,7 @@ from .limited_dict import LimitedDict
|
|
|
67
67
|
from .loop_wrapper import ABCLoopWrapper, DelayedTask, Lifespan, LoopWrapper
|
|
68
68
|
from .magic import impl, magic_bundle, resolve_arg_names
|
|
69
69
|
from .parse_mode import ParseMode
|
|
70
|
+
from .state_storage import ABCStateStorage, MemoryStateStorage, StateData
|
|
70
71
|
|
|
71
72
|
__all__ = (
|
|
72
73
|
"ABCErrorHandler",
|
|
@@ -139,4 +140,7 @@ __all__ = (
|
|
|
139
140
|
"block_quote",
|
|
140
141
|
"impl",
|
|
141
142
|
"resolve_arg_names",
|
|
143
|
+
"ABCStateStorage",
|
|
144
|
+
"MemoryStateStorage",
|
|
145
|
+
"StateData",
|
|
142
146
|
)
|
|
@@ -26,11 +26,6 @@ class KeyboardModel:
|
|
|
26
26
|
keyboard: list[list[DictStrAny]]
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
def copy_keyboard(keyboard: list[list[DictStrAny]]) -> list[list[DictStrAny]]:
|
|
31
|
-
return [row.copy() for row in keyboard]
|
|
32
|
-
|
|
33
|
-
|
|
34
29
|
class ABCMarkup(ABC, typing.Generic[ButtonT]):
|
|
35
30
|
BUTTON: type[ButtonT]
|
|
36
31
|
keyboard: list[list[DictStrAny]]
|
|
@@ -78,7 +73,7 @@ class ABCMarkup(ABC, typing.Generic[ButtonT]):
|
|
|
78
73
|
return copy_keyboard
|
|
79
74
|
|
|
80
75
|
def merge(self, other: typing.Self) -> typing.Self:
|
|
81
|
-
self.keyboard.extend(
|
|
76
|
+
self.keyboard.extend(other.keyboard)
|
|
82
77
|
return self
|
|
83
78
|
|
|
84
79
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import typing
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from fntypes import Option
|
|
6
|
+
|
|
7
|
+
from telegrinder.bot.rules.state import State, StateMeta
|
|
8
|
+
|
|
9
|
+
Payload = typing.TypeVar("Payload")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class StateData(typing.Generic[Payload]):
|
|
14
|
+
key: str
|
|
15
|
+
payload: Payload
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ABCStateStorage(abc.ABC, typing.Generic[Payload]):
|
|
19
|
+
@abc.abstractmethod
|
|
20
|
+
async def get(self, user_id: int) -> Option[StateData[Payload]]:
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
@abc.abstractmethod
|
|
24
|
+
async def delete(self, user_id: int) -> None:
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
@abc.abstractmethod
|
|
28
|
+
async def set(self, user_id: int, key: str, payload: Payload) -> None:
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
def State(self, key: str | StateMeta = StateMeta.ANY) -> State: # noqa: N802
|
|
32
|
+
"""Can be used as a shortcut to get a state rule dependant on current storage"""
|
|
33
|
+
return State(storage=self, key=key)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fntypes import Nothing, Option, Some
|
|
4
|
+
|
|
5
|
+
from .abc import ABCStateStorage, StateData
|
|
6
|
+
|
|
7
|
+
Payload = dict[str, typing.Any]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MemoryStateStorage(ABCStateStorage[Payload]):
|
|
11
|
+
def __init__(self):
|
|
12
|
+
self.storage: dict[int, StateData[Payload]] = {}
|
|
13
|
+
|
|
14
|
+
async def get(self, user_id: int) -> Option[StateData[Payload]]:
|
|
15
|
+
state = self.storage.get(user_id)
|
|
16
|
+
return Some(state) if state is not None else Nothing()
|
|
17
|
+
|
|
18
|
+
async def set(self, user_id: int, key: str, payload: Payload) -> None:
|
|
19
|
+
self.storage[user_id] = StateData(key, payload)
|
|
20
|
+
|
|
21
|
+
async def delete(self, user_id: int) -> None:
|
|
22
|
+
self.storage.pop(user_id)
|
|
@@ -4178,7 +4178,7 @@ class APIMethods:
|
|
|
4178
4178
|
:param description: Product description, 1-255 characters.
|
|
4179
4179
|
|
|
4180
4180
|
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to \
|
|
4181
|
-
the user, use for your internal processes.
|
|
4181
|
+
the user, use it for your internal processes.
|
|
4182
4182
|
|
|
4183
4183
|
:param provider_token: Payment provider token, obtained via @BotFather. Pass an empty string \
|
|
4184
4184
|
for payments in Telegram Stars.
|
|
@@ -4296,7 +4296,7 @@ class APIMethods:
|
|
|
4296
4296
|
:param description: Product description, 1-255 characters.
|
|
4297
4297
|
|
|
4298
4298
|
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to \
|
|
4299
|
-
the user, use for your internal processes.
|
|
4299
|
+
the user, use it for your internal processes.
|
|
4300
4300
|
|
|
4301
4301
|
:param provider_token: Payment provider token, obtained via @BotFather. Pass an empty string \
|
|
4302
4302
|
for payments in Telegram Stars.
|
|
@@ -2795,6 +2795,15 @@ class ChatInviteLink(Model):
|
|
|
2795
2795
|
pending_join_request_count: Option[int] = Nothing
|
|
2796
2796
|
"""Optional. Number of pending join requests created using this link."""
|
|
2797
2797
|
|
|
2798
|
+
subscription_period: Option[int] = Nothing
|
|
2799
|
+
"""Optional. The number of seconds the subscription will be active for before
|
|
2800
|
+
the next payment."""
|
|
2801
|
+
|
|
2802
|
+
subscription_price: Option[int] = Nothing
|
|
2803
|
+
"""Optional. The amount of Telegram Stars a user must pay initially and after
|
|
2804
|
+
each subsequent subscription period to be a member of the chat using the
|
|
2805
|
+
link."""
|
|
2806
|
+
|
|
2798
2807
|
|
|
2799
2808
|
class ChatAdministratorRights(Model):
|
|
2800
2809
|
"""Object `ChatAdministratorRights`, see the [documentation](https://core.telegram.org/bots/api#chatadministratorrights).
|
|
@@ -5393,7 +5402,7 @@ class InputInvoiceMessageContent(InputMessageContent):
|
|
|
5393
5402
|
|
|
5394
5403
|
payload: str
|
|
5395
5404
|
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
|
|
5396
|
-
the user, use for your internal processes."""
|
|
5405
|
+
the user, use it for your internal processes."""
|
|
5397
5406
|
|
|
5398
5407
|
currency: Currency
|
|
5399
5408
|
"""Three-letter ISO 4217 currency code, see more on currencies. Pass `XTR`
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/chat_join_request.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/cute_types/chat_member_updated.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/handler/message_reply.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/middleware/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/__init__.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/abc.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/return_manager/message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/callback_query.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/view/chat_join_request.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/__init__.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/bot/dispatch/waiter_machine/short_state.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/error_handler/error_handler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/formatting/spec_html_formats.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/global_context.py
RENAMED
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/global_context/telegrinder_ctx.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegrinder-0.2.0.post2 → telegrinder-0.2.1}/telegrinder/tools/loop_wrapper/loop_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|