1
0
Fork 0

Add controller.py

This commit is contained in:
Trueold89 2024-09-04 19:41:01 +03:00
parent 3b7c9cacc7
commit 0c5ab590c4
1 changed files with 27 additions and 0 deletions

27
u232ping/controller.py Normal file
View File

@ -0,0 +1,27 @@
from u232ping.abc.db import DataBase
from u232ping.types import Group
from aiogram.types import Message
class Controller(object):
db: DataBase
def __init__(self, db_implementation: DataBase) -> None:
self.db = db_implementation
async def _ping(self, msg: Message, group: int | None = None) -> None:
gtp: Group
if group is None:
gtp = await self.db.get_all()
else:
gtp = await self.db.get_group(group)
msg.answer(str(gtp))
async def all(self, msg: Message) -> None:
await self._ping(msg)
async def first(self, msg: Message) -> None:
await self._ping(msg, 1)
async def second(self, msg: Message) -> None:
await self._ping(msg, 2)