Пример #1
0
async def progress(current, total, event, start, type_of_ps, file_name=None):
    """Generic progress_callback for uploads and downloads."""
    now = time.time()
    diff = now - start
    if round(diff % 10.00) == 0 or current == total:
        percentage = current * 100 / total
        speed = current / diff
        elapsed_time = round(diff) * 1000
        time_to_completion = round((total - current) / speed) * 1000
        estimated_total_time = elapsed_time + time_to_completion
        progress_str = "{0}{1} {2}%\n".format(
            ''.join(["▰" for i in range(math.floor(percentage / 10))]),
            ''.join(["▱" for i in range(10 - math.floor(percentage / 10))]),
            round(percentage, 2))
        tmp = progress_str + \
            "{0} of {1}\nETA: {2}".format(
                humanbytes(current),
                humanbytes(total),
                time_formatter(estimated_total_time)
            )
        if file_name:
            await event.edit("{}\nFile Name: `{}`\n{}".format(
                type_of_ps, file_name, tmp))
        else:
            await event.edit("{}\n{}".format(type_of_ps, tmp))
Пример #2
0
async def progress(current, total, event, start, type_of_ps, file_name=None):
    """Generic progress_callback for uploads and downloads."""
    now = time.time()
    diff = now - start
    out_folder = Config.TMP_DOWNLOAD_DIRECTORY + "youtubedl/"
    Config.TMP_DOWNLOAD_DIRECTORY + "/thumb_image.jpg"
    if not os.path.isdir(out_folder):
        os.makedirs(out_folder)
    if round(diff % 10.00) == 0 or current == total:
        percentage = current * 100 / total
        speed = current / diff
        elapsed_time = round(diff) * 1000
        time_to_completion = round((total - current) / speed) * 1000
        estimated_total_time = elapsed_time + time_to_completion
        progress_str = "{0}{1} {2}%\n".format(
            ''.join(["â–ˆ" for i in range(math.floor(percentage / 10))]),
            ''.join(["â–‘" for i in range(10 - math.floor(percentage / 10))]),
            round(percentage, 2))
        tmp = progress_str + \
            "{0} of {1}\nETA: {2}".format(
                humanbytes(current),
                humanbytes(total),
                time_formatter(estimated_total_time)
            )
        if file_name:
            await event.edit("{}\nFile Name: `{}`\n{}".format(
                type_of_ps, file_name, tmp))
        else:
            await event.edit("{}\n{}".format(type_of_ps, tmp))
Пример #3
0
async def download_coroutine(session, url, file_name, event, start):
    CHUNK_SIZE = 2341
    downloaded = 0
    display_message = ""
    async with session.get(url) as response:
        total_length = int(response.headers["Content-Length"])
        content_type = response.headers["Content-Type"]
        if "text" in content_type and total_length < 500:
            return await response.release()
        await event.edit("""Initiating Download
URL: {}
File Name: {}
File Size: {}""".format(url, file_name, humanbytes(total_length)))
        with open(file_name, "wb") as f_handle:
            while True:
                chunk = await response.content.read(CHUNK_SIZE)
                if not chunk:
                    break
                f_handle.write(chunk)
                downloaded += CHUNK_SIZE
                now = time.time()
                diff = now - start
                if round(diff % 5.00) == 0 or downloaded == total_length:
                    percentage = downloaded * 100 / total_length
                    speed = downloaded / diff
                    elapsed_time = round(diff) * 1000
                    time_to_completion = round(
                        (total_length - downloaded) / speed) * 1000
                    estimated_total_time = elapsed_time + time_to_completion
                    try:
                        current_message = """**Download Status**
URL: {}
File Name: {}
File Size: {}
Downloaded: {}
ETA: {}""".format(
    url,
    file_name,
    humanbytes(total_length),
    humanbytes(downloaded),
    time_formatter(estimated_total_time)
)
                        if current_message != display_message:
                            await event.edit(current_message)
                            display_message = current_message
                    except Exception as e:
                        logger.info(str(e))
                        pass
        return await response.release()
Пример #4
0
async def _(event):
    if event.fwd_from:
        return
    
    currentTime = get_readable_time((time.time() - botStartTime))
    total, used, free = shutil.disk_usage('.')
    total = humanbytes(total)
    used = humanbytes(used)
    free = humanbytes(free)
    stats = f'Bot Uptime: {currentTime}\n' \
            f'Total disk space: {total}\n' \
                        f'Used: {used}\n' \
                        f'Free: {free}'

    await event.edit(str(stats))
Пример #5
0
async def _(event):
    if event.fwd_from:
        return
    splugin_name = event.pattern_match.group(1)
    if splugin_name in borg._plugins:
        s_help_string = borg._plugins[splugin_name].__doc__
    else:
        s_help_string = ""
    _, check_sgnirts = check_data_base_heal_th()

    current_run_time = time_formatter((time.time() - BOT_START_TIME))
    total, used, free = shutil.disk_usage("/")
    total = humanbytes(total)
    used = humanbytes(used)
    free = humanbytes(free)

    help_string = """@UniBorg
✅ <b>UpTime</b> <code>{}</code>
✅ <b>Python</b> <code>{}</code>
✅ <b>Telethon</b> <code>{}</code>
{} <b>Database</b>
<b>Total Disk Space</b>: <code>{}</code>
<b>Used Disk Space</b>: <code>{}</code>
<b>Free Disk Space</b>: <code>{}</code>

UserBot Forked from https://github.com/udf/uniborg""".format(
        current_run_time, sys.version, __version__, check_sgnirts, total, used,
        free)
    borg._iiqsixfourstore[str(event.chat_id)] = {}
    borg._iiqsixfourstore[str(event.chat_id)][str(
        event.id)] = help_string + "\n\n" + s_help_string
    tgbotusername = Config.TG_BOT_USER_NAME_BF_HER  # pylint:disable=E0602
    if tgbotusername is not None:
        results = await borg.inline_query(  # pylint:disable=E0602
            tgbotusername, f"@UniBorg {event.chat_id} {event.id}")
        await results[0].click(event.chat_id,
                               reply_to=event.reply_to_msg_id,
                               hide_via=True)
    else:
        await event.reply(help_string + "\n\n" + s_help_string,
                          parse_mode="html")

    await event.delete()
