This repository has been archived on 2022-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
it-volunteers-for-peace/handlers/commands.py

31 lines
1.1 KiB
Python
Raw Normal View History

2022-10-16 13:30:57 +00:00
from loguru import logger
2022-10-15 15:51:27 +00:00
from aiogram import types, Dispatcher
2022-10-16 19:50:37 +00:00
from keyboards.default import default_kb
from services.repositories import Repos, UserRepo
2022-10-16 13:30:57 +00:00
2022-10-15 15:51:27 +00:00
2022-10-16 19:50:37 +00:00
async def start(message: types.Message, repo: Repos):
user = await repo.get_repo(UserRepo).get(message.from_user.id)
2022-10-16 14:10:30 +00:00
if user is not None:
await message.answer(
"Добро пожаловать в Бота Теплицы Социальных Технологий "
2022-10-16 19:50:37 +00:00
"для организации антивоенных проектов.",
2022-10-17 10:58:17 +00:00
reply_markup=default_kb,
2022-10-16 14:10:30 +00:00
)
2022-10-16 19:50:37 +00:00
async def request_invite(message: types.Message, repo: Repos):
2022-10-17 10:58:17 +00:00
await repo.get_repo(UserRepo).add(message.from_user.id, message.chat.id)
2022-10-16 13:30:57 +00:00
logger.debug(f"Added new user {message.from_user.full_name}")
2022-10-15 15:51:27 +00:00
bot_info = await message.bot.get_me()
await message.reply(
2022-10-16 13:30:57 +00:00
f"Чтобы создать Ваш проект, перейдите в лс к боту @{bot_info.username}"
2022-10-15 15:51:27 +00:00
)
def register_command_handlers(dp: Dispatcher):
2022-10-16 14:10:30 +00:00
dp.register_message_handler(start, commands="start")
2022-10-16 13:30:57 +00:00
dp.register_message_handler(request_invite, commands="inviteme")