def send_product_text(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(update.message.chat_id, f"{translate('request_sent', lang)}") menu(update, context) data_about_user = "******" + " " + str(update.message.chat_id) + " " + str(update.message.message_id) keyboard = [ [InlineKeyboardButton(u"✅Есть", callback_data=data_about_user + " 1 " + lang), InlineKeyboardButton(u"❌Отсутсвует", callback_data=data_about_user + " 0 " + lang)], ] reply_markup = InlineKeyboardMarkup(keyboard) if lang == "ru": message = f"""🔎Запрос информации о наличии продукта\nот {first_name} {last_name} {username}\nНазвание продукта:\n""" \ + update.message.text else: message = f"""🔎🇬🇧 Запрос информации о наличии продукта\nот {first_name} {last_name} {username}\nНазвание продукта на английском:\n""" \ + update.message.text + "\n\nПеревод:\n" + translate_from_eng(update.message.text) bot.send_message(os.environ["WORKERS_CHANNEL"], message, reply_markup=reply_markup) return ConversationHandler.END
def send_product_photo(update, context): bot = context.bot user_data = context.user_data lang = extract_language_and_update_if_not_present(update, context) photo_file_id = update.message.photo[len(update.message.photo) - 1].file_id bot.send_message(update.message.chat_id, f"{translate('enter_product_name', lang)}") user_data["file_id"] = photo_file_id return ADD_PHOTO_TEXT
def input_photo(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, f"{translate('enter_product_photo', lang)}", reply_markup=reply_markup) return ADD_PHOTO
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
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))
def wrong_receipt(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, f"{translate('send_wrong_tag', lang)}", reply_markup=reply_markup) edit_stat("wrong_receipt") edit_user_stat(update.message.chat_id, "wrong_receipt") edit_daily_active_users_stat(update.message.chat_id) return ADD_COMMENT_RECEIPT
def send_product_text_photo(update, context): bot = context.bot user_data = context.user_data 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(update.message.chat_id, f"{translate('request_sent', lang)}") menu(update, context) picture = bot.send_photo(photo=user_data["file_id"], chat_id=os.environ["WORKERS_CHANNEL"]) data_about_user = "******" + " " + str(update.message.chat_id) + " " + str( update.message.message_id) keyboard = [ [ InlineKeyboardButton("✅Принять", callback_data=data_about_user + " 1 " + lang), InlineKeyboardButton("❌Отклонить", callback_data=data_about_user + " 0 " + lang) ], ] reply_markup = InlineKeyboardMarkup(keyboard) if lang == "ru": message = f"""🚚Заказ продуктов\nот {first_name} {last_name} {username}\nНазвание продукта:\n""" \ + update.message.text else: message = f"""🚚🇬🇧 Заказ продуктов\nот {first_name} {last_name} {username}\nНазвание продукта на английском:\n""" \ + update.message.text + "\n\nПеревод:\n" + translate_from_eng(update.message.text) bot.send_message(os.environ["WORKERS_CHANNEL"], message, reply_to_message_id=picture.message_id, reply_markup=reply_markup) return ConversationHandler.END
def choose_product(update, context): bot = context.bot lang = extract_language_and_update_if_not_present(update, context) keyboard = [[ KeyboardButton(f"📝{translate('send_name', lang)}") ], [KeyboardButton(f"📸📝{translate('send_name_and_photo', lang)}")], [KeyboardButton(f"🚫{translate('cancel', lang)}")]] reply_markup = ReplyKeyboardMarkup(keyboard, one_time_keyboard=False, resize_keyboard=True) bot.send_message(update.message.chat_id, f"{translate('select_option', lang)}", reply_markup=reply_markup) edit_stat("place_order") edit_user_stat(update.message.chat_id, "place_order") edit_daily_active_users_stat(update.message.chat_id) return SELECT_TYPE
def menu(update, context): bot = context.bot lang = extract_language_and_update_if_not_present(update, context) keyboard = [ [KeyboardButton(f"🗺{translate('shop_map', lang)}")], [KeyboardButton(f"🏃{translate('call_staff', lang)}")], [ KeyboardButton( f"🔎{translate('request_information_about_product', lang)}") ], [KeyboardButton(f"🚚{translate('place_order', lang)}")], [KeyboardButton(f"📵{translate('wrong_tag', 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)
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_cashier", language=lang)}', callback_data='call_cashier') ]] 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)
def send_photo(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 "" photo_file_id = update.message.photo[len(update.message.photo) - 1].file_id message = f"Отзыв о неправильном ценнике\nот {first_name} {last_name} {username}\n" bot.send_photo(photo=photo_file_id, chat_id=os.environ["WORKERS_CHANNEL"], caption=message) bot.send_message(update.message.chat_id, f"{translate('thank_fix_tag', lang)}") menu(update, context) return ConversationHandler.END
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