Exemplo n.º 1
0
def select_language(update, context):
    bot = context.bot

    text = update.message.text
    if "English" in text:
        lang = "eng"
    else:
        lang = "ru"

    context.user_data["language"] = lang
    bot.send_message(update.message.chat_id, translate("greeting", lang))
    menu(update, context)

    language_preference = DB('language_selection',
                             chat_id="TEXT",
                             language="TEXT")
    res = language_preference.get_items(chat_id=update.message.chat_id)
    if len(res) != 0 and res[0][1] != lang:
        language_preference.delete_item(chat_id=update.message.chat_id)
        res = []
    if len(res) == 0:
        language_preference.add_item(chat_id=update.message.chat_id,
                                     language=lang)

    return ConversationHandler.END
Exemplo n.º 2
0
def menu(update, context):
    bot = context.bot
    lang = extract_language_and_update_if_not_present(update, context)
    keyboard = [[KeyboardButton(f"🗺{translate('make_order', lang)}")],
                [KeyboardButton(f"🏃{translate('call_staff', lang)}")],
                [KeyboardButton(f"⭐{translate('leave_feedback', lang)}")]]
    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=False,
                                       resize_keyboard=True)

    bot.send_message(update.message.chat_id,
                     translate("select_menu", lang),
                     reply_markup=reply_markup)
Exemplo n.º 3
0
def send_comment(update, context):
    bot = context.bot
    lang = extract_language_and_update_if_not_present(update, context)

    user = update.message.from_user
    first_name = user.first_name if user.first_name is not None else ""
    last_name = user.last_name if user.last_name is not None else ""
    username = "******" + user.username if user.username is not None else ""

    bot.send_message(os.environ["FEEDBACK_CHANNEL"], f"""Отзыв о боте\nот {first_name} {last_name} {username}\n""" + \
                     update.message.text)
    bot.send_message(update.message.chat_id,
                     translate("thank_you_feedback", lang))
    menu(update, context)
    return ConversationHandler.END
Exemplo n.º 4
0
def call_cashier(update, context):
    bot = context.bot
    query = update.callback_query
    lang = extract_language_and_update_if_not_present(query, context)
    user = query.from_user

    first_name = user.first_name if user.first_name is not None else ""
    last_name = user.last_name if user.last_name is not None else ""
    username = "******" + user.username if user.username is not None else ""

    bot.send_message(
        os.environ["WORKERS_CHANNEL"],
        f"""Вызов официанта\nот {first_name} {last_name} {username}""")
    bot.edit_message_text(chat_id=query.message.chat_id,
                          message_id=query.message.message_id,
                          text=translate("staff_request_sent", lang))
Exemplo n.º 5
0
def select_staff(update, context):
    bot = context.bot
    lang = extract_language_and_update_if_not_present(update, context)
    keyboard = [[
        InlineKeyboardButton(f'❗{translate("call_admin", language=lang)}',
                             callback_data='call_admin')
    ],
                [
                    InlineKeyboardButton(
                        f'❕{translate("call_waiter", language=lang)}',
                        callback_data='call_waiter')
                ]]
    reply_markup = InlineKeyboardMarkup(keyboard)

    bot.send_message(update.message.chat_id,
                     translate("who_to_call", lang),
                     reply_markup=reply_markup)

    edit_stat("call_staff")
    edit_user_stat(update.message.chat_id, "call_staff")
    edit_daily_active_users_stat(update.message.chat_id)
Exemplo n.º 6
0
def write_comment(update, context):
    bot = context.bot

    lang = extract_language_and_update_if_not_present(update, context)

    keyboard = [
        [KeyboardButton(f'🚫{translate("cancel", lang)}')],
    ]
    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=False,
                                       resize_keyboard=True)

    bot.send_message(update.message.chat_id,
                     translate("write_feedback", lang),
                     reply_markup=reply_markup)

    edit_stat("feedback")

    edit_user_stat(update.message.chat_id, "feedback")

    edit_daily_active_users_stat(update.message.chat_id)

    return ADD_COMMENT