mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 21:49:42 +03:00
Refactoring: handlers now implemented as classes. Module structure
This commit is contained in:
26
handlers/message_handlers/handler.py
Normal file
26
handlers/message_handlers/handler.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Coroutine, Dict
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.filters import Filter
|
||||
|
||||
|
||||
class MessageHandlerABC(ABC):
|
||||
bot: Bot
|
||||
|
||||
def __init__(self, bot: Bot, *args: Any, **kwargs: Dict[str, Any]) -> None:
|
||||
assert isinstance(bot, Bot)
|
||||
self.bot = bot
|
||||
|
||||
@abstractmethod
|
||||
def _command(self, *args, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def handler(self) -> Coroutine[None, None, None]:
|
||||
return self._command
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def filter(self) -> Filter:
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user