Ejemplo n.º 1
0
def torserbut(update, context):
    query = update.callback_query
    user_id = query.from_user.id
    message = query.message
    key = message.reply_to_message.text.split(" ", maxsplit=1)[1]
    data = query.data
    data = data.split(" ")
    if user_id != int(data[1]):
        query.answer(text="Not Yours!", show_alert=True)
    elif data[2] == 'api':
        query.answer()
        button = _api_buttons(user_id)
        editMessage('Choose site to search:', message, button)
    elif data[2] == 'plugin':
        query.answer()
        button = _plugin_buttons(user_id)
        editMessage('Choose site to search:', message, button)
    elif data[2] != "cancel":
        query.answer()
        site = data[2]
        tool = data[3]
        if tool == 'api':
            editMessage(f"<b>Searching for <i>{key}</i>\nTorrent Site:- <i>{SITES.get(site)}</i></b>", message)
        else:
            editMessage(f"<b>Searching for <i>{key}</i>\nTorrent Site:- <i>{site.capitalize()}</i></b>", message)
        Thread(target=_search, args=(key, site, message, tool)).start()
    else:
        query.answer()
        editMessage("Search has been canceled!", message)
Ejemplo n.º 2
0
def _qual_subbuttons(task_id, qual, msg):
    buttons = button_build.ButtonMaker()
    task_info = listener_dict[task_id]
    formats_dict = task_info[6]
    qual_fps_ext = resplit(r'p|-', qual, maxsplit=2)
    height = qual_fps_ext[0]
    fps = qual_fps_ext[1]
    ext = qual_fps_ext[2]
    tbrs = []
    for tbr in formats_dict[qual]:
        tbrs.append(tbr)
    tbrs.sort(reverse=True)
    for index, br in enumerate(tbrs):
        if index == 0:
            tbr = f">{br}"
        else:
            sbr = index - 1
            tbr = f"<{tbrs[sbr]}"
        if fps != '':
            video_format = f"bv*[height={height}][fps={fps}][ext={ext}][tbr{tbr}]"
        else:
            video_format = f"bv*[height={height}][ext={ext}][tbr{tbr}]"
        size = formats_dict[qual][br]
        buttonName = f"{br}K ({get_readable_file_size(size)})"
        buttons.sbutton(str(buttonName), f"qu {task_id} {video_format}")
    buttons.sbutton("Back", f"qu {task_id} back")
    buttons.sbutton("Cancel", f"qu {task_id} cancel")
    SUBBUTTONS = InlineKeyboardMarkup(buttons.build_menu(2))
    editMessage(f"Choose Video Bitrate for <b>{qual}</b>:", msg, SUBBUTTONS)
Ejemplo n.º 3
0
def _auto_cancel(msg, msg_id):
    sleep(60)
    try:
        del listener_dict[msg_id]
        editMessage('Timed out! Task has been cancelled.', msg)
    except:
        pass
Ejemplo n.º 4
0
def _list_drive(key, bmsg, list_method, item_type):
    LOGGER.info(f"listing: {key}")
    list_method = list_method == "recu"
    gdrive = GoogleDriveHelper()
    msg, button = gdrive.drive_list(key, isRecursive=list_method, itemType=item_type)
    if button:
        editMessage(msg, bmsg, button)
    else:
        editMessage(f'No result found for <i>{key}</i>', bmsg)