Пример #6
0
async def _(event):
    if event.fwd_from:
        return
    splugin_name = event.pattern_match.group(1)
    if splugin_name in borg._plugins:
        s_help_string = borg._plugins[splugin_name].__doc__
    else:
        s_help_string = ""
        _, check_sgnirts = check_data_base_heal_th()

    current_run_time = time_formatter((time.time() - BOT_START_TIME))
    total, used, free = shutil.disk_usage("/")
    total = humanbytes(total)
    used = humanbytes(used)
    free = humanbytes(free)

    help_string = "@UniBorg\n"
    help_string += f"✅ <b>UpTime</b> <code>{current_run_time}</code>\n"
    help_string += f"✅ <b>Python</b> <code>{sys.version}</code>\n"
    help_string += f"✅ <b>Telethon</b> <code>{__version__}</code>\n"
    help_string += f"{check_sgnirts} <b>Database</b>\n"
    help_string += f"<b>Total Disk Space</b>: <code>{total}</code>\n"
    help_string += f"<b>Used Disk Space</b>: <code>{used}</code>\n"
    help_string += f"<b>Free Disk Space</b>: <code>{free}</code>\n\n"
    help_string += f"<b>Custom Repo</b>: https://github.com/prono69/PepeBot"
    borg._iiqsixfourstore[str(event.chat_id)] = {}
    borg._iiqsixfourstore[str(event.chat_id)][str(
        event.id)] = (help_string + "\n\n" + s_help_string)
    tgbotusername = Config.TG_BOT_USER_NAME_BF_HER
    if tgbotusername is not None:
        results = await borg.inline_query(
            tgbotusername, f"@UniBorg {event.chat_id} {event.id}")
        await results[0].click(event.chat_id,
                               reply_to=event.reply_to_msg_id,
                               hide_via=True)
    else:
        await event.reply(help_string + "\n\n" + s_help_string,
                          parse_mode="html")

    await event.delete()
Пример #7
0
async def gdrive_list_file_md(service, file_id):
    try:
        file = service.files().get(fileId=file_id, supportsTeamDrives=True).execute()
        # logger.info(file)
        file_meta_data = {}
        file_meta_data["title"] = file["title"]
        mimeType = file["mimeType"]
        file_meta_data["createdDate"] = file["createdDate"]
        if mimeType == G_DRIVE_DIR_MIME_TYPE:
            # is a dir.
            file_meta_data["mimeType"] = "directory"
            file_meta_data["previewURL"] = file["alternateLink"]
        else:
            # is a file.
            file_meta_data["mimeType"] = file["mimeType"]
            file_meta_data["md5Checksum"] = file["md5Checksum"]
            file_meta_data["fileSize"] = str(humanbytes(int(file["fileSize"])))
            file_meta_data["quotaBytesUsed"] = str(humanbytes(int(file["quotaBytesUsed"])))
            file_meta_data["previewURL"] = file["downloadUrl"]
        return json.dumps(file_meta_data, sort_keys=True, indent=4)
    except Exception as e:
        return str(e)
Пример #8
0
async def drivesch(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1).strip()
    drive = GDriveHelper()
    await drive.authorize(event)
    files = await drive.getFilesByParentId(Config.GDRIVE_FOLDER_ID, input_str, 20)
    msg = f"**G-Drive Search Query**\n`{input_str}`\n**Results**\n"
    for file in files:
        if file.get("mimeType") == drive.G_DRIVE_DIR_MIME_TYPE:
            msg += "⁍ [{}]({}) (folder)".format(file.get('name'),
                                                drive.formatLink(file.get('id')))+"\n"
        else:
            msg += "⁍ [{}]({}) ({})".format(file.get('name'), drive.formatLink(
                file.get('id'), folder=False), humanbytes(int(file.get('size'))))+"\n"
    await event.edit(msg)
Пример #9
0
async def _(event):
    if event.fwd_from:
        return
    entity = event.chat_id
    input_str = event.pattern_match.group(1)
    if input_str:
        entity = input_str
    status_message = await event.reply("... this might take some time "
                                       "depending on the number of messages "
                                       "in the chat ...")
    mus = 0
    hmm = {}
    async for message in event.client.iter_messages(entity=entity, limit=None):
        if message and message.file:
            if message.file.mime_type not in hmm:
                hmm[message.file.mime_type] = 0
            hmm[message.file.mime_type] += message.file.size
    hnm = {key: humanbytes(hmm[key]) for key in hmm}
    await status_message.edit(yaml_format(hnm), parse_mode=parse_pre)
Пример #10
0
def search_idop_se(search_query):
    r = []
    url = "https://idope.se/search/{}/".format(search_query)
    raw_json = requests.get(url).json()
    results = raw_json["result"]["items"]
    for item in results:
        """ The content scrapped on 24.09.2018 22:56:45
        """
        title = item["name"]
        hash = item["info_hash"]
        age = item["create_time"]
        size = item["length"]
        seeds = str(item["seeds"])
        r.append({
            "title": title,
            "hash": hash,
            "age": age,
            "size": humanbytes(size),
            "seeds": seeds,
            "peers": "NA"
        })
    return r
