def all_infos(app, call): pkmn = re.split('/', call.data)[1] form = re.split('/', call.data)[2] if pkmn in form: text = func.set_message(data[pkmn][form], reduced=False) else: base_form = re.sub('_', ' ', pkmn.title()) name = base_form + ' (' + data[pkmn][form]['name'] + ')' text = func.set_message(data[pkmn][form], name, reduced=False) markup_list = [[ InlineKeyboardButton(text='➖ Reduce', callback_data='basic_infos/' + pkmn + '/' + form) ], [ InlineKeyboardButton(text='⚔️ Moveset', callback_data='moveset/' + pkmn + '/' + form), InlineKeyboardButton(text='🏠 Locations', callback_data='locations/' + pkmn + '/' + form) ]] for alt_form in data[pkmn]: if alt_form != form: markup_list.append([ InlineKeyboardButton(text=data[pkmn][alt_form]['name'], callback_data='basic_infos/' + pkmn + '/' + alt_form) ]) markup = InlineKeyboardMarkup(markup_list) func.bot_action(app, call, text, markup)
def pkmn_search(app, message): try: if message.text == '/data' or message.text == '/data@Rotom3_Bot': app.send_message(message.chat.id, texts['error1'], parse_mode='HTML') return None pkmn = func.find_name(message.text) result = func.check_name(pkmn, data) if type(result) == str: app.send_message(message.chat.id, result) return None elif type(result) == list: best_matches(app, message, result) return None else: pkmn = result['pkmn'] form = result['form'] except AttributeError: pkmn = re.split('/', message.data)[1] form = re.split('/', message.data)[2] if pkmn in form: text = func.set_message(data[pkmn][form], reduced=True) else: base_form = re.sub('_', ' ', pkmn.title()) name = base_form + ' (' + data[pkmn][form]['name'] + ')' text = func.set_message(data[pkmn][form], name, reduced=True) markup_list = [[ InlineKeyboardButton( text='➕ Expand', callback_data='all_infos/'+pkmn+'/'+form ) ], [ InlineKeyboardButton( text='⚔️ Moveset', callback_data='moveset/'+pkmn+'/'+form ), InlineKeyboardButton( text='🏠 Locations', callback_data='locations/'+pkmn+'/'+form ) ]] for alt_form in data[pkmn]: if alt_form != form: markup_list.append([ InlineKeyboardButton( text=data[pkmn][alt_form]['name'], callback_data='basic_infos/'+pkmn+'/'+alt_form ) ]) markup = InlineKeyboardMarkup(markup_list) func.bot_action(app, message, text, markup)