From 8236bfd5aa02a167bab1f8146dd25956ad9b34ef Mon Sep 17 00:00:00 2001 From: "sourcery-ai[bot]" <58596630+sourcery-ai[bot]@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:12:48 +0700 Subject: [PATCH] 'Refactored by Sourcery' Co-authored-by: Sourcery AI <> --- bot/modules/torrent_search.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/bot/modules/torrent_search.py b/bot/modules/torrent_search.py index e41eb93..3e00496 100644 --- a/bot/modules/torrent_search.py +++ b/bot/modules/torrent_search.py @@ -70,7 +70,7 @@ async def return_search(query, page=1, sukebei=False): except IndexError: return '', len(results), ttl -message_info = dict() +message_info = {} ignore = set() @app.on_message(filters.command(['nyaasi', f'nyaasi@{bot.username}'])) @@ -92,7 +92,11 @@ async def init_search(client, message, query, sukebei): if not result: await message.reply_text('No results found') else: - buttons = [InlineKeyboardButton(f'1/{pages}', 'nyaa_nop'), InlineKeyboardButton(f'Next', 'nyaa_next')] + buttons = [ + InlineKeyboardButton(f'1/{pages}', 'nyaa_nop'), + InlineKeyboardButton('Next', 'nyaa_next'), + ] + if pages == 1: buttons.pop() reply = await message.reply_text(result, reply_markup=InlineKeyboardMarkup([ @@ -132,7 +136,12 @@ async def nyaa_callback(client, callback_query): await callback_query.answer('...no', cache_time=3600) return text, pages, ttl = await return_search(query, current_page, sukebei) - buttons = [InlineKeyboardButton(f'Prev', 'nyaa_back'), InlineKeyboardButton(f'{current_page}/{pages}', 'nyaa_nop'), InlineKeyboardButton(f'Next', 'nyaa_next')] + buttons = [ + InlineKeyboardButton('Prev', 'nyaa_back'), + InlineKeyboardButton(f'{current_page}/{pages}', 'nyaa_nop'), + InlineKeyboardButton('Next', 'nyaa_next'), + ] + if ttl_ended: buttons = [InlineKeyboardButton('Search Expired', 'nyaa_nop')] else: @@ -196,9 +205,12 @@ class TorrentSearch: return string async def update_message(self): - prevBtn = InlineKeyboardButton(f"Prev", callback_data=f"{self.command}_previous") + prevBtn = InlineKeyboardButton( + 'Prev', callback_data=f"{self.command}_previous" + ) + delBtn = InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data=f"{self.command}_delete") - nextBtn = InlineKeyboardButton(f"Next", callback_data=f"{self.command}_next") + nextBtn = InlineKeyboardButton('Next', callback_data=f"{self.command}_next") inline = [] if (self.index != 0): @@ -314,9 +326,10 @@ torrents_dict = { 'ts': {'source': "https://torrents-api.netlify.app/.netlify/functions/api/all/", 'result_str': RESULT_STR_ALL} } -torrent_handlers = [] -for command, value in torrents_dict.items(): - torrent_handlers.append(TorrentSearch(command, value['source'], value['result_str'])) +torrent_handlers = [ + TorrentSearch(command, value['source'], value['result_str']) + for command, value in torrents_dict.items() +] def searchhelp(update, context): help_string = '''