def increase_page(message): curr_page = logmode.get_user_field(message.chat.username, "current_page") print_functions.delete_products_page(message, bot) logmode.update_user_field("current_page", curr_page + 1, message.chat.username) print_functions.print_products(message, bot) logmode.create_log(bot, message, "command")
def new_favourite(callback_data, bot): args = callback_data.data.split("_") current_service_code = args[1] product_index = int(args[2]) prod = parse_shop.get_products_list(current_service_code)[product_index] current_fav_list = logmode.get_user_field( callback_data.message.chat.username, "favourites") current_fav_list.append(prod.create_dict()) logmode.update_user_field("favourites", current_fav_list, callback_data.message.chat.username)
def check_if_service_name(message): # Services list in config.py for service in service_list: if (message.text == service.fullname): logmode.update_user_field("current_service_code", service.code, message.chat.username) return service # if(message.text == "Торгівельна мережа АТБ"): PREV VERSION # logmode.update_user_field("current_service_code", service_codes_list.index( # "atb"), message.chat.username) # # current_service_code = service_codes_list.index("atb") # # print("\n" + service_list[current_service_code].fullname + # # "\ncurr index:[{}]".format(current_service_code)) # return service_list[service_codes_list.index("atb")] # else: return bot_classes.service(code=-1)
def answer_text(message): code = print_functions.check_if_service_name(message).code if print_functions.say_hello(message, bot): # CHAT-BOT FUNCTIONS if config.create_log: logmode.create_log(bot, message, "text") return elif (code >= 0): # IF STRING IS SHOP NAME logmode.create_log(bot, message, "command") logmode.update_user_field("current_page", 0, message.chat.username) logmode.update_user_field("current_service_code", code, message.chat.username) print_functions.delete_few_messages(message.message_id, 2, message.chat.id, bot) print_functions.print_products(message, bot) return else: print_functions.responce_to_casual_text( message, bot) # DEFAULT ANSWER TO STRING if config.create_log: logmode.create_log(bot, message, "text")
def favourites_menu(message): print_functions.delete_few_messages(message.message_id, 2, message.chat.id, bot) logmode.update_user_field("current_page", 0, message.chat.username) print_functions.print_favourites(message, bot) logmode.create_log(bot, message, "command")