36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from bot.Handler import Handler
|
|
from bot import SET_DATE_STEP, SET_TABLE_STEP, REQUEST_CODE_STEP, FIRST, AUTH_FINISH, config
|
|
from bot.keyboards.DateToBookingKeyboard import DateToBookingKeyboard
|
|
from bot.keyboards.FirstStepKeyboard import FirstStepKeyboard
|
|
from bot.keyboards.GetTableListKeyboard import GetTableListKeyboard
|
|
from itguild_api import client
|
|
from bot.DaMsg import DaMsg
|
|
|
|
|
|
class AuthHandler(Handler):
|
|
|
|
@staticmethod
|
|
async def request_code(update, context):
|
|
await context.bot.send_message(chat_id=update.effective_chat.id, text="Введите код:")
|
|
|
|
return REQUEST_CODE_STEP
|
|
|
|
@staticmethod
|
|
async def add_user_at_dialog(update, context):
|
|
msg = DaMsg(update.effective_message)
|
|
|
|
user = client.tgBot.get_user({'token': msg.text})
|
|
|
|
if "error" in user:
|
|
reply_markup = FirstStepKeyboard()
|
|
await context.bot.send_message(chat_id=update.effective_chat.id,
|
|
text="Пользователь не найден. Проверте верность введенного кода.",
|
|
reply_markup=reply_markup.create_keyboard())
|
|
else:
|
|
dialog = client.tgBot.set_user_at_dialog({'dialog_id': update.effective_chat.id, 'user_id': user['id']})
|
|
await context.bot.send_message(chat_id=update.effective_chat.id,
|
|
text="Авторизация прошла успешно.")
|
|
|
|
print(user)
|
|
return FIRST
|