Пример #11
0
    async def inline_handler(event):
        builder = event.builder
        result = None
        query = event.text
        if event.query.user_id == borg.uid and query.startswith("@UniBorg"):
            rev_text = query[::-1]
            buttons = paginate_help(0, borg._plugins, "helpme")
            result = builder.article(
                "© @UniBorg",
                text="{}\nCurrently Loaded Plugins: {}".format(
                    query, len(borg._plugins)),
                buttons=buttons,
                link_preview=False)
        elif query.startswith("ytdl"):
            # input format should be ytdl URL
            p = re.compile("ytdl (.*)")
            b = p.search(event.text)
            ytdl_url = "https://www.google.com/url?q=" + b.group(1).strip()
            if ytdl_url.startswith("http"):
                command_to_exec = [
                    "youtube-dl", "--no-warnings",
                    "--youtube-skip-dash-manifest", "-j", ytdl_url
                ]
                logger.info(command_to_exec)
                process = await asyncio.create_subprocess_exec(
                    *command_to_exec,
                    # stdout must a pipe to be accessible as process.stdout
                    stdout=asyncio.subprocess.PIPE,
                    stderr=asyncio.subprocess.PIPE,
                )
                # Wait for the subprocess to finish
                stdout, stderr = await process.communicate()
                e_response = stderr.decode().strip()
                # logger.info(e_response)
                t_response = stdout.decode().strip()
                logger.info(command_to_exec)
                if e_response:
                    error_message = e_response.replace(
                        "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                        "")
                    # throw error
                    result = builder.article(
                        "YTDL Errors © @UniBorg",
                        text=f"{error_message} Powered by @UniBorg",
                        link_preview=False)
                elif t_response:
                    x_reponse = t_response
                    if "\n" in x_reponse:
                        x_reponse, _ = x_reponse.split("\n")
                    response_json = json.loads(x_reponse)
                    save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                        "/" + "YouTubeDL" + ".json"
                    with open(save_ytdl_json_path, "w",
                              encoding="utf8") as outfile:
                        json.dump(response_json, outfile, ensure_ascii=False)
                    # logger.info(response_json)
                    inline_keyboard = []
                    duration = None
                    if "duration" in response_json:
                        duration = response_json["duration"]
                    if "formats" in response_json:
                        for formats in response_json["formats"]:
                            format_id = formats.get("format_id")
                            format_string = formats.get("format_note")
                            if format_string is None:
                                format_string = formats.get("format")
                            format_ext = formats.get("ext")
                            approx_file_size = ""
                            if "filesize" in formats:
                                approx_file_size = humanbytes(
                                    formats["filesize"])
                            cb_string_video = "ytdl|{}|{}|{}".format(
                                "video", format_id, format_ext)
                            if format_string is not None:
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + format_ext + " video [" +
                                        format_string + "] ( " +
                                        approx_file_size + " )",
                                        data=(cb_string_video))
                                ]
                            else:
                                # special weird case :\
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + approx_file_size + " ",
                                        data=cb_string_video)
                                ]
                            inline_keyboard.append(ikeyboard)
                        if duration is not None:
                            cb_string_64 = "ytdl|{}|{}|{}".format(
                                "audio", "64k", "mp3")
                            cb_string_128 = "ytdl|{}|{}|{}".format(
                                "audio", "128k", "mp3")
                            cb_string = "ytdl|{}|{}|{}".format(
                                "audio", "320k", "mp3")
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                     ")",
                                                     data=cb_string_64),
                                custom.Button.inline("MP3 " + "(" +
                                                     "128 kbps" + ")",
                                                     data=cb_string_128)
                            ])
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" +
                                                     "320 kbps" + ")",
                                                     data=cb_string)
                            ])
                    else:
                        format_id = response_json["format_id"]
                        format_ext = response_json["ext"]
                        cb_string_video = "ytdl|{}|{}|{}".format(
                            "video", format_id, format_ext)
                        inline_keyboard.append([
                            custom.Button.inline("video", data=cb_string_video)
                        ])
                    result = builder.article(
                        "YouTube © @UniBorg",
                        text="{} powered by @UniBorg".format(
                            ytdl_url.replace("https://www.google.com/url?q=",
                                             "")),
                        buttons=inline_keyboard,
                        link_preview=True)
        elif query.startswith("tb_btn"):
            result = builder.article("Button Parser © @UniBorg",
                                     text=f"Button Parser © @UniBorg",
                                     buttons=[
                                         custom.Button.url(
                                             "Source Code",
                                             "https://da.gd/YQgR7")
                                     ],
                                     link_preview=True)
        elif query.startswith("c_button"):
            BTN_URL_REGEX = re.compile(
                r"(\{([^\[]+?)\}\<button(url|text):(?:/{0,2})(.+?)(:same)?\>)")
            reply_message = query.replace("c_button ", "")
            markdown_note = reply_message
            prev = 0
            note_data = ""
            buttons = []
            for match in BTN_URL_REGEX.finditer(markdown_note):
                # Check if btnurl is escaped
                n_escapes = 0
                to_check = match.start(1) - 1
                while to_check > 0 and markdown_note[to_check] == "\\":
                    n_escapes += 1
                    to_check -= 1

                # if even, not escaped -> create button
                if n_escapes % 2 == 0:
                    # create a thruple with button label, url, and newline status
                    buttons.append(
                        (match.group(2), match.group(4), bool(match.group(5))))
                    note_data += markdown_note[prev:match.start(1)]
                    prev = match.end(1)

                # if odd, escaped -> move along
                else:
                    note_data += markdown_note[prev:to_check]
                    prev = match.start(1) - 1
            else:
                note_data += markdown_note[prev:]

            message_text = note_data.strip()
            tl_ib_buttons = build_keyboard(buttons, match.group(3))

            # logger.info(message_text)
            # logger.info(tl_ib_buttons)

            try:
                result = builder.article(
                    "Button Generated" if tl_ib_buttons else "Proccessing...",
                    text=message_text if tl_ib_buttons else "Error",
                    buttons=tl_ib_buttons if tl_ib_buttons else [
                        custom.Button.inline(
                            "Error",
                            data=
                            "txt_prod_Please Do Not Press Proccessing... Again"
                        )
                    ],
                    link_preview=True)
            except ButtonUrlInvalidError:
                pass
        else:
            result = builder.article(
                "© @UniBorg",
                text="""Hi there. I will introduce you to UniBorg
You can log-in as Bot or User and do many cool things with your Telegram account.

All instructions to run @UniBorg in your device has been explained in https://github.com/Somto811/UniBorg""",
                buttons=[[
                    custom.Button.url("Contact the Creator",
                                      "https://telegram.dog/loxxi"),
                    custom.Button.url("Tutorial",
                                      "https://telegra.ph/Tutorial-07-26")
                ],
                         [
                             custom.Button.url(
                                 "Source Code",
                                 "https://github.com/Somto811/UniBorg"),
                             custom.Button.url("Best Prank Ever",
                                               "https://da.gd/OpvE3")
                         ],
                         [
                             custom.Button.url(
                                 "Deploy to Heroku",
                                 "http://github.com/Somto811/UniBorg"),
                             custom.Button.url(
                                 "Fork Boost",
                                 "https://telegra.ph/Fork-Boost-07-28"),
                             custom.Button.url(
                                 "Premium Dyno Cheat",
                                 "https://telegra.ph/Premium-Dyno-Cheat-07-28")
                         ]],
                link_preview=False)
        await event.answer([result] if result else None)