Ejemplo n.º 5
0
def _getResult(search_results, key, message, tool):
    telegraph_content = []
    msg = f"<h4>Search Result For {key}</h4>"
    for index, result in enumerate(search_results, start=1):
        if tool == 'api':
            try:
                msg += f"<code><a href='{result['Url']}'>{escape(result['Name'])}</a></code><br>"
                if "Files" in result.keys():
                    for subres in result['Files']:
                        msg += f"<b>Quality: </b>{subres['Quality']} | <b>Size: </b>{subres['Size']}<br>"
                        try:
                            msg += f"<b>Share link to</b> <a href='http://t.me/share/url?url={subres['Torrent']}'>Telegram</a><br>"
                            msg += f"<b>Link: </b><code>{subres['Torrent']}</code><br>"
                        except KeyError:
                            msg += f"<b>Share Magnet to</b> <a href='http://t.me/share/url?url={subres['Magnet']}'>Telegram</a><br>"
                else:
                    msg += f"<b>Size: </b>{result['Size']}<br>"
                    msg += f"<b>Seeders: </b>{result['Seeders']} | <b>Leechers: </b>{result['Leechers']}<br>"
            except KeyError:
                pass
            try:
                msg += f"<b>Share Magnet to</b> <a href='http://t.me/share/url?url={quote(result['Magnet'])}'>Telegram</a><br><br>"
            except KeyError:
                msg += "<br>"
        else:
            msg += f"<a href='{result.descrLink}'>{escape(result.fileName)}</a><br>"
            msg += f"<b>Size: </b>{get_readable_file_size(result.fileSize)}<br>"
            msg += f"<b>Seeders: </b>{result.nbSeeders} | <b>Leechers: </b>{result.nbLeechers}<br>"
            link = result.fileUrl
            if link.startswith('magnet:'):
                msg += f"<b>Share Magnet to</b> <a href='http://t.me/share/url?url={quote(link)}'>Telegram</a><br><br>"
            else:
                msg += f"<b>Share Url to</b> <a href='http://t.me/share/url?url={link}'>Telegram</a><br><br>"

        if len(msg.encode('utf-8')) > 39000:
           telegraph_content.append(msg)
           msg = ""

        if index == SEARCH_LIMIT:
            break

    if msg != "":
        telegraph_content.append(msg)

    editMessage(f"<b>Creating</b> {len(telegraph_content)} <b>Telegraph pages.</b>", message)
    path = [telegraph.create_page(
                title='Mirror-leech-bot Torrent Search',
                content=content
            )["path"] for content in telegraph_content]
    sleep(0.5)
    if len(path) > 1:
        editMessage(f"<b>Editing</b> {len(telegraph_content)} <b>Telegraph pages.</b>", message)
        _edit_telegraph(path, telegraph_content)
    return f"https://telegra.ph/{path[0]}"
Ejemplo n.º 6
0
def select_format(update, context):
    query = update.callback_query
    user_id = query.from_user.id
    data = query.data
    msg = query.message
    data = data.split(" ")
    task_id = int(data[1])
    try:
        task_info = listener_dict[task_id]
    except:
        return editMessage("This is old task", msg)
    uid = task_info[1]
    if user_id != uid:
        return query.answer(text="Don't waste your time!", show_alert=True)
    elif data[2] == "dict":
        query.answer()
        qual = data[3]
        return _qual_subbuttons(task_id, qual, msg)
    elif data[2] == "back":
        query.answer()
        return editMessage('Choose Video Quality:', msg, task_info[4])
    elif data[2] == "audio":
        query.answer()
        if len(data) == 4:
            playlist = True
        else:
            playlist = False
        return _audio_subbuttons(task_id, msg, playlist)
    elif data[2] != "cancel":
        query.answer()
        listener = task_info[0]
        link = task_info[2]
        name = task_info[3]
        args = task_info[5]
        qual = data[2]
        if qual.startswith(
                'bv*['
        ):  # To not exceed telegram button bytes limits. Temp solution.
            height = resplit(r'\[|\]', qual, maxsplit=2)[1]
            qual = qual + f"+ba/b[{height}]"
        if len(data) == 4:
            playlist = True
        else:
            playlist = False
        ydl = YoutubeDLHelper(listener)
        Thread(target=ydl.add_download,
               args=(link, f'{DOWNLOAD_DIR}{task_id}', name, qual, playlist,
                     args)).start()
    del listener_dict[task_id]
    query.message.delete()
Ejemplo n.º 7
0
def list_drive(update,context):
    try:
        search = update.message.text.split(' ',maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Searching..... Please wait!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)
 
        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('No result found', reply, button)
 
    except IndexError:
        sendMessage('send a search key along with command', context.bot, update)
