Ejemplo n.º 1
0
async def convert_sticker_to_gif(sticker):
    gif_id = sticker_to_gif.get(str(sticker.id), None)
    if gif_id:
        access_hash = access_hashes[str(gif_id)]
        return types.InputDocument(gif_id, access_hash, b'')
    file = BytesIO()
    await borg.download_media(sticker, file=file)
    file.seek(0)

    # remove alpha
    im = Image.open(file)
    alpha = im.convert('RGBA').getchannel('A')
    size = max(im.width, im.height)
    new_im = Image.new('RGBA', (size, size), (40, 40, 40, 255))
    xy = (round((size - im.width) / 2), round((size - im.height) / 2))
    new_im.paste(im, box=xy, mask=alpha)
    file = BytesIO()
    new_im.save(file, format='gif')
    file.seek(0)

    # upload file
    file = await event.upload_file(file, part_size_kb=512)
    file = types.InputMediaUploadedDocument(file, 'video/mp4', [])
    media = await event(UploadMediaRequest('me', file))
    media = utils.get_input_document(media)

    # save (that's right, this is relational json)
    sticker_to_gif[str(sticker.id)] = media.id
    gif_to_sticker[str(media.id)] = sticker.id
    access_hashes[str(sticker.id)] = sticker.access_hash
    access_hashes[str(media.id)] = media.access_hash
    storage.sticker_to_gif = sticker_to_gif
    storage.access_hashes = access_hashes

    return media
Ejemplo n.º 2
0
async def _(event):
    if event.fwd_from:
        return
    catreply = await event.get_reply_message()
    if not catreply or not catreply.media or not catreply.media.document:
        return await edit_or_reply(event,
                                   "`Stupid!, This is not animated sticker.`")
    if catreply.media.document.mime_type != "application/x-tgsticker":
        return await edit_or_reply(event,
                                   "`Stupid!, This is not animated sticker.`")
    reply_to_id = event.message
    if event.reply_to_msg_id:
        reply_to_id = await event.get_reply_message()
    chat = "@tgstogifbot"
    catevent = await edit_or_reply(event, "`Converting to gif ...`")
    async with event.client.conversation(chat) as conv:
        try:
            await silently_send_message(conv, "/start")
            await event.client.send_file(chat, catreply.media)
            response = await conv.get_response()
            await event.client.send_read_acknowledge(conv.chat_id)
            if response.text.startswith("Send me an animated sticker!"):
                return await catevent.edit("`This file is not supported`")
            catresponse = response if response.media else await conv.get_response(
            )
            await event.client.send_read_acknowledge(conv.chat_id)
            catfile = Path(await
                           event.client.download_media(catresponse, "./temp/"))
            catgif = Path(await unzip(catfile))
            sandy = await event.client.send_file(
                event.chat_id,
                catgif,
                support_streaming=True,
                force_document=False,
                reply_to=reply_to_id,
            )
            await event.client(
                functions.messages.SaveGifRequest(
                    id=types.InputDocument(
                        id=sandy.media.document.id,
                        access_hash=sandy.media.document.access_hash,
                        file_reference=sandy.media.document.file_reference,
                    ),
                    unsave=True,
                ))
            await catevent.delete()
            for files in (catgif, catfile):
                if files and os.path.exists(files):
                    os.remove(files)
        except YouBlockedUserError:
            await catevent.edit("Unblock @tgstogifbot")
            return
Ejemplo n.º 3
0
async def on_gif(event):
    if not event.gif:
        return
    sticker_id = gif_to_sticker.get(str(event.gif.id), None)
    if not sticker_id:
        return
    access_hash = access_hashes[str(sticker_id)]
    sticker = types.InputDocument(sticker_id, access_hash, b'')

    await event.delete()
    await event.client.send_message(await event.get_input_chat(),
                                    file=sticker,
                                    reply_to=event.message.reply_to_msg_id)
Ejemplo n.º 4
0
async def unsavegif(event, h1m4n5hu0p):
    try:
        await event.client(
            functions.messages.SaveGifRequest(
                id=types.InputDocument(
                    id=h1m4n5hu0p.media.document.id,
                    access_hash=h1m4n5hu0p.media.document.access_hash,
                    file_reference=h1m4n5hu0p.media.document.file_reference,
                ),
                unsave=True,
            ))
    except Exception as e:
        LOGS.info(str(e))
Ejemplo n.º 5
0
async def unsavegif(event, sandy):
    try:
        await event.client(
            functions.messages.SaveGifRequest(
                id=types.InputDocument(
                    id=sandy.media.document.id,
                    access_hash=sandy.media.document.access_hash,
                    file_reference=sandy.media.document.file_reference,
                ),
                unsave=True,
            )
        )
    except:
        pass
Ejemplo n.º 6
0
async def decide(event):
    decision = event.pattern_match.group(1).lower()
    message_id = event.reply_to_msg_id or None
    if decision != "decide":
        r = requests.get(f"https://yesno.wtf/api?force={decision}").json()
    else:
        r = requests.get(f"https://yesno.wtf/api").json()
    await event.delete()
    sandy = await event.client.send_message(event.chat_id,
                                            str(r["answer"]).upper(),
                                            reply_to=message_id,
                                            file=r["image"])
    await event.client(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=sandy.media.document.id,
                access_hash=sandy.media.document.access_hash,
                file_reference=sandy.media.document.file_reference,
            ),
            unsave=True,
        ))