Пример #12
0
    async def inline_handler(event):
        builder = event.builder
        result = None
        query = event.text
        if event.sender_id == borg.uid and query.startswith("@UniBorg"):
            rev_text = query[::-1]
            buttons = paginate_help(0, borg._plugins, "helpme")
            result = builder.article(
                "© @UniBorg",
                text="{}\nCurrently Loaded Plugins: {}".format(
                    query, len(borg._plugins)),
                buttons=buttons,
                link_preview=True,
                parse_mode="html")
        elif query.startswith("tb_btn"):
            result = builder.article("Button Parser © @UniBorg",
                                     text="powered by @LazyAF_Pepe",
                                     buttons=[],
                                     link_preview=True,
                                     parse_mode="html")
        elif query.startswith("ytdl"):
            # input format should be ytdl URL
            p = re.compile("ytdl (.*)")
            r = p.search(query)
            ytdl_url = r.group(1).strip()
            if ytdl_url.startswith("http"):
                command_to_exec = [
                    "youtube-dl", "--no-warnings",
                    "--youtube-skip-dash-manifest", "-j", ytdl_url
                ]
                logger.info(command_to_exec)
                process = await asyncio.create_subprocess_exec(
                    *command_to_exec,
                    # stdout must a pipe to be accessible as process.stdout
                    stdout=asyncio.subprocess.PIPE,
                    stderr=asyncio.subprocess.PIPE,
                )
                # Wait for the subprocess to finish
                stdout, stderr = await process.communicate()
                e_response = stderr.decode().strip()
                # logger.info(e_response)
                t_response = stdout.decode().strip()
                logger.info(command_to_exec)
                if e_response:
                    error_message = e_response.replace(
                        "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                        "")
                    # throw error
                    result = builder.article(
                        "YTDL Errors © @UniBorg",
                        text=f"{error_message} Powered by @LazyAF_Pepe",
                        link_preview=False)
                elif t_response:
                    x_reponse = t_response
                    if "\n" in x_reponse:
                        x_reponse, _ = x_reponse.split("\n")
                    response_json = json.loads(x_reponse)
                    save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                        "/" + "YouTubeDL" + ".json"
                    with open(save_ytdl_json_path, "w",
                              encoding="utf8") as outfile:
                        json.dump(response_json, outfile, ensure_ascii=False)
                    # logger.info(response_json)
                    inline_keyboard = []
                    duration = None
                    if "duration" in response_json:
                        duration = response_json["duration"]
                    if "formats" in response_json:
                        for formats in response_json["formats"]:
                            format_id = formats.get("format_id")
                            format_string = formats.get("format_note")
                            if format_string is None:
                                format_string = formats.get("format")
                            format_ext = formats.get("ext")
                            approx_file_size = ""
                            if "filesize" in formats:
                                approx_file_size = humanbytes(
                                    formats["filesize"])
                            cb_string_video = "ytdl|{}|{}|{}".format(
                                "video", format_id, format_ext)
                            if format_string is not None:
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + format_ext + " video [" +
                                        format_string + "] ( " +
                                        approx_file_size + " )",
                                        data=(cb_string_video))
                                ]
                            else:
                                # special weird case :\
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + approx_file_size + " ",
                                        data=cb_string_video)
                                ]
                            inline_keyboard.append(ikeyboard)
                        if duration is not None:
                            cb_string_64 = "ytdl|{}|{}|{}".format(
                                "audio", "64k", "mp3")
                            cb_string_128 = "ytdl|{}|{}|{}".format(
                                "audio", "128k", "mp3")
                            cb_string = "ytdl|{}|{}|{}".format(
                                "audio", "320k", "mp3")
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                     ")",
                                                     data=cb_string_64),
                                custom.Button.inline("MP3 " + "(" +
                                                     "128 kbps" + ")",
                                                     data=cb_string_128)
                            ])
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" +
                                                     "320 kbps" + ")",
                                                     data=cb_string)
                            ])
                    else:
                        format_id = response_json["format_id"]
                        format_ext = response_json["ext"]
                        cb_string_video = "ytdl|{}|{}|{}".format(
                            "video", format_id, format_ext)
                        inline_keyboard.append([
                            custom.Button.inline("video", data=cb_string_video)
                        ])
                    result = builder.article(
                        "YouTube © @kirito6969",
                        text=f"{ytdl_url} powered by @LazyAF_Pepe",
                        buttons=inline_keyboard,
                        link_preview=True)
        else:
            result = builder.article(
                "© @UniBorg",
                text="""@PepeB0t **( Custom Built By** @kirito6969 **)
**Verified Account:** ✅
**Official Website:** https://prono69.github.io/PepeBot/

**Pithun 3.8.5 (default, Apr 29 2020, 09:19:52)**
**[GCC 7.4.0]**
**Talethrun 1.15.0**

**Custom Built Fork:** https://github.com/prono69/PepeBot""",
                buttons=
                [[
                    custom.Button.url("👤Contact Creator👤",
                                      "https://telegram.dog/kirito6969"),
                    custom.Button.url("📼Ravana Audio Memes📼",
                                      "https://t.me/tgaudiomemes")
                ],
                 [
                     custom.Button.url("👨‍💻Source Code👨‍💻",
                                       "https://github.com/prono69/PepeBot"),
                     custom.Button.url(
                         "❕❗Deploy Me❗❕",
                         "https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2Fravana69%2FPornHub%2F&template=https%3A%2F%2Fgithub.com%2Fravana69%2FPornHub%2F"
                     )
                 ],
                 [
                     custom.Button.url("🔰Update Fork🔰",
                                       "tg://need_update_for_some_feature"),
                     custom.Button.url("✳️Fork Boost✳️",
                                       "tg://some_unsupported_feature"),
                     custom.Button.url("♻️Refresh Heroku♻️", "tg://chutiya")
                 ]],
                link_preview=True)
        await event.answer([result] if result else None)