Ejemplo n.º 8
0
def _audio_subbuttons(task_id, msg, playlist=False):
    buttons = button_build.ButtonMaker()
    audio_qualities = [64, 128, 320]
    for q in audio_qualities:
        if playlist:
            i = 's'
            audio_format = f"ba/b-{q} t"
        else:
            i = ''
            audio_format = f"ba/b-{q}"
        buttons.sbutton(f"{q}K-mp3", f"qu {task_id} {audio_format}")
    buttons.sbutton("Back", f"qu {task_id} back")
    buttons.sbutton("Cancel", f"qu {task_id} cancel")
    SUBBUTTONS = InlineKeyboardMarkup(buttons.build_menu(2))
    editMessage(f"Choose Audio{i} Bitrate:", msg, SUBBUTTONS)
Ejemplo n.º 9
0
def list_drive(update,context):
    try:
        search = update.message.text.split(' ',maxsplit=1)[1]
        LOGGER.info(f"𝗦𝗲𝗮𝗿𝗰𝗵𝗶𝗻𝗴: {search}")
        reply = sendMessage('𝗦𝗲𝗮𝗿𝗰𝗵𝗶𝗻𝗴....𝗛𝗼𝗹𝗱 𝗢𝗻!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)
 
        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('𝗡𝗼 𝗿𝗲𝘀𝘂𝗹𝘁 𝗳𝗼𝘂𝗻𝗱', reply, button)
 
    except IndexError:
        sendMessage('𝘀𝗲𝗻𝗱 𝗮 𝘀𝗲𝗮𝗿𝗰𝗵 𝗸𝗲𝘆 𝗮𝗹𝗼𝗻𝗴 𝘄𝗶𝘁𝗵 𝗰𝗼𝗺𝗺𝗮𝗻𝗱', context.bot, update)
Ejemplo n.º 10
0
def list_drive(update,context):
    try:
        search = update.message.text.split(' ',maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Searching..... Please wait!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)
 
        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('tidak ditemukan. contoh mencari Avengers Infinity War cukup tulis /list avengers saja', reply, button)
 
    except IndexError:
        sendMessage('ketik /list lalu nama film, contoh mencari Avengers Infinity War cukup tulis /list avengers', context.bot, update)
Ejemplo n.º 11
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        reply = sendMessage('Searching...', context.bot, update)

        LOGGER.info(f"Searching: {search}")

        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        editMessage(msg, reply)

    except IndexError:
        sendMessage('send a search key along with command', context.bot,
                    update)
Ejemplo n.º 12
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"𝐒𝐞𝐚𝐫𝐜𝐡𝐢𝐧𝐠: {search}")
        reply = sendMessage('🔍𝐒𝐞𝐚𝐫𝐜𝐡𝐢𝐧𝐠... 𝐏𝐥𝐞𝐚𝐬𝐞 𝐖𝐚𝐢𝐭!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('🔍𝐍𝐨 𝐑𝐞𝐬𝐮𝐥𝐭𝐬 𝐅𝐨𝐮𝐧𝐝❌', reply, button)

    except IndexError:
        sendMessage('𝐒𝐞𝐧𝐝 𝐚 𝐒𝐞𝐚𝐫𝐜𝐡🔍 𝐊𝐞𝐲𝐰𝐨𝐫𝐝 𝐀𝐥𝐨𝐧𝐠 𝐰𝐢𝐭𝐡 𝐁𝐨𝐭 𝐂𝐨𝐦𝐦𝐚𝐧𝐝',
                    context.bot, update)
Ejemplo n.º 13
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Searching..... Please wait!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('Tidak ada hasil yang ditemukan', reply, button)

    except IndexError:
        sendMessage('kirim kunci pencarian bersama dengan perintah',
                    context.bot, update)
Ejemplo n.º 14
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Mencari..... Mohon tunggu sambil minum kopi!',
                            context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('Hasil tidak ditemukan', reply, button)

    except IndexError:
        sendMessage('Berikan kata kunci setelah command', context.bot, update)
Ejemplo n.º 15
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"🔎 Searching : {search}")
        reply = sendMessage('🔎 Searching..... Please wait! 🔁', context.bot,
                            update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('🚫 No Result Found 🚫', reply, button)

    except IndexError:
        sendMessage('🔍 Submit the search keywords along with the command 🔎',
                    context.bot, update)
Ejemplo n.º 16
0
def msg_list_drive(update, context):
    try:
        search = update.message.text
        reply = sendMessage(
            f'Searching for {search} in my Google Drive Database...',
            context.bot, update)

        LOGGER.info(f"Searching: {search}")

        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        editMessage(msg, reply, button)

    except IndexError:
        sendMessage('send a search key along with command', context.bot,
                    update)
Ejemplo n.º 17
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Bentar lagi nge cari file yang kamu cari',
                            context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('No result found', reply, button)

    except IndexError:
        sendMessage('command yang kamu kirim salah/kosong', context.bot,
                    update)
Ejemplo n.º 18
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('🔍𝚂𝚎𝚊𝚛𝚌𝚑𝚒𝚗𝚐..... 𝙿𝚕𝚎𝚊𝚜𝚎 𝚠𝚊𝚒𝚝🤚❗️', context.bot,
                            update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('🚫𝗡𝗼 𝗿𝗲𝘀𝘂𝗹𝘁 𝗳𝗼𝘂𝗻𝗱🚫', reply, button)

    except IndexError:
        sendMessage('𝚂𝚎𝚗𝚍 𝚊 𝚜𝚎𝚊𝚛𝚌𝚑 𝚔𝚎𝚢 𝚊𝚕𝚘𝚗𝚐 𝚠𝚒𝚝𝚑 𝚌𝚘𝚖𝚖𝚊𝚗𝚍😏', context.bot,
                    update)
Ejemplo n.º 19
0
Archivo: list.py Proyecto: NickxFury/td
def list_drive(update,context):
    try:
        search = update.message.text.split(' ',maxsplit=1)[1]
        if "'"in search:
            search = search.replace("'", "\\'")
    except IndexError:
        sendMessage('<b>⛽@DEV_BOTSS-Bᴏᴛ: ➼Sᴇɴᴅ ᴀ Fɪʟᴇ Kᴇʏᴡᴏʀᴅ Tᴏ Sᴇᴀʀᴄʜ, Aʟᴏɴɢ Wɪᴛʜ /search Cᴏᴍᴍᴀɴᴅ</b>', context.bot, update)
        return
        
    reply = sendMessage('<b>🔍Sᴇᴀʀᴄʜɪɴɢ...Pʟᴇᴀsᴇ Wᴀɪᴛ!& join @DEV_BOTSS</b>', context.bot, update)

    LOGGER.info(f"Searching: {search}")
        
    gdrive = GoogleDriveHelper(None)
    msg, button = gdrive.drive_list(search)

    editMessage(msg,reply,button)
Ejemplo n.º 20
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Đang tìm kiếm ..... Vui lòng đợi!', context.bot,
                            update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage('Không có kết quả nào', reply, button)

    except IndexError:
        sendMessage('gửi một từ khoá và tìm kiếm cùng với lệnh', context.bot,
                    update)
Ejemplo n.º 21
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('Searching..... Please wait!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage(
                '😬Error!! Please Go To https://testing.bunny.workers.dev/0: To Search🤪',
                reply, button)

    except IndexError:
        sendMessage(
            '😬Error!! Please Go To https://testing.bunny.workers.dev/0: To Search🤪',
            context.bot, update)
Ejemplo n.º 22
0
def list_drive(update, context):
    try:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: {search}")
        reply = sendMessage('<b>🔍Sᴇᴀʀᴄʜɪɴɢ...Pʟᴇᴀsᴇ Wᴀɪᴛ!</b>', context.bot,
                            update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)

        if button:
            editMessage(msg, reply, button)
        else:
            editMessage(
                '<b>➼Nᴏ Rᴇsᴜʟᴛs Fᴏᴜɴᴅ Fᴏʀ Yᴏᴜʀ Fɪʟᴇ Nᴀᴍᴇ Kᴇʏᴡᴏʀᴅ :(</b>',
                reply, button)

    except IndexError:
        sendMessage(
            '<b>➼Sᴇɴᴅ ᴀ Fɪʟᴇ Nᴀᴍᴇ As Kᴇʏᴡᴏʀᴅ Tᴏ Sᴇᴀʀᴄʜ., Aʟᴏɴɢ Wɪᴛʜ</b> <b>/list</b> <b>Cᴏᴍᴍᴀɴᴅ</b>',
            context.bot, update)
def speedtest(update, context):
    speed = sendMessage("Running Speed Test . . . ", context.bot, update)
    test = Speedtest()
    test.get_best_server()
    test.download()
    test.upload()
    test.results.share()
    result = test.results.dict()
    string_speed = f'''
<b>Server</b>
<b>Name:</b> <code>{result['server']['name']}</code>
<b>Country:</b> <code>{result['server']['country']}, {result['server']['cc']}</code>
<b>Sponsor:</b> <code>{result['server']['sponsor']}</code>
<b>ISP:</b> <code>{result['client']['isp']}</code>
<b>SpeedTest Results</b>
<b>Upload:</b> <code>{speed_convert(result['upload'] / 8)}</code>
<b>Download:</b>  <code>{speed_convert(result['download'] / 8)}</code>
<b>Ping:</b> <code>{result['ping']} ms</code>
<b>ISP Rating:</b> <code>{result['client']['isprating']}</code>
'''
    editMessage(string_speed, speed)
Ejemplo n.º 24
0
def tor_search(update, context):
    message = update.message.text
    query = message.split(" ", maxsplit=1)[1]
    msg = sendMessage("Searching for available torrents...", context.bot,
                      update)
    api_url = "https://api.sumanjay.cf/torrent/?query=" + query

    r = requests.get(api_url)
    try:
        torrents = r.json()
        reply_ = ""
        for torrent in torrents:
            if len(reply_) < 4096:
                try:
                    reply_ = (reply_ + f"\n\n<b>{torrent['name']}</b>\n"
                              f"<b>Site : </b>{torrent['site']}\n"
                              f"<b>Size : </b>{torrent['size']}\n"
                              f"<b>Seeders : </b>{torrent['seeder']}\n"
                              f"<b>Leechers : </b>{torrent['leecher']}\n"
                              f"<code>{torrent['magnet']}</code>")
                    editMessage(reply_, msg)
                    time.sleep(0.5)
                except BaseException:
                    pass

        if reply_ == "":
            editMessage(f"No torrents found for {query}", msg)

    except BaseException:
        editMessage("Torrent Search API is down\nTry again later", msg)
Ejemplo n.º 25
0
def rss_get(update, context):
    try:
        args = update.message.text.split(" ")
        title = args[1]
        count = int(args[2])
        feed_url = rss_dict.get(title)
        if feed_url is not None and count > 0:
            try:
                msg = sendMessage(
                    f"Getting the last <b>{count}</b> item(s) from {title}",
                    context.bot, update)
                rss_d = feedparse(feed_url[0])
                item_info = ""
                for item_num in range(count):
                    try:
                        link = rss_d.entries[item_num]['links'][1]['href']
                    except IndexError:
                        link = rss_d.entries[item_num]['link']
                    item_info += f"<b>Name: </b><code>{rss_d.entries[item_num]['title']}</code>\n"
                    item_info += f"<b>Link: </b><code>{link}</code>\n\n"
                editMessage(item_info, msg)
            except IndexError as e:
                LOGGER.error(str(e))
                editMessage(
                    "Parse depth exceeded. Try again with a lower value.", msg)
            except Exception as e:
                LOGGER.error(str(e))
                editMessage(str(e), msg)
        else:
            sendMessage("Enter a vaild title/value.", context.bot, update)
    except (IndexError, ValueError):
        sendMessage(
            f"Use this format to fetch:\n/{BotCommands.RssGetCommand} Title value",
            context.bot, update)
Ejemplo n.º 26
0
def select_type(update, context):
    query = update.callback_query
    user_id = query.from_user.id
    msg = query.message
    key = msg.reply_to_message.text.split(" ", maxsplit=1)[1]
    data = query.data
    data = data.split(" ")
    if user_id != int(data[1]):
        query.answer(text="Not Yours!", show_alert=True)
    elif data[2] in ["root", "recu"]:
        query.answer()
        buttons = button_build.ButtonMaker()
        buttons.sbutton("Folders", f"types {user_id} folders {data[2]}")
        buttons.sbutton("Files", f"types {user_id} files {data[2]}")
        buttons.sbutton("Both", f"types {user_id} both {data[2]}")
        buttons.sbutton("Cancel", f"types {user_id} cancel")
        button = InlineKeyboardMarkup(buttons.build_menu(2))
        editMessage('Choose option to list.', msg, button)
    elif data[2] in ["files", "folders", "both"]:
        query.answer()
        list_method = data[3]
        item_type = data[2]
        editMessage(f"<b>Searching for <i>{key}</i></b>", msg)
        Thread(target=_list_drive, args=(key, msg, list_method, item_type)).start()
    else:
        query.answer()
        editMessage("list has been canceled!", msg)
Ejemplo n.º 27
0
def list_drive(update, context):
    if update.message.text == f'/{BotCommands.ListCommand}':
        sendMessage(f'Send a search key along with {BotCommands.ListCommand} command', context.bot, update)
    else:
        search = update.message.text.split(' ', maxsplit=1)[1]
        LOGGER.info(f"Searching: '{search}'...")
        reply = sendMessage('Searching..... Please Wait!', context.bot, update)
        gdrive = GoogleDriveHelper(None)
        msg, button = gdrive.drive_list(search)
        if msg:
            if button:
                editMessage(msg, reply, button)
            else:
                editMessage(msg, reply)
        else:
            editMessage('No results found', reply)
Ejemplo n.º 28
0
def _search(key, site, message, tool):
    LOGGER.info(f"Searching: {key} from {site}")
    if tool == 'api':
        api = f"{SEARCH_API_LINK}/api/{site}/{key}"
        try:
            resp = rget(api)
            search_results = resp.json()
            if site == "all":
                search_results = list(
                    itertools.chain.from_iterable(search_results))
            if isinstance(search_results, list):
                msg = f"<b>Found {min(len(search_results), SEARCH_LIMIT)}</b>"
                msg += f" <b>result for <i>{key}</i>\nTorrent Site:- <i>{SITES.get(site)}</i></b>"
            else:
                return editMessage(
                    f"No result found for <i>{key}</i>\nTorrent Site:- <i>{SITES.get(site)}</i>",
                    message)
        except Exception as e:
            editMessage(str(e), message)
    else:
        client = get_client()
        search = client.search_start(pattern=str(key),
                                     plugins=str(site),
                                     category='all')
        search_id = search.id
        while True:
            result_status = client.search_status(search_id=search_id)
            status = result_status[0].status
            if status != 'Running':
                break
        dict_search_results = client.search_results(search_id=search_id)
        search_results = dict_search_results.results
        total_results = dict_search_results.total
        if total_results != 0:
            msg = f"<b>Found {min(total_results, SEARCH_LIMIT)}</b>"
            msg += f" <b>result for <i>{key}</i>\nTorrent Site:- <i>{site.capitalize()}</i></b>"
        else:
            return editMessage(
                f"No result found for <i>{key}</i>\nTorrent Site:- <i>{site.capitalize()}</i>",
                message)
    link = _getResult(search_results, key, message, tool)
    buttons = button_build.ButtonMaker()
    buttons.buildbutton("🔎 VIEW", link)
    button = InlineKeyboardMarkup(buttons.build_menu(1))
    editMessage(msg, message, button)
    if tool != 'api':
        client.search_delete(search_id=search_id)
Ejemplo n.º 29
0
def ping(update, context):
    start_time = int(round(time.time() * 1000))
    reply = sendMessage("Starting Ping", context.bot, update)
    end_time = int(round(time.time() * 1000))
    editMessage(f"{end_time - start_time} ms", reply)
Ejemplo n.º 30
0
def editLeechType(message, query):
    msg, button = getleechinfo(query.from_user)
    editMessage(msg, message, button)