Ejemplo n.º 7
0
async def spammer(e):
    if e.fwd_from:
        return
    await e.get_chat()
    reply_to_id = e.message
    if e.reply_to_msg_id:
        reply_to_id = await e.get_reply_message()
    if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
    try:
        hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
        hmm = Get(hmm)
        await e.client(hmm)
    except BaseException:
        pass
    cat = e.pattern_match.group(1).split(' ', 1)
    counter = int(cat[0])
    if len(cat) == 2:
        spam_message = str(e.pattern_match.group(1).split(' ', 1)[1])
        await e.delete()
        for i in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
                await asyncio.sleep(0.1)
            else:
                await borg.send_message(e.chat_id, spam_message)
                await asyncio.sleep(0.1)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(
                    BOTLOG_CHATID, "#SPAM\n" +
                    f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} messages of \n"
                    + f"`{spam_message}`")
            else:
                await e.client.send_message(
                    BOTLOG_CHATID, "#SPAM\n" +
                    f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) chat  with {counter} messages of \n"
                    + f"`{spam_message}`")
    elif reply_to_id.media:
        to_download_directory = Config.TMP_DOWNLOAD_DIRECTORY
        downloaded_file_name = os.path.join(to_download_directory, "spam")
        downloaded_file_name = await borg.download_media(
            reply_to_id.media, downloaded_file_name)
        await e.delete()
        if os.path.exists(downloaded_file_name):
            for i in range(counter):
                sandy = await borg.send_file(e.chat_id, downloaded_file_name)
                await borg(
                    functions.messages.SaveGifRequest(id=types.InputDocument(
                        id=sandy.media.document.id,
                        access_hash=sandy.media.document.access_hash,
                        file_reference=sandy.media.document.file_reference),
                                                      unsave=True))
                await asyncio.sleep(1)
            if BOTLOG:
                if e.is_private:
                    await e.client.send_message(
                        BOTLOG_CHATID, "#SPAM\n" +
                        f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} times with below message"
                    )
                    sandy = await borg.send_file(BOTLOG_CHATID,
                                                 downloaded_file_name)
                    await borg(
                        functions.messages.SaveGifRequest(
                            id=types.InputDocument(
                                id=sandy.media.document.id,
                                access_hash=sandy.media.document.access_hash,
                                file_reference=sandy.media.document.
                                file_reference),
                            unsave=True))
                    os.remove(downloaded_file_name)
                else:
                    await e.client.send_message(
                        BOTLOG_CHATID, "#SPAM\n" +
                        f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) with {counter} times with below message"
                    )
                    sandy = await borg.send_file(BOTLOG_CHATID,
                                                 downloaded_file_name)
                    await borg(
                        functions.messages.SaveGifRequest(
                            id=types.InputDocument(
                                id=sandy.media.document.id,
                                access_hash=sandy.media.document.access_hash,
                                file_reference=sandy.media.document.
                                file_reference),
                            unsave=True))
                    os.remove(downloaded_file_nam)
    elif reply_to_id.text and e.reply_to_msg_id:
        spam_message = reply_to_id.text
        await e.delete()
        for i in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
                await asyncio.sleep(0.5)
            else:
                await borg.send_message(e.chat_id, spam_message)
                await asyncio.sleep(0.5)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(
                    BOTLOG_CHATID, "#SPAM\n" +
                    f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} messages of \n"
                    + f"`{spam_message}`")
            else:
                await e.client.send_message(
                    BOTLOG_CHATID, "#SPAM\n" +
                    f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) chat  with {counter} messages of \n"
                    + f"`{spam_message}`")
    else:
        await e.edit("try again something went wrong or check `.info spam`")
Ejemplo n.º 8
0
async def glitch(event):
    if not event.reply_to_msg_id:
        await event.edit("`Não vou falhar um fantasma!`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit("`responda a uma imagem/sticker`")
        return
    await bot.download_file(reply_message.media)
    await event.edit("`Baixando mídia..`")
    if event.is_reply:
        data = await check_media(reply_message)
        if isinstance(data, bool):
            await event.edit("`Arquivos não suportados...`")
            return
    else:
        await event.edit("`Responda a qualquer mídia`")
        return

    try:
        value = int(event.pattern_match.group(1))
        if value > 8:
            raise ValueError
    except ValueError:
        value = 2
    await event.edit("```Falhando essa mídia```")
    await asyncio.sleep(2)
    file_name = "glitch.png"
    to_download_directory = TEMP_DOWNLOAD_DIRECTORY
    downloaded_file_name = os.path.join(to_download_directory, file_name)
    downloaded_file_name = await bot.download_media(
        reply_message,
        downloaded_file_name,
    )
    glitch_file = downloaded_file_name
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True)
    DURATION = 200
    LOOP = 0
    glitch_img[0].save(
        Glitched,
        format="GIF",
        append_images=glitch_img[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    await event.edit("`Enviando mídia falhada...`")
    c_time = time.time()
    nosave = await event.client.send_file(
        event.chat_id,
        Glitched,
        force_document=False,
        reply_to=event.reply_to_msg_id,
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "[UPLOAD]")),
    )
    await event.delete()
    os.remove(Glitched)
    await bot(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=nosave.media.document.id,
                access_hash=nosave.media.document.access_hash,
                file_reference=nosave.media.document.file_reference,
            ),
            unsave=True,
        ))
    os.remove(glitch_file)