Пример #13
0
 async def inline_handler(event):
     builder = event.builder
     result = None
     query = event.text
     if event.query.user_id == borg.uid and query.startswith("Plugins"):
         rev_text = query[::-1]
         buttons = paginate_help(0, borg._plugins, "helpme")
         result = builder.article(
             "© @hackedyouagain",
             text="{}\nCurrently Loaded Plugins: {}".format(
                 query, len(borg._plugins)),
             buttons=buttons,
             link_preview=False)
     elif query.startswith("ytdl"):
         # input format should be ytdl URL
         p = re.compile("ytdl (.*)")
         r = p.search(query)
         ytdl_url = r.group(1).strip()
         if ytdl_url.startswith("http"):
             command_to_exec = [
                 "youtube-dl", "--no-warnings",
                 "--youtube-skip-dash-manifest", "-j", ytdl_url
             ]
             logger.info(command_to_exec)
             process = await asyncio.create_subprocess_exec(
                 *command_to_exec,
                 # stdout must a pipe to be accessible as process.stdout
                 stdout=asyncio.subprocess.PIPE,
                 stderr=asyncio.subprocess.PIPE,
             )
             # Wait for the subprocess to finish
             stdout, stderr = await process.communicate()
             e_response = stderr.decode().strip()
             # logger.info(e_response)
             t_response = stdout.decode().strip()
             logger.info(command_to_exec)
             if e_response:
                 error_message = e_response.replace(
                     "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                     "")
                 # throw error
                 result = builder.article(
                     "YTDL Errors © ",
                     text=f"{error_message} Powered by Internet Lol!",
                     link_preview=False)
             elif t_response:
                 x_reponse = t_response
                 if "\n" in x_reponse:
                     x_reponse, _ = x_reponse.split("\n")
                 response_json = json.loads(x_reponse)
                 save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                     "/" + "YouTubeDL" + ".json"
                 with open(save_ytdl_json_path, "w",
                           encoding="utf8") as outfile:
                     json.dump(response_json, outfile, ensure_ascii=False)
                 # logger.info(response_json)
                 inline_keyboard = []
                 duration = None
                 if "duration" in response_json:
                     duration = response_json["duration"]
                 if "formats" in response_json:
                     for formats in response_json["formats"]:
                         format_id = formats.get("format_id")
                         format_string = formats.get("format_note")
                         if format_string is None:
                             format_string = formats.get("format")
                         format_ext = formats.get("ext")
                         approx_file_size = ""
                         if "filesize" in formats:
                             approx_file_size = humanbytes(
                                 formats["filesize"])
                         cb_string_video = "ytdl|{}|{}|{}".format(
                             "video", format_id, format_ext)
                         if format_string is not None:
                             ikeyboard = [
                                 custom.Button.inline(
                                     " " + format_ext + " video [" +
                                     format_string + "] ( " +
                                     approx_file_size + " )",
                                     data=(cb_string_video))
                             ]
                         else:
                             # special weird case :\
                             ikeyboard = [
                                 custom.Button.inline(
                                     " " + approx_file_size + " ",
                                     data=cb_string_video)
                             ]
                         inline_keyboard.append(ikeyboard)
                     if duration is not None:
                         cb_string_64 = "ytdl|{}|{}|{}".format(
                             "audio", "64k", "mp3")
                         cb_string_128 = "ytdl|{}|{}|{}".format(
                             "audio", "128k", "mp3")
                         cb_string = "ytdl|{}|{}|{}".format(
                             "audio", "320k", "mp3")
                         inline_keyboard.append([
                             custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                  ")",
                                                  data=cb_string_64),
                             custom.Button.inline("MP3 " + "(" +
                                                  "128 kbps" + ")",
                                                  data=cb_string_128)
                         ])
                         inline_keyboard.append([
                             custom.Button.inline("MP3 " + "(" +
                                                  "320 kbps" + ")",
                                                  data=cb_string)
                         ])
                 else:
                     format_id = response_json["format_id"]
                     format_ext = response_json["ext"]
                     cb_string_video = "ytdl|{}|{}|{}".format(
                         "video", format_id, format_ext)
                     inline_keyboard.append([
                         custom.Button.inline("video", data=cb_string_video)
                     ])
                 result = builder.article(
                     "YouTube ©",
                     text=f"{ytdl_url} powered by Internet Lol!",
                     buttons=inline_keyboard,
                     link_preview=True)
     else:
         result = builder.article(
             "Dont Click Me..",
             text="""Dont Try to use me only @hackedyouagain can do that""",
             buttons=[
                 [
                     custom.Button.url(
                         "Join the Channel",
                         "https://telegram.dog/hackedyouagain"),
                     custom.Button.url("Join the Group",
                                       "https://t.me/hackersinheree")
                 ],
                 [
                     custom.Button.url(
                         "Join Another Group",
                         "https://t.me/joinchat/Dkaagk3Nf6snvm2LSJ3paA")
                 ]
             ],
             link_preview=False)
     await event.answer([result] if result else None)
