def quest_choice(update, context): ''' Bot core to interact with quests. ''' msg = update.message.text.lower() quests = context.user_data['quests'] if msg == endphrase: if get_solved(quests) == NUM_QTS: reply = "Congratulazioni! Hai finito tutte le missioni..." reply_markup = ReplyKeyboardRemove() update.message.reply_text(reply, reply_markup=reply_markup) return ConversationHandler.END reply = "Non hai completato tutte le missioni. Che peccato..." elif msg == 'quest 0': reply = check_choice(quests, 0) elif msg == 'quest 1': reply = check_choice(quests, 1) elif msg == 'quest 2': reply = check_choice(quests, 2) elif msg == 'quest 3': reply = check_choice(quests, 3) elif msg == 'quest 4': reply = check_choice(quests, 4) elif msg == 'quest 5': reply = check_choice(quests, 5) else: reply = "Non ho niente da dire..." update.message.reply_text(reply)
def status(update, context): '''Show number of completed quests.''' if 'quests' in context.user_data.keys(): quests = context.user_data['quests'] solved_qts = get_solved(quests) reply = f"Hai completato {solved_qts} quest su {NUM_QTS}" else: reply = f"Hai completato 0 quest su {NUM_QTS}" update.message.reply_text(reply)
def unlocks(update, context): ''' Unlock missions with the correct passphrase ''' msg = update.message.text.lower() reply = "Non ho niente da dire..." if msg == passphrase: if 'quests' not in context.user_data.keys(): context.user_data['quests'] = create_qts() reply_keyboard = [['Quest 0', 'Quest 1', 'Quest 2'], ['Quest 3', 'Quest 4', 'Quest 5']] markup = ReplyKeyboardMarkup(reply_keyboard, resize_keyboard=True) update.message.reply_text(reply, reply_markup=markup) return 1 elif msg == endphrase: if 'quests' in context.user_data.keys(): quests = context.user_data['quests'] if get_solved(quests) == NUM_QTS: reply = "Congratulazioni! Hai finito tutte le missioni..." else: reply = "Non hai completato tutte le missioni. Che peccato..." update.message.reply_text(reply)