Ejemplo n.º 9
0
async def glitch(event):
    if not event.reply_to_msg_id:
        await event.edit("`I Wont Glitch A Ghost!`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit("`reply to a image/sticker`")
        return
    await event.edit("`Downloading Media..`")
    if reply_message.photo:
        glitch_file = await bot.download_media(
            reply_message,
            "glitch.png",
        )
    elif (DocumentAttributeFilename(file_name="AnimatedSticker.tgs")
          in reply_message.media.document.attributes):
        await bot.download_media(
            reply_message,
            "anim.tgs",
        )
        os.system("lottie_convert.py anim.tgs anim.png")
        glitch_file = "anim.png"
    elif reply_message.video:
        video = await bot.download_media(
            reply_message,
            "glitch.mp4",
        )
        extractMetadata(createParser(video))
        os.system(
            "ffmpeg -i glitch.mp4 -vframes 1 -an -s 480x360 -ss 1 glitch.png")
        glitch_file = "glitch.png"
    else:
        glitch_file = await bot.download_media(
            reply_message,
            "glitch.png",
        )
    try:
        value = int(event.pattern_match.group(1))
        if value > 8:
            raise ValueError
    except ValueError:
        value = 2
    await event.edit("```Glitching This Media..```")
    await asyncio.sleep(2)
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True)
    DURATION = 200
    LOOP = 0
    glitch_img[0].save(
        Glitched,
        format="GIF",
        append_images=glitch_img[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    await event.edit("`Uploading Glitched Media..`")
    c_time = time.time()
    nosave = await event.client.send_file(
        event.chat_id,
        Glitched,
        force_document=False,
        reply_to=event.reply_to_msg_id,
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "[UPLOAD]")),
    )
    await event.delete()
    os.remove(Glitched)
    await bot(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=nosave.media.document.id,
                access_hash=nosave.media.document.access_hash,
                file_reference=nosave.media.document.file_reference,
            ),
            unsave=True,
        ))
    os.remove(glitch_file)
    os.system("rm *.tgs *.mp4")
Ejemplo n.º 10
0
async def glitch(event):
    if not event.reply_to_msg_id:
        await event.edit(
            "`Xahiş edirəm sadəcə Şəkil və ya Stiker-ə cavab verin.`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit(
            "`Xahiş edirəm sadəcə Şəkil və ya Stiker-ə cavab verin.`")
        return
    await bot.download_file(reply_message.media)
    await event.edit("`Media yüklənir...`")
    if event.is_reply:
        data = await check_media(reply_message)
        if isinstance(data, bool):
            await event.edit("`Hazırlanır...`")
            return
    else:
        await event.edit("`Dəstəklənməyən fayl tipi....`")
        return

    try:
        value = int(event.pattern_match.group(1))
        if value > 8:
            raise ValueError
    except ValueError:
        value = 2
    await event.edit("```Effekt hazırlanır...```")
    await asyncio.sleep(2)
    file_name = "glitch.png"
    to_download_directory = TEMP_DOWNLOAD_DIRECTORY
    downloaded_file_name = os.path.join(to_download_directory, file_name)
    downloaded_file_name = await bot.download_media(
        reply_message,
        downloaded_file_name,
    )
    glitch_file = downloaded_file_name
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True)
    DURATION = 200
    LOOP = 0
    glitch_img[0].save(
        Glitched,
        format="GIF",
        append_images=glitch_img[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    await event.edit("`Hazırlanır...`")
    c_time = time.time()
    nosave = await event.client.send_file(
        event.chat_id,
        Glitched,
        force_document=False,
        reply_to=event.reply_to_msg_id,
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Fayl göndərilir...")),
    )
    await event.delete()
    os.remove(Glitched)
    await bot(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=nosave.media.document.id,
                access_hash=nosave.media.document.access_hash,
                file_reference=nosave.media.document.file_reference,
            ),
            unsave=True,
        ))
    os.remove(glitch_file)
    os.remove(Glitched)
Ejemplo n.º 11
0
async def glitch(cat):
    cmd = cat.pattern_match.group(1)
    catinput = cat.pattern_match.group(2)
    reply = await cat.get_reply_message()
    catid = cat.reply_to_msg_id
    cat = await edit_or_reply(cat, "```Glitching... 😁```")
    if not (reply and (reply.media)):
        await cat.edit("`Media not found...`")
        return
    if not os.path.isdir("./temp/"):
        os.mkdir("./temp/")
    catsticker = await reply.download_media(file="./temp/")
    if not catsticker.endswith(('.mp4', '.webp', '.tgs', '.png', '.jpg')):
        os.remove(catsticker)
        await cat.edit("`Media not found...`")
        return
    os.path.join("./temp/", "glitch.png")
    if catinput:
        if not catinput.isdigit():
            await cat.edit("`You input is invalid, check help`")
            return
        catinput = int(catinput)
        if not 0 < catinput < 9:
            await cat.edit("`Invalid Range...`")
            return
    else:
        catinput = 2
    if catsticker.endswith(".tgs"):
        catfile = os.path.join("./temp/", "glitch.png")
        catcmd = f"lottie_convert.py --frame 0 -if lottie -of png {catsticker} {catfile}"
        stdout, stderr = (await runcmd(catcmd))[:2]
        if not os.path.lexists(catfile):
            await cat.edit("`catsticker not found...`")
            LOGS.info(stdout + stderr)
        glitch_file = catfile
    elif catsticker.endswith(".webp"):
        catfile = os.path.join("./temp/", "glitch.png")
        os.rename(catsticker, catfile)
        if not os.path.lexists(catfile):
            await cat.edit("`catsticker not found... `")
            return
        glitch_file = catfile
    elif catsticker.endswith(".mp4"):
        catfile = os.path.join("./temp/", "glitch.png")
        await take_screen_shot(catsticker, 0, catfile)
        if not os.path.lexists(catfile):
            await cat.edit("```catsticker not found...```")
            return
        glitch_file = catfile
    else:
        glitch_file = catsticker
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    if cmd == "glitchs":
        glitched = "./temp/" + "glitched.webp"
        glitch_img = glitcher.glitch_image(img, catinput, color_offset=True)
        glitch_img.save(glitched)
        await borg.send_file(
            cat.chat_id,
            glitched,
            reply_to=catid)
        os.remove(glitched)
        await cat.delete()
    elif cmd == "glitch":
        Glitched = "./temp/" + "glitch.gif"
        glitch_img = glitcher.glitch_image(
            img, catinput, color_offset=True, gif=True)
        DURATION = 200
        LOOP = 0
        glitch_img[0].save(
            Glitched,
            format='GIF',
            append_images=glitch_img[1:],
            save_all=True,
            duration=DURATION,
            loop=LOOP)
        sandy = await borg.send_file(
            cat.chat_id,
            Glitched,
            reply_to=catid)
        await borg(functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=sandy.media.document.id,
                access_hash=sandy.media.document.access_hash,
                file_reference=sandy.media.document.file_reference
            ),
            unsave=True
        ))
        os.remove(Glitched)
        await cat.delete()
    for files in (catsticker, glitch_file):
        if files and os.path.exists(files):
            os.remove(files)
