def airing_today(bot, update): from notif import anime_query, today anime_list = anime_query(86400) msg = 'Anime airing today are:\n' for anime in anime_list: text = today(anime) msg += f'\n{text}\n' bot.send_message(chat_id = update.message.chat_id, text = msg, parse_mode = "Markdown")
def inlinequery(bot, update): query = update.inline_query.query print(query) from main import anime_query, info from info_of_anime import info_anime data, anime_list, anime_dict, eng_dict = anime_query(query, 1, 20) results = [] pp.pprint(anime_dict) for anime in anime_list: animes = anime_dict[anime] animeinfo = info_anime(animes) try: image = animeinfo['coverImage']['medium'] except: try: image = animeinfo['coverImage']['large'] except: pass if animeinfo: status = animeinfo['status'] status = status.capitalize() status = status.replace('_',' ') typee = animeinfo['type'] typee = typee.capitalize() string = f'{status} {typee}' text, site_url, trailer_url = info(animes) if trailer_url: info_buttons = [[InlineKeyboardButton("Trailer", url = trailer_url), InlineKeyboardButton("Full Anime Page", url = site_url)]] else: info_buttons = [[InlineKeyboardButton("Full Anime Page", url = site_url)]] markup = InlineKeyboardMarkup(info_buttons) results.append( InlineQueryResultArticle( id = str(uuid4()), title = anime, input_message_content = (InputTextMessageContent(text, parse_mode='Markdown')), thumb_url = image, description = string, reply_markup=markup)) update.inline_query.answer(results)
def inlinequery(bot, update): query = update.inline_query.query from main import anime_query, info from info_of_anime import info_anime data, anime_list, anime_dict, eng_dict = anime_query(query, 1, 10) results = [] for anime in anime_list: animes = anime_dict[anime] animeinfo = info_anime(animes) image = animeinfo['coverImage']['medium'] status = animeinfo['status'] typee = animeinfo[''] text = info(animes) results.append( InlineQueryResultArticle( id=str(uuid4()), title=anime, input_message_content=(InputTextMessageContent( text, parse_mode='MARKDOWN')), thumb_url=image, description=status)) update.inline_query.answer(results)
def anime_search(bot, update, user_data): try: bot.delete_message(chat_id = update.message.chat_id, message_id = user_data['prev_message'].message_id) except: pass from main import anime_query if 'name' not in user_data.keys(): user_data['name'] = update.message.text anime_name = user_data['name'] if 'curr_page' not in user_data.keys(): user_data['curr_page'] = 1 curr_page = user_data['curr_page'] if 'sent_message' not in user_data.keys(): user_data['sent_message'] = bot.send_message(chat_id = update.message.chat_id, text = "Searching, wait a second...", reply_to_message_id = update.message.message_id) sent_message = user_data['sent_message'] data, anime_list, anime_dict, eng_dict = anime_query(anime_name, curr_page) if not data['data']['Page']['media']: bot.edit_message_text(chat_id = update.message.chat_id, text = "No Anime found, try again.", message_id = sent_message.message_id) try: bot.delete_message(chat_id = update.message.chat_id, message_id = update.message.message_id) except: pass return done(bot, update, user_data) user_data['anime_dict'] = anime_dict user_data['anime_list'] = anime_list if update.message: user_data['user_id'] = update.message.from_user.id msg = (f"Choose Anime:\n\n") try: if 'method' not in user_data.keys(): bot.delete_message(chat_id = update.message.chat_id, message_id = update.message.message_id) except: pass if len(anime_dict.keys())==1: if 'choice' in user_data.keys() and user_data['choice'] in ['add_to_watchlist', 'info', 'airing_schedule']: user_data['anime_id']=anime_dict[anime_list[0]] user_data['direct']=True try: bot.delete_message(chat_id = update.message.chat_id, message_id = sent_message.message_id) except: pass return intermediate(bot, update, user_data) for index, anime in enumerate(anime_dict, 1): if eng_dict[anime]: msg += (f"/{index}. {eng_dict[anime]}\n ({anime})\n") else: msg += (f"/{index}. {anime}\n") if data['data']['Page']['pageInfo']['hasNextPage']: inline_button = InlineKeyboardMarkup([[InlineKeyboardButton("More...", callback_data = 'search')]]) bot.edit_message_text(chat_id = sent_message.chat_id, text = msg, message_id = sent_message.message_id, reply_markup = inline_button) else: bot.edit_message_text(chat_id = sent_message.chat_id, text = msg, message_id = sent_message.message_id) return CHOICE
def update_anime_list(bot, job): from notif import anime_query anime_list = anime_query(1800) if anime_list: print(anime_list) return callback(bot, job, anime_list)
def update_anime_list(bot, job): from notif import anime_query anime_list = anime_query(7200) return callback(bot, job, anime_list)