Пример #14
0
    async def inline_handler(event):
        builder = event.builder
        result = None
        query = event.text
        if event.query.user_id == borg.uid and query.startswith("@UniBorg"):
            rev_text = query[::-1]
            buttons = paginate_help(0, borg._plugins, "helpme")
            result = builder.article(
                "© @UniBorg",
                text="{}\nCurrently Loaded Plugins: {}".format(
                    query, len(borg._plugins)),
                buttons=buttons,
                link_preview=False)
        elif query.startswith("ytdl"):
            # input format should be ytdl URL
            p = re.compile("ytdl (.*)")
            r = p.search(query)
            ytdl_url = "https://www.google.com/url?q=" + r.group(1).strip()
            if ytdl_url.startswith("http"):
                command_to_exec = [
                    "youtube-dl", "--no-warnings",
                    "--youtube-skip-dash-manifest", "-j", ytdl_url
                ]
                logger.info(command_to_exec)
                process = await asyncio.create_subprocess_exec(
                    *command_to_exec,
                    # stdout must a pipe to be accessible as process.stdout
                    stdout=asyncio.subprocess.PIPE,
                    stderr=asyncio.subprocess.PIPE,
                )
                # Wait for the subprocess to finish
                stdout, stderr = await process.communicate()
                e_response = stderr.decode().strip()
                # logger.info(e_response)
                t_response = stdout.decode().strip()
                logger.info(command_to_exec)
                if e_response:
                    error_message = e_response.replace(
                        "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                        "")
                    # throw error
                    result = builder.article(
                        "YTDL Errors © @UniBorg",
                        text=f"{error_message} Powered by @UniBorg",
                        link_preview=False)
                elif t_response:
                    x_reponse = t_response
                    if "\n" in x_reponse:
                        x_reponse, _ = x_reponse.split("\n")
                    response_json = json.loads(x_reponse)
                    save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                        "/" + "YouTubeDL" + ".json"
                    with open(save_ytdl_json_path, "w",
                              encoding="utf8") as outfile:
                        json.dump(response_json, outfile, ensure_ascii=False)
                    # logger.info(response_json)
                    inline_keyboard = []
                    duration = None
                    if "duration" in response_json:
                        duration = response_json["duration"]
                    if "formats" in response_json:
                        for formats in response_json["formats"]:
                            format_id = formats.get("format_id")
                            format_string = formats.get("format_note")
                            if format_string is None:
                                format_string = formats.get("format")
                            format_ext = formats.get("ext")
                            approx_file_size = ""
                            if "filesize" in formats:
                                approx_file_size = humanbytes(
                                    formats["filesize"])
                            cb_string_video = "ytdl|{}|{}|{}".format(
                                "video", format_id, format_ext)
                            if format_string is not None:
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + format_ext + " video [" +
                                        format_string + "] ( " +
                                        approx_file_size + " )",
                                        data=(cb_string_video))
                                ]
                            else:
                                # special weird case :\
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + approx_file_size + " ",
                                        data=cb_string_video)
                                ]
                            inline_keyboard.append(ikeyboard)
                        if duration is not None:
                            cb_string_64 = "ytdl|{}|{}|{}".format(
                                "audio", "64k", "mp3")
                            cb_string_128 = "ytdl|{}|{}|{}".format(
                                "audio", "128k", "mp3")
                            cb_string = "ytdl|{}|{}|{}".format(
                                "audio", "320k", "mp3")
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                     ")",
                                                     data=cb_string_64),
                                custom.Button.inline("MP3 " + "(" +
                                                     "128 kbps" + ")",
                                                     data=cb_string_128)
                            ])
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" +
                                                     "320 kbps" + ")",
                                                     data=cb_string)
                            ])
                    else:
                        format_id = response_json["format_id"]
                        format_ext = response_json["ext"]
                        cb_string_video = "ytdl|{}|{}|{}".format(
                            "video", format_id, format_ext)
                        inline_keyboard.append([
                            custom.Button.inline("video", data=cb_string_video)
                        ])
                    result = builder.article(
                        "YouTube © @UniBorg",
                        text="{} powered by @UniBorg".format(
                            ytdl_url.replace("https://www.google.com/url?q=",
                                             "")),
                        buttons=inline_keyboard,
                        link_preview=True)
        elif query.startswith("tb_btn"):
            result = builder.article("Button Parser © @UniBorg",
                                     text=f"powered by @UniBorg",
                                     buttons=[],
                                     link_preview=True)
        else:
            result = builder.article(
                "© @UniBorg",
                text="""Hi there. I will introduce you to UniBorg
You can log-in as Bot or User and do many cool things with your Telegram account.

All instructions to run @UniBorg in your device has been explained in https://github.com/SnapDragon7410/UniBorg""",
                buttons=[[
                    custom.Button.url("Contact the Creator",
                                      "https://telegram.dog/snappy101"),
                    custom.Button.url("Tutorial",
                                      "https://telegra.ph/Tutorial-07-26")
                ],
                         [
                             custom.Button.url(
                                 "Source Code",
                                 "https://github.com/SnapDragon7410/UniBorg"),
                             custom.Button.url(
                                 "Best Prank Ever",
                                 "https://telegram.dog/s/freenetrulez")
                         ],
                         [
                             custom.Button.url("Deploy to Heroku",
                                               "http://da.gd/SnapBorg"),
                             custom.Button.url(
                                 "Fork Boost",
                                 "https://telegra.ph/Fork-Boost-07-28"),
                             custom.Button.url(
                                 "Premium Dyno Cheat",
                                 "https://telegra.ph/Premium-Dyno-Cheat-07-28")
                         ]],
                link_preview=False)
        await event.answer([result] if result else None)
Пример #15
0
 async def inline_handler(event):
     builder = event.builder
     result = None
     query = event.text
     if event.query.user_id == borg.uid and query.startswith("@UniBorg"):
         rev_text = query[::-1]
         buttons = paginate_help(0, borg._plugins, "helpme")
         result = builder.article(
             "© @AmazerS_xD",
             text="{}\nCurrently Loaded Plugins: {}".format(
                 query, len(borg._plugins)),
             buttons=buttons,
             link_preview=False)
     elif query.startswith("ytdl"):
         # input format should be ytdl URL
         p = re.compile("ytdl (.*)")
         r = p.search(query)
         ytdl_url = r.group(1).strip()
         if ytdl_url.startswith("http"):
             command_to_exec = [
                 "youtube-dl", "--no-warnings",
                 "--youtube-skip-dash-manifest", "-j", ytdl_url
             ]
             logger.info(command_to_exec)
             process = await asyncio.create_subprocess_exec(
                 *command_to_exec,
                 # stdout must a pipe to be accessible as process.stdout
                 stdout=asyncio.subprocess.PIPE,
                 stderr=asyncio.subprocess.PIPE,
             )
             # Wait for the subprocess to finish
             stdout, stderr = await process.communicate()
             e_response = stderr.decode().strip()
             # logger.info(e_response)
             t_response = stdout.decode().strip()
             logger.info(command_to_exec)
             if e_response:
                 error_message = e_response.replace(
                     "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                     "")
                 # throw error
                 result = builder.article(
                     "YTDL Errors © @UniBorg",
                     text=f"{error_message} Powered by @UniBorg",
                     link_preview=False)
             elif t_response:
                 x_reponse = t_response
                 if "\n" in x_reponse:
                     x_reponse, _ = x_reponse.split("\n")
                 response_json = json.loads(x_reponse)
                 save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                     "/" + "YouTubeDL" + ".json"
                 with open(save_ytdl_json_path, "w",
                           encoding="utf8") as outfile:
                     json.dump(response_json, outfile, ensure_ascii=False)
                 # logger.info(response_json)
                 inline_keyboard = []
                 duration = None
                 if "duration" in response_json:
                     duration = response_json["duration"]
                 if "formats" in response_json:
                     for formats in response_json["formats"]:
                         format_id = formats.get("format_id")
                         format_string = formats.get("format_note")
                         if format_string is None:
                             format_string = formats.get("format")
                         format_ext = formats.get("ext")
                         approx_file_size = ""
                         if "filesize" in formats:
                             approx_file_size = humanbytes(
                                 formats["filesize"])
                         cb_string_video = "ytdl|{}|{}|{}".format(
                             "video", format_id, format_ext)
                         if format_string is not None:
                             ikeyboard = [
                                 custom.Button.inline(
                                     " " + format_ext + " video [" +
                                     format_string + "] ( " +
                                     approx_file_size + " )",
                                     data=(cb_string_video))
                             ]
                         else:
                             # special weird case :\
                             ikeyboard = [
                                 custom.Button.inline(
                                     " " + approx_file_size + " ",
                                     data=cb_string_video)
                             ]
                         inline_keyboard.append(ikeyboard)
                     if duration is not None:
                         cb_string_64 = "ytdl|{}|{}|{}".format(
                             "audio", "64k", "mp3")
                         cb_string_128 = "ytdl|{}|{}|{}".format(
                             "audio", "128k", "mp3")
                         cb_string = "ytdl|{}|{}|{}".format(
                             "audio", "320k", "mp3")
                         inline_keyboard.append([
                             custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                  ")",
                                                  data=cb_string_64),
                             custom.Button.inline("MP3 " + "(" +
                                                  "128 kbps" + ")",
                                                  data=cb_string_128)
                         ])
                         inline_keyboard.append([
                             custom.Button.inline("MP3 " + "(" +
                                                  "320 kbps" + ")",
                                                  data=cb_string)
                         ])
                 else:
                     format_id = response_json["format_id"]
                     format_ext = response_json["ext"]
                     cb_string_video = "ytdl|{}|{}|{}".format(
                         "video", format_id, format_ext)
                     inline_keyboard.append([
                         custom.Button.inline("video", data=cb_string_video)
                     ])
                 result = builder.article(
                     "YouTube © @UniBorg",
                     text=f"{ytdl_url} powered by @UniBorg",
                     buttons=inline_keyboard,
                     link_preview=True)
     else:
         result = builder.article(
             "© @AmazerS_xD",
             text="""**Custom Built TGUserbot By** @AmazerS_xD
                     **Verified Account:** ✅
                     **Official Channel:** No channel yet
                     
                     **Python 3.7.4 (default, Sep 12 2019, 01:19:52)** 
                     **[GCC 7.4.0]**
                     **Telethon 1.10.3**
                     
                     **Custom Built Fork:** https://github.com/Amazers03/uniborg1/""",
             buttons=[[
                 custom.Button.url("Owner", "https://t.me/AmazerS_xD"),
                 custom.Button.url(
                     "Deploy",
                     "https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2FAmazers03%2Funiborg1&template=https%3A%2F%2Fgithub.com%2FAmazers03%2Funiborg1"
                 )
             ],
                      [
                          custom.Button.url(
                              "Source",
                              "https://github.com/Amazers03/unibog1")
                      ]],
             link_preview=False)
     await event.answer([result] if result else None)