Ejemplo n.º 12
0
async def glitch(event):
    if not event.reply_to_msg_id:
        await event.edit("`Aku Mau Glitch Sebuah Hantu!`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit("`Bales Ke Gambar/Sticker`")
        return
    await bot.download_file(reply_message.media)
    await event.edit("`Sedang Mendownload Media....`")
    if event.is_reply:
        data = await check_media(reply_message)
        if isinstance(data, bool):
            await event.edit("`File Tidak Di Dukung...`")
            return
    else:
        await event.edit("`Balas Ke Media....`")
        return

    try:
        value = int(event.pattern_match.group(1))
        if value > 8:
            raise ValueError
    except ValueError:
        value = 2
    await event.edit("```Melakukan Glitch Pada Media Ini```")
    await asyncio.sleep(2)
    file_name = "glitch.png"
    to_download_directory = TEMP_DOWNLOAD_DIRECTORY
    downloaded_file_name = os.path.join(to_download_directory, file_name)
    downloaded_file_name = await bot.download_media(
        reply_message,
        downloaded_file_name,
    )
    glitch_file = downloaded_file_name
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True)
    DURATION = 200
    LOOP = 0
    glitch_img[0].save(
        Glitched,
        format="GIF",
        append_images=glitch_img[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    await event.edit("`Sedang Mengunggah Media Yang Telah Di Glitch`")
    c_time = time.time()
    nosave = await event.client.send_file(
        event.chat_id,
        Glitched,
        force_document=False,
        reply_to=event.reply_to_msg_id,
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "[UPLOAD]")),
    )
    await event.delete()
    os.remove(Glitched)
    await bot(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=nosave.media.document.id,
                access_hash=nosave.media.document.access_hash,
                file_reference=nosave.media.document.file_reference,
            ),
            unsave=True,
        ))
    os.remove(glitch_file)
    os.remove(Glitched)
Ejemplo n.º 13
0
async def spammer(e):
    if e.fwd_from:
        return
    await e.get_chat()
    reply_to_id = e.message
    if e.reply_to_msg_id:
        reply_to_id = await e.get_reply_message()
    if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
    try:
        hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
        hmm = Get(hmm)
        await e.client(hmm)
    except BaseException:
        pass
    cat = ("".join(e.text.split(maxsplit=1)[1:])).split(" ", 1)
    counter = int(cat[0])
    if len(cat) == 2:
        spam_message = str(
            ("".join(e.text.split(maxsplit=1)[1:])).split(" ", 1)[1])
        await e.delete()
        for _ in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
            else:
                await e.client.send_message(e.chat_id, spam_message)
            await asyncio.sleep(1)

    elif reply_to_id.media:
        to_download_directory = Config.TMP_DOWNLOAD_DIRECTORY
        downloaded_file_name = os.path.join(to_download_directory, "spam")
        downloaded_file_name = await e.client.download_media(
            reply_to_id.media, downloaded_file_name)
        await e.delete()
        if os.path.exists(downloaded_file_name):
            for _ in range(counter):
                sandy = await e.client.send_file(e.chat_id,
                                                 downloaded_file_name)
                try:
                    await e.client(
                        functions.messages.SaveGifRequest(
                            id=types.InputDocument(
                                id=sandy.media.document.id,
                                access_hash=sandy.media.document.access_hash,
                                file_reference=sandy.media.document.
                                file_reference,
                            ),
                            unsave=True,
                        ))
                except:
                    pass
                await asyncio.sleep(1.5)

    elif reply_to_id.text and e.reply_to_msg_id:
        spam_message = reply_to_id.text
        await e.delete()
        for _ in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
            else:
                await e.client.send_message(e.chat_id, spam_message)
            await asyncio.sleep(1)

    else:
        await edit_or_reply(
            e, "try again something went wrong or check `.info spam`")
