:
This commit is contained in:
ollyhearn
2023-06-07 20:08:08 +03:00
parent 6962420e28
commit 7f78c79837
2 changed files with 24 additions and 13 deletions

View File

@ -36,19 +36,15 @@ class States(StatesGroup):
@bot.message_handler(commands=["start"])
async def start(msg: Message):
user = session.query(User).filter_by(id=msg.from_user.id).first()
if user:
await bot.send_message(chat_id=msg.chat.id, text="Вы зарегистрированы!")
else:
await bot.send_message(chat_id=msg.chat.id, text="Привет, новый пользователь, регистрирую тебя..")
new_user = User(id=msg.from_user.id, name=msg.from_user.first_name, username=msg.from_user.username)
session.add(new_user)
session.commit()
await bot.send_message(chat_id=msg.chat.id, text="Регистрация прошла успешно, добро пожаловать!")
# if msg.chat.type in ("group", "supergroup"):
# await bot.send_message(chat_id=msg.chat.id, text=textbook.start_group)
# else:
# await bot.send_message(chat_id=msg.chat.id, text=textbook.start)
if msg.chat.type == "private":
user = session.query(User).filter_by(id=msg.from_user.id).first()
if not user:
new_user = User(id=msg.from_user.id, name=msg.from_user.first_name, username=msg.from_user.username)
session.add(new_user)
session.commit()
await bot.send_message(chat_id=msg.chat.id, text=textbook.start)
await bot.set_state(user_id=msg.from_user.id, state=States.default)
await bot.send_message(chat_id=msg.chat.id, text=textbook.menu, reply_markup=keyboards.menu())
@bot.message_handler(commands=["new_queue"])
async def nq(msg: Message):

View File

@ -0,0 +1,15 @@
from telebot.types import InlineKeyboardButton as button, InlineKeyboardMarkup as keyboard
def menu():
return keyboard(
keyboard=[
[
button(text=" Новая очередь", callback_data="new")
],
[
button(text="📋 Мои очереди", callback_data="my")
],
[
button(text=" О боте", callback_data="about")
],
])