1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00
Files
AdministrationItDepartmens/venv/Lib/site-packages/aiogram/handlers/message.py
MoonTestUse1 e81df4c87e Initial commit
2024-12-23 19:27:44 +06:00

29 lines
721 B
Python

from abc import ABC
from typing import Optional, cast
from aiogram.filters import CommandObject
from aiogram.handlers.base import BaseHandler, BaseHandlerMixin
from aiogram.types import Chat, Message, User
class MessageHandler(BaseHandler[Message], ABC):
"""
Base class for message handlers
"""
@property
def from_user(self) -> Optional[User]:
return self.event.from_user
@property
def chat(self) -> Chat:
return self.event.chat
class MessageHandlerCommandMixin(BaseHandlerMixin[Message]):
@property
def command(self) -> Optional[CommandObject]:
if "command" in self.data:
return cast(CommandObject, self.data["command"])
return None