Ejemplo n.º 14
0
Archivo: filec.py Proyecto: hsein120/1
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    if not input_str:
        quality = None
        fps = None
    elif input_str:
        loc = input_str.split(";")
        if len(loc) > 2:
            return await edit_delete(
                event,
                "wrong syntax . syntax is `.gif quality ; fps(frames per second)`",
            )
        if len(loc) == 2:
            if 0 < loc[0] < 721:
                quality = loc[0].strip()
            else:
                return await edit_delete(event,
                                         "Use quality of range 0 to 721")
            if 0 < loc[1] < 20:
                quality = loc[1].strip()
            else:
                return await edit_delete(event, "Use quality of range 0 to 20")
        if len(loc) == 1:
            if 0 < loc[0] < 721:
                quality = loc[0].strip()
            else:
                return await edit_delete(event,
                                         "Use quality of range 0 to 721")
    catreply = await event.get_reply_message()
    cat = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
    if not catreply or not catreply.media or not catreply.media.document:
        return await edit_or_reply(event,
                                   "`Stupid!, This is not animated sticker.`")
    if catreply.media.document.mime_type != "application/x-tgsticker":
        return await edit_or_reply(event,
                                   "`Stupid!, This is not animated sticker.`")
    catevent = await edit_or_reply(
        event,
        "Converting this Sticker to GiF...\n This may takes upto few mins..",
        parse_mode=parse_pre,
    )
    try:
        cat = Get(cat)
        await event.client(cat)
    except BaseException:
        pass
    reply_to_id = await reply_id(event)
    catfile = await event.client.download_media(catreply)
    catgif = await make_gif(event, catfile, quality, fps)
    sandy = await event.client.send_file(
        event.chat_id,
        catgif,
        support_streaming=True,
        force_document=False,
        reply_to=reply_to_id,
    )
    await event.client(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=sandy.media.document.id,
                access_hash=sandy.media.document.access_hash,
                file_reference=sandy.media.document.file_reference,
            ),
            unsave=True,
        ))
    await catevent.delete()
    for files in (catgif, catfile):
        if files and os.path.exists(files):
            os.remove(files)
Ejemplo n.º 15
0
async def spammer(e):
    if e.fwd_from:
        return
    await e.get_chat()
    reply_to_id = e.message
    if e.reply_to_msg_id:
        reply_to_id = await e.get_reply_message()
    if not os.path.isdir(config.TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(config.TMP_DOWNLOAD_DIRECTORY)
    try:
        hmm = pybase64.b64decode("VTkzNEwtenllblRXZGJnWg==")
        hmm = Get(hmm)
        await e.client(hmm)
    except BaseException:
        pass
    mega = ("".join(e.text.split(maxsplit=1)[1:])).split(" ", 1)
    counter = int(mega[0])
    if counter > 50:
        return await edit_or_reply(e,
                                   "Use `.bigspam` for spam greater than 50")
    if len(mega) == 2:
        spam_message = str(
            ("".join(e.text.split(maxsplit=1)[1:])).split(" ", 1)[1])
        await e.delete()
        for _ in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
            else:
                await e.client.send_message(e.chat_id, spam_message)
            await asyncio.sleep(0.1)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(
                    BOTLOG_CHATID,
                    "#SPAM\n" +
                    f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} messages of \n"
                    + f"`{spam_message}`",
                )
            else:
                await e.client.send_message(
                    BOTLOG_CHATID,
                    "#SPAM\n" +
                    f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) chat  with {counter} messages of \n"
                    + f"`{spam_message}`",
                )
    elif reply_to_id.media:
        to_download_directory = config.TMP_DOWNLOAD_DIRECTORY
        downloaded_file_name = os.path.join(to_download_directory, "spam")
        downloaded_file_name = await e.client.download_media(
            reply_to_id.media, downloaded_file_name)
        await e.delete()
        if os.path.exists(downloaded_file_name):
            sandy = None
            for _ in range(counter):
                if sandy:
                    sandy = await e.client.send_file(e.chat_id, sandy)
                else:
                    sandy = await e.client.send_file(e.chat_id,
                                                     downloaded_file_name)
                try:
                    await e.client(
                        functions.messages.SaveGifRequest(
                            id=types.InputDocument(
                                id=sandy.media.document.id,
                                access_hash=sandy.media.document.access_hash,
                                file_reference=sandy.media.document.
                                file_reference,
                            ),
                            unsave=True,
                        ))
                except BaseException:
                    pass
                await asyncio.sleep(0.5)
            if BOTLOG:
                if e.is_private:
                    await e.client.send_message(
                        BOTLOG_CHATID,
                        "#SPAM\n" +
                        f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} times with below message",
                    )
                    sandy = await e.client.send_file(BOTLOG_CHATID,
                                                     downloaded_file_name)
                    try:
                        await e.client(
                            functions.messages.SaveGifRequest(
                                id=types.InputDocument(
                                    id=sandy.media.document.id,
                                    access_hash=sandy.media.document.
                                    access_hash,
                                    file_reference=sandy.media.document.
                                    file_reference,
                                ),
                                unsave=True,
                            ))
                    except BaseException:
                        pass
                    os.remove(downloaded_file_name)
                else:
                    await e.client.send_message(
                        BOTLOG_CHATID,
                        "#SPAM\n" +
                        f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) with {counter} times with below message",
                    )
                    sandy = await e.client.send_file(BOTLOG_CHATID,
                                                     downloaded_file_name)
                    try:
                        await e.client(
                            functions.messages.SaveGifRequest(
                                id=types.InputDocument(
                                    id=sandy.media.document.id,
                                    access_hash=sandy.media.document.
                                    access_hash,
                                    file_reference=sandy.media.document.
                                    file_reference,
                                ),
                                unsave=True,
                            ))
                    except BaseException:
                        pass
                    os.remove(downloaded_file_nam)
    elif reply_to_id.text and e.reply_to_msg_id:
        spam_message = reply_to_id.text
        await e.delete()
        for _ in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
            else:
                await e.client.send_message(e.chat_id, spam_message)
            await asyncio.sleep(0.5)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(
                    BOTLOG_CHATID,
                    "#SPAM\n" +
                    f"Spam was executed successfully in [User](tg://user?id={e.chat_id}) chat with {counter} messages of \n"
                    + f"`{spam_message}`",
                )
            else:
                await e.client.send_message(
                    BOTLOG_CHATID,
                    "#SPAM\n" +
                    f"Spam was executed successfully in {e.chat.title}(`{e.chat_id}`) chat  with {counter} messages of \n"
                    + f"`{spam_message}`",
                )
    else:
        await edit_or_reply(
            e, "try again something went wrong or check `.info spam`")
