'Refactored by Sourcery'

Co-authored-by: Sourcery AI <>
This commit is contained in:
sourcery-ai[bot] 2021-09-07 15:12:48 +07:00 committed by GitHub
parent d973ac2cc4
commit 8236bfd5aa
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,7 @@ async def return_search(query, page=1, sukebei=False):
except IndexError: except IndexError:
return '', len(results), ttl return '', len(results), ttl
message_info = dict() message_info = {}
ignore = set() ignore = set()
@app.on_message(filters.command(['nyaasi', f'nyaasi@{bot.username}'])) @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: if not result:
await message.reply_text('No results found') await message.reply_text('No results found')
else: 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: if pages == 1:
buttons.pop() buttons.pop()
reply = await message.reply_text(result, reply_markup=InlineKeyboardMarkup([ 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) await callback_query.answer('...no', cache_time=3600)
return return
text, pages, ttl = await return_search(query, current_page, sukebei) 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: if ttl_ended:
buttons = [InlineKeyboardButton('Search Expired', 'nyaa_nop')] buttons = [InlineKeyboardButton('Search Expired', 'nyaa_nop')]
else: else:
@ -196,9 +205,12 @@ class TorrentSearch:
return string return string
async def update_message(self): 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") 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 = [] inline = []
if (self.index != 0): 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} 'ts': {'source': "https://torrents-api.netlify.app/.netlify/functions/api/all/", 'result_str': RESULT_STR_ALL}
} }
torrent_handlers = [] torrent_handlers = [
for command, value in torrents_dict.items(): TorrentSearch(command, value['source'], value['result_str'])
torrent_handlers.append(TorrentSearch(command, value['source'], value['result_str'])) for command, value in torrents_dict.items()
]
def searchhelp(update, context): def searchhelp(update, context):
help_string = ''' help_string = '''