Add add_user method
This commit is contained in:
parent
77b949730e
commit
4730fb646b
|
@ -1,12 +1,18 @@
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
from aiogram import types, Dispatcher
|
from aiogram import types, Dispatcher
|
||||||
|
from services.repository import Repo
|
||||||
|
|
||||||
|
|
||||||
async def create_project(message: types.Message):
|
async def request_invite(message: types.Message, repo: Repo):
|
||||||
|
await repo.add_user(message.from_user.id, message.chat.id)
|
||||||
|
logger.debug(f"Added new user {message.from_user.full_name}")
|
||||||
|
|
||||||
bot_info = await message.bot.get_me()
|
bot_info = await message.bot.get_me()
|
||||||
await message.reply(
|
await message.reply(
|
||||||
f"Перейдите в лс к боту @{bot_info.username}"
|
f"Чтобы создать Ваш проект, перейдите в лс к боту @{bot_info.username}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def register_command_handlers(dp: Dispatcher):
|
def register_command_handlers(dp: Dispatcher):
|
||||||
dp.register_message_handler(create_project, commands="create_project")
|
dp.register_message_handler(request_invite, commands="inviteme")
|
||||||
|
|
|
@ -6,3 +6,10 @@ class Repo:
|
||||||
|
|
||||||
def __init__(self, conn: Connection):
|
def __init__(self, conn: Connection):
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
|
|
||||||
|
async def add_user(self, user_id: int, chat_id: int):
|
||||||
|
await self.conn.execute(
|
||||||
|
"INSERT INTO users (user_id, chat_id) "
|
||||||
|
"VALUES ($1, $2) ON CONFLICT (user_id) DO NOTHING",
|
||||||
|
user_id, chat_id
|
||||||
|
)
|
||||||
|
|
Reference in a new issue