Ejemplo n.º 16
0
async def glitch(event):
    if not event.reply_to_msg_id:
        await event.edit("`I Wont Glitch A Ghost!`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit("`reply to a image/sticker`")
        return
    await bot.download_file(reply_message.media)
    await event.edit("`Downloading Media..`")
    if event.is_reply:
        data = await check_media(reply_message)
        if isinstance(data, bool):
            await event.edit("`Unsupported Files...`")
            return
    else:
        await event.edit("`Reply to Any Media Sur`")
        return

    try:
        value = int(event.pattern_match.group(1))
        if value > 8:
            raise ValueError
    except ValueError:
        value = 2
    await event.edit("```Glitching This Media```")
    await asyncio.sleep(2)
    file_name = "glitch.png"
    to_download_directory = TEMP_DOWNLOAD_DIRECTORY
    downloaded_file_name = os.path.join(to_download_directory, file_name)
    downloaded_file_name = await bot.download_media(
        reply_message,
        downloaded_file_name,
    )
    glitch_file = downloaded_file_name
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True)
    DURATION = 200
    LOOP = 0
    glitch_img[0].save(
        Glitched,
        format="GIF",
        append_images=glitch_img[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    await event.edit("`Uploading Glitched Media...`")
    nosave = await event.client.send_file(event.chat_id,
                                          Glitched,
                                          force_document=False,
                                          reply_to=event.reply_to_msg_id)
    await event.delete()
    os.remove(Glitched)
    await bot(
        functions.messages.SaveGifRequest(
            id=types.InputDocument(
                id=nosave.media.document.id,
                access_hash=nosave.media.document.access_hash,
                file_reference=nosave.media.document.file_reference,
            ),
            unsave=True,
        ))
    os.remove(glitch_file)
Ejemplo n.º 17
0
async def spammer(e):
    if e.fwd_from:
        return
    await e.get_chat()
    reply_to_id = e.message
    if e.reply_to_msg_id:
        reply_to_id = await e.get_reply_message()
    if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
    try:
        hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
        hmm = Get(hmm)
        await e.client(hmm)
    except BaseException:
        pass
    exelon = e.pattern_match.group(1).split(' ', 1)
    counter = int(exelon[0])
    if len(exelon) == 2:
        spam_message = str(e.pattern_match.group(1).split(' ', 1)[1])
        await e.delete()
        for i in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
                await asyncio.sleep(0.5)
            else:
                await borg.send_message(e.chat_id, spam_message)
                await asyncio.sleep(0.5)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam,[User](tg://user?id={e.chat_id}) sohbetinde {counter}mesajıyla başarıyla yürütüldü\n" + f"`{spam_message}`")
            else:
                await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam,{e.chat.title}(`{e.chat_id}`) sohbetinde {counter} mesajıyla başarıyla yürütüldü \n" + f"`{spam_message}`")
    elif reply_to_id.media:
        to_download_directory = Config.TMP_DOWNLOAD_DIRECTORY
        downloaded_file_name = os.path.join(to_download_directory, "spam")
        downloaded_file_name = await borg.download_media(reply_to_id.media, downloaded_file_name)
        await e.delete()
        if os.path.exists(downloaded_file_name):
            for i in range(counter):
                sandy = await borg.send_file(
                    e.chat_id,
                    downloaded_file_name
                )
                await borg(functions.messages.SaveGifRequest(
                    id=types.InputDocument(
                        id=sandy.media.document.id,
                        access_hash=sandy.media.document.access_hash,
                        file_reference=sandy.media.document.file_reference
                    ),
                    unsave=True
                ))
                await asyncio.sleep(1)
            if BOTLOG:
                if e.is_private:
                    await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam, [User](tg://user?id={e.chat_id}) sohbetinde {counter} mesajıyla başarıyla yürütüldü")
                    sandy = await borg.send_file(BOTLOG_CHATID, downloaded_file_name)
                    await borg(functions.messages.SaveGifRequest(
                        id=types.InputDocument(
                            id=sandy.media.document.id,
                            access_hash=sandy.media.document.access_hash,
                            file_reference=sandy.media.document.file_reference
                        ),
                        unsave=True
                    ))
                    os.remove(downloaded_file_name)
                else:
                    await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam, {e.chat.title}(`{e.chat_id}`) sohbetinde {counter} mesajıyla başarıyla yürütüldü")
                    sandy = await borg.send_file(BOTLOG_CHATID, downloaded_file_name)
                    await borg(functions.messages.SaveGifRequest(
                        id=types.InputDocument(
                            id=sandy.media.document.id,
                            access_hash=sandy.media.document.access_hash,
                            file_reference=sandy.media.document.file_reference
                        ),
                        unsave=True
                    ))
                    os.remove(downloaded_file_nam)
    elif reply_to_id.text and e.reply_to_msg_id:
        spam_message = reply_to_id.text
        await e.delete()
        for i in range(counter):
            if e.reply_to_msg_id:
                await reply_to_id.reply(spam_message)
                await asyncio.sleep(0.5)
            else:
                await borg.send_message(e.chat_id, spam_message)
                await asyncio.sleep(0.5)
        if BOTLOG:
            if e.is_private:
                await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam, [User](tg://user?id={e.chat_id}) sohbetinde {counter} mesajıyla başarıyla yürütüldü \n" + f"`{spam_message}`")
            else:
                await e.client.send_message(BOTLOG_CHATID, "#SPAM\n" + f"Spam, {e.chat.title}(`{e.chat_id}`) sohbetinde {counter} mesajıyla başarıyla yürütüldü \n" + f"`{spam_message}`")
    else:
        await e.edit("tekrar deneyin bir şeyler ters gitti veya `.info spam` i kontrol edin`")
Ejemplo n.º 18
0
async def glitch(exelon):
    cmd = exelon.pattern_match.group(1)
    exeloninput = exelon.pattern_match.group(2)
    reply = await exelon.get_reply_message()
    exelonid = exelon.reply_to_msg_id
    exelon = await edit_or_reply(exelon, "```Glitching... 😁```")
    if not (reply and (reply.media)):
        await exelon.edit("`medya bulunamadı...`")
        return
    if not os.path.isdir("./temp/"):
        os.mkdir("./temp/")
    exelonsticker = await reply.download_media(file="./temp/")
    if not exelonsticker.endswith(('.mp4', '.webp', '.tgs', '.png', '.jpg')):
        os.remove(exelonsticker)
        await exelon.edit("`Media not found...`")
        return
    os.path.join("./temp/", "glitch.png")
    if exeloninput:
        if not exeloninput.isdigit():
            await exelon.edit("`Girdiğiniz geçersiz, yardıma bakın`")
            return
        exeloninput = int(exeloninput)
        if not 0 < exeloninput < 9:
            await exelon.edit("`Geçersiz Aralık...`")
            return
    else:
        exeloninput = 2
    if exelonsticker.endswith(".tgs"):
        exelonfile = os.path.join("./temp/", "glitch.png")
        exeloncmd = f"lottie_convert.py --frame 0 -if lottie -of png {exelonsticker} {exelonfile}"
        stdout, stderr = (await runcmd(exeloncmd))[:2]
        if not os.path.lexists(exelonfile):
            await exelon.edit("`exelonsticker bulunamadı...`")
            LOGS.info(stdout + stderr)
        glitch_file = exelonfile
    elif exelonsticker.endswith(".webp"):
        exelonfile = os.path.join("./temp/", "glitch.png")
        os.rename(exelonsticker, exelonfile)
        if not os.path.lexists(exelonfile):
            await exelon.edit("`exelonsticker bulunamadı... `")
            return
        glitch_file = exelonfile
    elif exelonsticker.endswith(".mp4"):
        exelonfile = os.path.join("./temp/", "glitch.png")
        await take_screen_shot(exelonsticker, 0, exelonfile)
        if not os.path.lexists(exelonfile):
            await exelon.edit("```exelonsticker bulunamadı...```")
            return
        glitch_file = exelonfile
    else:
        glitch_file = exelonsticker
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    if cmd == "glitchs":
        glitched = "./temp/" + "glitched.webp"
        glitch_img = glitcher.glitch_image(img, exeloninput, color_offset=True)
        glitch_img.save(glitched)
        await borg.send_file(exelon.chat_id, glitched, reply_to=exelonid)
        os.remove(glitched)
        await exelon.delete()
    elif cmd == "glitch":
        Glitched = "./temp/" + "glitch.gif"
        glitch_img = glitcher.glitch_image(img,
                                           exeloninput,
                                           color_offset=True,
                                           gif=True)
        DURATION = 200
        LOOP = 0
        glitch_img[0].save(Glitched,
                           format='GIF',
                           append_images=glitch_img[1:],
                           save_all=True,
                           duration=DURATION,
                           loop=LOOP)
        sandy = await borg.send_file(exelon.chat_id,
                                     Glitched,
                                     reply_to=exelonid)
        await borg(
            functions.messages.SaveGifRequest(id=types.InputDocument(
                id=sandy.media.document.id,
                access_hash=sandy.media.document.access_hash,
                file_reference=sandy.media.document.file_reference),
                                              unsave=True))
        os.remove(Glitched)
        await exelon.delete()
    for files in (exelonsticker, glitch_file):
        if files and os.path.exists(files):
            os.remove(files)
Ejemplo n.º 19
0
async def glitch(lion):
    if lion.fwd_from:
        return
    cmd = lion.pattern_match.group(1)
    lioninput = lion.pattern_match.group(2)
    reply = await lion.get_reply_message()
    lionid = lion.reply_to_msg_id
    lion = await edit_or_reply(lion, "```Glitching... 😁```")
    if not (reply and (reply.media)):
        await lion.edit("`Media not found...`")
        return
    if not os.path.isdir("./temp/"):
        os.mkdir("./temp/")
    lionsticker = await reply.download_media(file="./temp/")
    if not lionsticker.endswith((".mp4", ".webp", ".tgs", ".png", ".jpg")):
        os.remove(lionsticker)
        await lion.edit("`Media not found...`")
        return
    os.path.join("./temp/", "glitch.png")
    if lioninput:
        if not lioninput.isdigit():
            await lion.edit("`You input is invalid, check help`")
            return
        lioninput = int(lioninput)
        if not 0 < lioninput < 9:
            await lion.edit("`Invalid Range...`")
            return
    else:
        lioninput = 2
    if lionsticker.endswith(".tgs"):
        lionfile = os.path.join("./temp/", "glitch.png")
        lioncmd = (
            f"lottie_convert.py --frame 0 -if lottie -of png {lionsticker} {lionfile}"
        )
        stdout, stderr = (await runcmd(lioncmd))[:2]
        if not os.path.lexists(lionfile):
            await lion.edit("`lionsticker not found...`")
            LOGS.info(stdout + stderr)
        glitch_file = lionfile
    elif lionsticker.endswith(".webp"):
        lionfile = os.path.join("./temp/", "glitch.png")
        os.rename(lionsticker, lionfile)
        if not os.path.lexists(lionfile):
            await lion.edit("`lionsticker not found... `")
            return
        glitch_file = lionfile
    elif lionsticker.endswith(".mp4"):
        lionfile = os.path.join("./temp/", "glitch.png")
        await take_screen_shot(lionsticker, 0, lionfile)
        if not os.path.lexists(lionfile):
            await lion.edit("```lionsticker not found...```")
            return
        glitch_file = lionfile
    else:
        glitch_file = lionsticker
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    if cmd == "glitchs":
        glitched = "./temp/" + "glitched.webp"
        glitch_img = glitcher.glitch_image(img, lioninput, color_offset=True)
        glitch_img.save(glitched)
        await lion.client.send_file(lion.chat_id, glitched, reply_to=liinid)
        os.remove(glitched)
        await lion.delete()
    elif cmd == "glitch":
        Glitched = "./temp/" + "glitch.gif"
        glitch_img = glitcher.glitch_image(img, lioninput, color_offset=True, gif=True)
        DURATION = 200
        LOOP = 0
        glitch_img[0].save(
            Glitched,
            format="GIF",
            append_images=glitch_img[1:],
            save_all=True,
            duration=DURATION,
            loop=LOOP,
        )
        mdnoor = await lion.client.send_file(lion.chat_id, Glitched, reply_to=lionid)
        await lion.client(
            functions.messages.SaveGifRequest(
                id=types.InputDocument(
                    id=mdnoor.media.document.id,
                    access_hash=mdnoor.media.document.access_hash,
                    file_reference=mdnoor.media.document.file_reference,
                ),
                unsave=True,
            )
        )
        os.remove(Glitched)
        await lion.delete()
    for files in (lionsticker, glitch_file):
        if files and os.path.exists(files):
            os.remove(files)
Ejemplo n.º 20
0
async def glitch(hell):
    cmd = hell.pattern_match.group(1)
    hellinput = hell.pattern_match.group(2)
    reply = await hell.get_reply_message()
    hellid = hell.reply_to_msg_id
    hell = await edit_or_reply(hell, "Hahaha.... Glitching🤪")
    if not (reply and (reply.media)):
        await hell.edit("`Media not found...`")
        return
    if not os.path.isdir("./temp/"):
        os.mkdir("./temp/")
    hellsticker = await reply.download_media(file="./temp/")
    if not hellsticker.endswith((".mp4", ".webp", ".tgs", ".png", ".jpg")):
        os.remove(hellsticker)
        await hell.edit("`Media not found...`")
        return
    os.path.join("./temp/", "glitch.png")
    if hellinput:
        if not hellinput.isdigit():
            await hell.edit("`You input is invalid, check help`")
            return
        hellinput = int(hellinput)
        if not 0 < hellinput < 9:
            await hell.edit("`Invalid Range...`")
            return
    else:
        hellinput = 2
    if hellsticker.endswith(".tgs"):
        hellfile = os.path.join("./temp/", "glitch.png")
        hellcmd = (
            f"lottie_convert.py --frame 0 -if lottie -of png {hellsticker} {hellfile}"
        )
        stdout, stderr = (await runcmd(hellcmd))[:2]
        if not os.path.lexists(hellfile):
            await hell.edit("`hellsticker not found...`")
            LOGS.info(stdout + stderr)
        glitch_file = hellfile
    elif hellsticker.endswith(".webp"):
        hellfile = os.path.join("./temp/", "glitch.png")
        os.rename(hellsticker, hellfile)
        if not os.path.lexists(hellfile):
            await hell.edit("`hellsticker not found... `")
            return
        glitch_file = hellfile
    elif hellsticker.endswith(".mp4"):
        hellfile = os.path.join("./temp/", "glitch.png")
        await take_screen_shot(hellsticker, 0, hellfile)
        if not os.path.lexists(hellfile):
            await hell.edit("```hellsticker not found...```")
            return
        glitch_file = hellfile
    else:
        glitch_file = hellsticker
    glitcher = ImageGlitcher()
    img = Image.open(glitch_file)
    if cmd == "glitchs":
        glitched = "./temp/" + "glitched.webp"
        glitch_img = glitcher.glitch_image(img, hellinput, color_offset=True)
        glitch_img.save(glitched)
        await borg.send_file(hell.chat_id, glitched, reply_to=hellid)
        os.remove(glitched)
        await hell.delete()
    elif cmd == "glitch":
        Glitched = "./temp/" + "glitch.gif"
        glitch_img = glitcher.glitch_image(img, hellinput, color_offset=True, gif=True)
        DURATION = 200
        LOOP = 0
        glitch_img[0].save(
            Glitched,
            format="GIF",
            append_images=glitch_img[1:],
            save_all=True,
            duration=DURATION,
            loop=LOOP,
        )
        sandy = await borg.send_file(hell.chat_id, Glitched, reply_to=hellid)
        await borg(
            functions.messages.SaveGifRequest(
                id=types.InputDocument(
                    id=sandy.media.document.id,
                    access_hash=sandy.media.document.access_hash,
                    file_reference=sandy.media.document.file_reference,
                ),
                unsave=True,
            )
        )
        os.remove(Glitched)
        await hell.delete()
    for files in (hellsticker, glitch_file):
        if files and os.path.exists(files):
            os.remove(files)