def callback_func(poll_w, update, context): global chosen1, poll_widget2 print("From callback function: ", poll_w.answer) chosen1 = poll_w.chosen answers = poll_w.answer #Lets create another poll. You can always create a poll and pass your # preferred arguments to it #Callback_data will call a state callback like if it was a button poll_widget2 = utils.multi_selection_widget( ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5"], single_option=True, #For this one only one option is accepted chosen=[], autoremove= True, #Just to show that this option exists and it's defaulted to True add_confirm_button= False, #Do not add the default confirm button because we are doing this differently spacing=15, #Let's add more spacing between the symbols and text payload_key="poll2", extra_buttons=[ InlineKeyboardButton("End", callback_data="confirm_poll_2"), InlineKeyboardButton("Back", callback_data="poll_back") ]) #Finally send the message again poll_widget2.send(update, context)
def poll2(answer, update, context): global keys tortia_side_choice = [ "Fried Chips", "Onion Rings", "Fried Cabbage", "Potatos" ] #print(context.bot_data["poll1"]["answer"]) # context.user_data['Poll1Answer'] = context.bot_data["poll1"]["answer"] cancel_text = emojize(" \U00002716 Cancel") back_button = emojize(" \U000021AA Back") payload_key = keys[1] poll = utils.multi_selection_widget( #options=list(f"Option: {i}" for i in range(4)), options=tortia_side_choice, question=" \U0001F35F Please select only one item!\n", single_option=True, n_columns=1, spacing=5, checked_symbol="✅", unchecked_symbol="☑️", payload_key=payload_key, confirm_button_text="Approve", cancel_buttons=[ InlineKeyboardButton(cancel_text, callback_data="cancel"), InlineKeyboardButton(back_button, callback_data="poll1") ], callback=finish) poll.send(update, context)
def tortia_salad(update, context): global keys query = update.callback_query data = update.callback_query.data tortia_dish_text = "" user_data = context.user_data user_id = user_data['user_id'] tortia_selection = context.user_data['TortiaSelection'] randomCartId = context.user_data['CartId'] product_keyboard = [] selection_title = "" if tortia_selection == "cb_antricott": selection_title = "Antricott" elif tortia_selection == "cb_chicken_p": selection_title = "Chicken Stake" elif tortia_selection == "cb_chicken_breast": selection_title = "Chicken Breast" elif tortia_selection == "cb_kabbab": selection_title = "Kebbab" user_selection_title = context.user_data['UserTortiaSelection'] user_selection_size = context.user_data['UserTortiaSize'] user_selection_price = context.user_data['UserTortiaPrice'] tortia_dish_text = user_selection_title + " " + user_selection_size + " " questions_all_salads = [ "Vegetable Salad", "Lettuce Salad", "Spicy Onion Salad", "Onion Salad", "Spicy Shifka", "Sweet Salsa", "Spicy Salsa", "Chimichuri", "Lemon", "Turkish Salad", "Tahina", "Avocado" ] reply_text = emojize("\n You selected {}.".format(tortia_dish_text)) salad_manager = emojize(" \U000021AA Approve") back_button = emojize(" \U000021AA Back") cancel_text = emojize(" \U00002716 Cancel") payload_key = keys[0] poll = utils.multi_selection_widget( options=questions_all_salads, question=" \U0001F371 Please choose the salads for {}. \n".format( selection_title), n_columns=2, spacing=5, checked_symbol="✅", unchecked_symbol="☑️", cancel_buttons=[ InlineKeyboardButton(cancel_text, callback_data="cancel"), ], payload_key=payload_key, callback=poll2) poll.send(update, context)
def jabeta_salad(update, context): global keys query = update.callback_query data = update.callback_query.data jabeta_dish_text = "" user_data = context.user_data user_id = user_data['user_id'] randomCartId = context.user_data['CartId'] product_keyboard = [] user_jabeta_selection = context.user_data["UserJabetaSelection"] user_jabeta_price = context.user_data["UserJabetaPrice"] questions_all_salads = ["Vegetable Salad", "Lettuce Salad", "Spicy Onion Salad", "Onion Salad", "Spicy Shifka", "Sweet Salsa", "Spicy Salsa", "Chimichuri", "Lemon", "Turkish Salad", "Tahina", "Avocado"] reply_text = emojize("\nYour selection {} was saved!".format(user_jabeta_selection)) salad_manager = emojize(" \U000021AA Approve") back_button = emojize(" \U000021AA Back") cancel_text = emojize(" \U00002716 Cancel") payload_key=keys[0] poll=utils.multi_selection_widget( options=questions_all_salads, question=" \U0001F371 Please choose the salads for this course. \n", n_columns=2, spacing=5, checked_symbol="✅", unchecked_symbol="☑️", cancel_buttons=[ InlineKeyboardButton(cancel_text, callback_data="cancel"), # InlineKeyboardButton(back_button, callback_data="back_1") ], payload_key=payload_key, # callback_data="tortia_poll_2" callback=poll2 ) poll.send(update, context)
def hamburger_salad(update, context): global keys query = update.callback_query data = update.callback_query.data tortia_dish_text = "" user_data = context.user_data user_id = user_data['user_id'] user_hamburger_selection = context.user_data['UserSelectedHamburger'] user_hamburger_price = context.user_data['UserHamburgerPrice'] randomCartId = context.user_data['CartId'] product_keyboard = [] humburger_salads = ["Lettuce", "Onion", "Tomato", "Pickle"] #print(tortia_salad_choices ) reply_text = emojize( "\nYour selection of {} was saved!".format(user_hamburger_selection)) salad_manager = emojize(" \U000021AA Approve") back_button = emojize(" \U000021AA Back") cancel_text = emojize(" \U00002716 Cancel") payload_key = keys[0] poll = utils.multi_selection_widget( options=humburger_salads, question=" \U0001F371 Please choose your hamburger toppings: \n", n_columns=2, spacing=5, checked_symbol="✅", unchecked_symbol="☑️", cancel_buttons=[ InlineKeyboardButton(cancel_text, callback_data="cancel"), # InlineKeyboardButton(back_button, callback_data="back_1") ], payload_key=payload_key, # callback_data="tortia_poll_2" callback=poll2) poll.send(update, context)
def meal_manager(update, context): query = update.callback_query data = update.callback_query.data user_data = context.user_data user_id = user_data['user_id'] randomCartId = context.user_data['CartId'] tortia_selection = context.user_data['TortiaSelection'] chat_id = update.effective_message.chat_id keyword = str(data) selection_title = "" if keyword == "cb_regulare_meal": selection_title = "Regulare Meal" context.user_data['UserSelectedMeal'] = selection_title context.user_data['UserMealPrice'] = 50.00 print("TORTIA SELECTION: $$$$$$$ " + str(selection_title)) elif keyword == "cb_double_meal": selection_title = "Double Meal" context.user_data['UserSelectedMeal'] = selection_title context.user_data['UserMealPrice'] = 60.00 print("TORTIA SELECTION: $$$$$$$ " + str(selection_title)) elif keyword == "cb_triple_meal": selection_title = "Triple Meal" context.user_data['UserSelectedMeal'] = selection_title context.user_data['UserMealPrice'] = 75.00 print("TORTIA SELECTION: $$$$$$$ " + str(selection_title)) product_keyboard = [] salad_manager = emojize(" \U000021AA Approve") back_button = emojize(" \U000021AA Back") cancel_text = emojize(" \U00002716 Cancel") completed_text = emojize(" \U00002611 הזמן עכשיו") questions_all_salads = [ "Vegetable Salad", "Lettuce Salad", "Spicy Onion Salad", "Onion Salad", "Spicy Shifka", "Sweet Salsa", "Spicy Salsa", "Chimichuri", "Lemon", "Turkish Salad", "Tahina", "Avocado" ] payload_key = keys[0] poll = utils.multi_selection_widget( options=questions_all_salads, question=" \U0001F371 Please choose the salads for {}. \n".format( selection_title), n_columns=2, spacing=5, checked_symbol="✅", unchecked_symbol="☑️", cancel_buttons=[ InlineKeyboardButton(cancel_text, callback_data="cancel"), # InlineKeyboardButton(back_button, callback_data="back_1") ], payload_key=payload_key, # callback_data="tortia_poll_2" callback=poll2) poll.send(update, context) product_keyboard += [[ InlineKeyboardButton(back_button, callback_data="cb_back_tortias"), InlineKeyboardButton(cancel_text, callback_data="cancel") ]] product_keyboard = list(product_keyboard) reply_markup_cart = InlineKeyboardMarkup(product_keyboard)
def default_poll(): return utils.multi_selection_widget(checked_symbol="✅", unchecked_symbol="☑️")