Пример #16
0
    async def inline_handler(event):
        builder = event.builder
        result = None
        query = event.text
        if event.query.user_id == borg.uid and query.startswith("@UniBorg"):
            rev_text = query[::-1]
            buttons = paginate_help(0, borg._plugins, "helpme")
            result = builder.article(
                "© @UniBorg",
                text="{}\nℂ𝕦𝕣𝕣𝕖𝕟𝕥𝕝𝕪 𝕃𝕠𝕒𝕕𝕖𝕕 ℙ𝕝𝕦𝕘𝕚𝕟𝕤: {}".format(
                    query, len(borg._plugins)),
                buttons=buttons,
                link_preview=False)
        elif query.startswith("ytdl"):
            # input format should be ytdl URL
            p = re.compile("ytdl (.*)")
            r = p.search(query)
            ytdl_url = r.group(1).strip()
            if ytdl_url.startswith("http"):
                command_to_exec = [
                    "youtube-dl", "--no-warnings",
                    "--youtube-skip-dash-manifest", "-j", ytdl_url
                ]
                logger.info(command_to_exec)
                process = await asyncio.create_subprocess_exec(
                    *command_to_exec,
                    # stdout must a pipe to be accessible as process.stdout
                    stdout=asyncio.subprocess.PIPE,
                    stderr=asyncio.subprocess.PIPE,
                )
                # Wait for the subprocess to finish
                stdout, stderr = await process.communicate()
                e_response = stderr.decode().strip()
                # logger.info(e_response)
                t_response = stdout.decode().strip()
                logger.info(command_to_exec)
                if e_response:
                    error_message = e_response.replace(
                        "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
                        "")
                    # throw error
                    result = builder.article(
                        "YTDL Errors © @UniBorg",
                        text=f"{error_message} Powered by @UniBorg",
                        link_preview=False)
                elif t_response:
                    x_reponse = t_response
                    if "\n" in x_reponse:
                        x_reponse, _ = x_reponse.split("\n")
                    response_json = json.loads(x_reponse)
                    save_ytdl_json_path = Config.TMP_DOWNLOAD_DIRECTORY + \
                        "/" + "YouTubeDL" + ".json"
                    with open(save_ytdl_json_path, "w",
                              encoding="utf8") as outfile:
                        json.dump(response_json, outfile, ensure_ascii=False)
                    # logger.info(response_json)
                    inline_keyboard = []
                    duration = None
                    if "duration" in response_json:
                        duration = response_json["duration"]
                    if "formats" in response_json:
                        for formats in response_json["formats"]:
                            format_id = formats.get("format_id")
                            format_string = formats.get("format_note")
                            if format_string is None:
                                format_string = formats.get("format")
                            format_ext = formats.get("ext")
                            approx_file_size = ""
                            if "filesize" in formats:
                                approx_file_size = humanbytes(
                                    formats["filesize"])
                            cb_string_video = "ytdl|{}|{}|{}".format(
                                "video", format_id, format_ext)
                            if format_string is not None:
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + format_ext + " video [" +
                                        format_string + "] ( " +
                                        approx_file_size + " )",
                                        data=(cb_string_video))
                                ]
                            else:
                                # special weird case :\
                                ikeyboard = [
                                    custom.Button.inline(
                                        " " + approx_file_size + " ",
                                        data=cb_string_video)
                                ]
                            inline_keyboard.append(ikeyboard)
                        if duration is not None:
                            cb_string_64 = "ytdl|{}|{}|{}".format(
                                "audio", "64k", "mp3")
                            cb_string_128 = "ytdl|{}|{}|{}".format(
                                "audio", "128k", "mp3")
                            cb_string = "ytdl|{}|{}|{}".format(
                                "audio", "320k", "mp3")
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" + "64 kbps" +
                                                     ")",
                                                     data=cb_string_64),
                                custom.Button.inline("MP3 " + "(" +
                                                     "128 kbps" + ")",
                                                     data=cb_string_128)
                            ])
                            inline_keyboard.append([
                                custom.Button.inline("MP3 " + "(" +
                                                     "320 kbps" + ")",
                                                     data=cb_string)
                            ])
                    else:
                        format_id = response_json["format_id"]
                        format_ext = response_json["ext"]
                        cb_string_video = "ytdl|{}|{}|{}".format(
                            "video", format_id, format_ext)
                        inline_keyboard.append([
                            custom.Button.inline("video", data=cb_string_video)
                        ])
                    result = builder.article(
                        "YouTube © @UniBorg",
                        text=f"{ytdl_url} powered by @UniBorg",
                        buttons=inline_keyboard,
                        link_preview=True)
        else:
            result = builder.article(
                "© @UniBorg",
                text="""@UniBorg **( Custom Built By** @r4v4n4 **)** 
**Verified Account:** ✅
**Official Website:** https://ravanaisdrunk.site.live

**Pithun 3.7.3 (default, Apr  3 2019, 21:35:17)** 
**[GCC 7.3.0]**
**Talethrun 1.9.0**

**Custom Built Fork:** https://github.com/ravana69/UniBorg""",
                buttons=[[
                    custom.Button.url("👤Contact Creator👤",
                                      "https://telegram.dog/r4v4n4"),
                    custom.Button.url(
                        "🐶Resistance Dog🐶",
                        "https://t.me/addstickers/ResistanceDog")
                ],
                         [
                             custom.Button.url(
                                 "👨‍💻Source Code👨‍💻",
                                 "https://github.com/ravana69/UniBorg")
                         ]],
                link_preview=False)
        await event.answer([result] if result else None)