Update stats, fix some text input flows to working with delete middleware

This commit is contained in:
hteppl
2025-01-15 14:29:33 +03:00
parent 5884e0c213
commit b2f793fa70
4 changed files with 34 additions and 35 deletions
+2 -21
View File
@@ -18,13 +18,6 @@ pass_callbacks = [
AdminUserEditorCallback,
]
pass_states = [
"UserEditorState",
"AdminServersEditor",
"AdminSender",
"AdminCouponsState"
]
class DeleteMessageMiddleware(BaseMiddleware):
async def __call__(
@@ -35,9 +28,8 @@ class DeleteMessageMiddleware(BaseMiddleware):
) -> Any:
if isinstance(event, Message):
if (
not event.text or
not event.text.startswith("/start") or
not self._check_user_state(event)
not event.text
or not event.text.startswith("/start")
):
try:
await event.bot.delete_message(
@@ -55,17 +47,6 @@ class DeleteMessageMiddleware(BaseMiddleware):
return await handler(event, data)
@staticmethod
async def _check_user_state(event: CallbackQuery) -> bool:
from bot import dp
context = dp.fsm.get_context(
bot=event.bot,
user_id=event.from_user.id,
chat_id=event.chat.id
)
state = await context.get_state()
return state.split(":")[0] in pass_states
@staticmethod
async def _check_callbacks(event: CallbackQuery) -> bool:
for callback in pass_callbacks: