Пример #1
0
async def packinfo(client, message):
    pablo = await edit_or_reply(message, "`Processing...`")
    if not message.reply_to_message:
        await pablo.edit("Please Reply To Sticker...")
        return
    Hell = get_text(message)
    name = ""
    pack = 1
    nm = message.from_user.username
    if nm:
        nam = message.from_user.username
        name = nam[1:]
    else:
        name = message.from_user.first_name
    packname = f"@{nm} Kang Pack {pack}"
    packshortname = f"WHITEDEVIL_{message.from_user.id}_{pack}"
    non = [None, "None"]
    emoji = "😁"
    try:
        Hell = Hell.strip()
        if not Hell.isalpha():
            if not Hell.isnumeric():
                emoji = Hell
        else:
            emoji = "😁"
    except:
        emoji = "😁"
    exist = None
    is_anim = False
    if message.reply_to_message.sticker:
        if not Hell:
            emoji = message.reply_to_message.sticker.emoji or "😁"
        is_anim = message.reply_to_message.sticker.is_animated
        if is_anim:
            packshortname += "_animated"
            packname += " Animated"
        if message.reply_to_message.sticker.mime_type == "application/x-tgsticker":
            file_name = await message.reply_to_message.download(
                "AnimatedSticker.tgs")
        else:
            cool = await convert_to_image(message, client)
            if not cool:
                await pablo.edit("`Reply to a valid media first.`")
                return
            file_name = resize_image(cool)
    elif message.reply_to_message.document:
        if message.reply_to_message.document.mime_type == "application/x-tgsticker":
            is_anim = True
            packshortname += "_animated"
            packname += " Animated"
            file_name = await message.reply_to_message.download(
                "AnimatedSticker.tgs")
    else:
        cool = await convert_to_image(message, client)
        if not cool:
            await pablo.edit("`Reply to a valid media first.`")
            return
        file_name = resize_image(cool)
    try:
        exist = await client.send(
            GetStickerSet(stickerset=InputStickerSetShortName(
                short_name=packshortname)))
    except StickersetInvalid:
        pass
    if exist:
        try:
            await client.send_message("stickers", "/addsticker")
        except YouBlockedUser:
            await pablo.edit("`Please Unblock @Stickers`")
            return
        await client.send_message("stickers", packshortname)
        await asyncio.sleep(0.2)
        limit = "50" if is_anim else "120"
        messi = (await client.get_history("stickers", 1))[0]
        while limit in messi.text:
            pack += 1
            packname = f"@{nm} Kang Pack {pack}"
            packshortname = f"FRIDAY_{message.from_user.id}_{pack}"
            if is_anim:
                packshortname += "_animated"
                packname += " Animated"
            await client.send_message("stickers", packshortname)
            await asyncio.sleep(0.2)
            messi = (await client.get_history("stickers", 1))[0]
            if messi.text == "Invalid pack selected.":
                if is_anim:
                    await client.send_message("stickers", "/newanimated")
                else:
                    await client.send_message("stickers", "/newpack")
                await asyncio.sleep(0.5)
                await client.send_message("stickers", packname)
                await asyncio.sleep(0.2)
                await client.send_document("stickers", file_name)
                await asyncio.sleep(1)
                await client.send_message("stickers", emoji)
                await asyncio.sleep(0.5)
                await client.send_message("stickers", "/publish")
                if is_anim:
                    await client.send_message("stickers", f"<{packname}>")
                await client.send_message("stickers", "/skip")
                await asyncio.sleep(0.5)
                await client.send_message("stickers", packshortname)
                await pablo.edit(
                    f"Sticker Added To Your Pack. You Can Find It [Here](https://t.me/addstickers/{packshortname})"
                )
                return
        await client.send_document("stickers", file_name)
        await asyncio.sleep(1)
        await client.send_message("stickers", emoji)
        await asyncio.sleep(0.5)
        await client.send_message("stickers", "/done")
        await pablo.edit(
            f"`Sticker Added To Your Pack. You Can Find It` [Here](https://t.me/addstickers/{packshortname})"
        )
    else:
        if is_anim:
            await client.send_message("stickers", "/newanimated")
        else:
            await client.send_message("stickers", "/newpack")
        await client.send_message("stickers", packname)
        await asyncio.sleep(0.2)
        await client.send_document("stickers", file_name)
        await asyncio.sleep(1)
        await client.send_message("stickers", emoji)
        await asyncio.sleep(0.5)
        await client.send_message("stickers", "/publish")
        await asyncio.sleep(0.5)
        if is_anim:
            await client.send_message("stickers", f"<{packname}>")
        await client.send_message("stickers", "/skip")
        await asyncio.sleep(0.5)
        await client.send_message("stickers", packshortname)
        await pablo.edit(
            f"`Sticker Added To Your Pack. You Can Find It` [Here](https://t.me/addstickers/{packshortname})"
        )
        if os.path.exists(file_name):
            os.remove(file_name)
Пример #2
0
async def kang_(message: Message):
    """ kang a sticker """
    user = await userge.get_me()
    replied = message.reply_to_message
    photo = None
    _emoji = None
    emoji_ = ""
    is_anim = False
    resize = False
    if replied and replied.media:
        if replied.photo:
            resize = True
        elif replied.document and "image" in replied.document.mime_type:
            resize = True
        elif replied.document and "tgsticker" in replied.document.mime_type:
            is_anim = True
        elif replied.sticker:
            if not replied.sticker.file_name:
                await message.edit("`Sticker has no Name!`")
                return
            emoji_ = replied.sticker.emoji
            is_anim = replied.sticker.is_animated
            if not replied.sticker.file_name.endswith('.tgs'):
                resize = True
        else:
            await message.edit("`Unsupported File!`")
            return
        await message.edit(f"`{random.choice(KANGING_STR)}`")
        photo = await userge.download_media(message=replied,
                                            file_name=Config.DOWN_PATH)
    else:
        await message.edit("`I can't kang that...`")
        return
    if photo:
        args = message.filtered_input_str.split(' ')
        pack = 1
        if len(args) == 2:
            _emoji, pack = args
        elif len(args) == 1:
            if args[0].isnumeric():
                pack = int(args[0])
            else:
                _emoji = args[0]

        if _emoji is not None:
            for k in _emoji:
                if k and k in (
                    getattr(emoji, a) for a in dir(emoji) if not a.startswith("_")
                ):
                    emoji_ += k
        if not emoji_:
            emoji_ = "🤔"

        u_name = user.username
        if u_name:
            u_name = "@" + u_name
        else:
            u_name = user.first_name or user.id
        packname = f"a{user.id}_by_userge_{pack}"
        custom_packnick = Config.CUSTOM_PACK_NAME or f"{u_name}'s kang pack"
        packnick = f"{custom_packnick} Vol.{pack}"
        cmd = '/newpack'
        if resize:
            photo = resize_photo(photo)
        if is_anim:
            packname += "_anim"
            packnick += " (Animated)"
            cmd = '/newanimated'
        exist = False
        try:
            exist = await message.client.send(
                GetStickerSet(
                    stickerset=InputStickerSetShortName(
                        short_name=packname)))
        except StickersetInvalid:
            pass
        if exist is not False:
            async with userge.conversation('Stickers', limit=30) as conv:
                try:
                    await conv.send_message('/addsticker')
                except YouBlockedUser:
                    await message.edit('first **unblock** @Stickers')
                    return
                await conv.get_response(mark_read=True)
                await conv.send_message(packname)
                msg = await conv.get_response(mark_read=True)
                limit = "50" if is_anim else "120"
                while limit in msg.text:
                    pack += 1
                    packname = f"a{user.id}_by_userge_{pack}"
                    packnick = f"{custom_packnick} Vol.{pack}"
                    if is_anim:
                        packname += "_anim"
                        packnick += " (Animated)"
                    await message.edit("`Switching to Pack " + str(pack) +
                                       " due to insufficient space`")
                    await conv.send_message(packname)
                    msg = await conv.get_response(mark_read=True)
                    if msg.text == "Invalid pack selected.":
                        await conv.send_message(cmd)
                        await conv.get_response(mark_read=True)
                        await conv.send_message(packnick)
                        await conv.get_response(mark_read=True)
                        await conv.send_document(photo)
                        await conv.get_response(mark_read=True)
                        await conv.send_message(emoji_)
                        await conv.get_response(mark_read=True)
                        await conv.send_message("/publish")
                        if is_anim:
                            await conv.get_response(mark_read=True)
                            await conv.send_message(f"<{packnick}>", parse_mode=None)
                        await conv.get_response(mark_read=True)
                        await conv.send_message("/skip")
                        await conv.get_response(mark_read=True)
                        await conv.send_message(packname)
                        await conv.get_response(mark_read=True)
                        if '-d' in message.flags:
                            await message.delete()
                        else:
                            out = "__kanged__" if '-s' in message.flags else \
                                f"[kanged](t.me/addstickers/{packname})"
                            await message.edit(f"**Sticker** {out} __in a Different Pack__**!**")
                        return
                await conv.send_document(photo)
                rsp = await conv.get_response(mark_read=True)
                if "Sorry, the file type is invalid." in rsp.text:
                    await message.edit("`Failed to add sticker, use` @Stickers "
                                       "`bot to add the sticker manually.`")
                    return
                await conv.send_message(emoji_)
                await conv.get_response(mark_read=True)
                await conv.send_message('/done')
                await conv.get_response(mark_read=True)
        else:
            await message.edit("`Brewing a new Pack...`")
            async with userge.conversation('Stickers') as conv:
                try:
                    await conv.send_message(cmd)
                except YouBlockedUser:
                    await message.edit('first **unblock** @Stickers')
                    return
                await conv.get_response(mark_read=True)
                await conv.send_message(packnick)
                await conv.get_response(mark_read=True)
                await conv.send_document(photo)
                rsp = await conv.get_response(mark_read=True)
                if "Sorry, the file type is invalid." in rsp.text:
                    await message.edit("`Failed to add sticker, use` @Stickers "
                                       "`bot to add the sticker manually.`")
                    return
                await conv.send_message(emoji_)
                await conv.get_response(mark_read=True)
                await conv.send_message("/publish")
                if is_anim:
                    await conv.get_response(mark_read=True)
                    await conv.send_message(f"<{packnick}>", parse_mode=None)
                await conv.get_response(mark_read=True)
                await conv.send_message("/skip")
                await conv.get_response(mark_read=True)
                await conv.send_message(packname)
                await conv.get_response(mark_read=True)
        if '-d' in message.flags:
            await message.delete()
        else:
            out = "__kanged__" if '-s' in message.flags else \
                f"[kanged](t.me/addstickers/{packname})"
            await message.edit(f"**Sticker** {out}**!**")
        if os.path.exists(str(photo)):
            os.remove(photo)
Пример #3
0
async def packinfo(client, message):
    pablo = await edit_or_reply(message, "`Caricamento...`")
    if not message.reply_to_message:
        await pablo.edit("COGLIONE rispondi a uno sticker...")
        return
    Hell = get_text(message)
    name = ""
    pack = 1
    nm = message.from_user.username
    if nm:
        nam = message.from_user.username
        name = nam[1:]
    else:
        name = message.from_user.first_name
    packname = f"Pacchetto di @{nm} Numero {pack}"
    packshortname = f"Pacchetto_{message.from_user.id}_{pack}"
    non = [None, "None"]
    
    try:
       Hell = Hell.strip()
       if not Hell.isalpha():
         if not Hell.isnumeric():
           emoji = Hell
       else:
         emoji = "😁"
    except:
        emoji = "😁"
    exist = None
    is_anim = False
    if message.reply_to_message.sticker:
        if not Hell:
            emoji = message.reply_to_message.sticker.emoji
        is_anim = message.reply_to_message.sticker.is_animated
        if is_anim:
            packshortname +="_animated"
            packname += " Animated"
        if message.reply_to_message.sticker.mime_type == "application/x-tgsticker":
            file_name = await message.reply_to_message.download("AnimatedSticker.tgs")
        else:
            cool = await convert_to_image(message, client)
            if not cool:
               await pablo.edit("`COGLIONE, media non valido.`")
               return
            file_name = resize_image(cool)
    elif message.reply_to_message.document:
        if message.reply_to_message.document.mime_type == "application/x-tgsticker":
            is_anim = True
            packshortname +="_animated"
            packname += " Animated"
            file_name = await message.reply_to_message.download("AnimatedSticker.tgs")
    else:
        cool = await convert_to_image(message, client)
        if not cool:
            await pablo.edit("`COGLIONE, media non valido.`")
            return
        file_name = resize_image(cool)
    try:
            exist = await client.send(
                GetStickerSet(
                    stickerset=InputStickerSetShortName(
                        short_name=packshortname)))
    except StickersetInvalid:
            pass
    if exist:
        try:
            await client.send_message("stickers", "/addsticker")
        except YouBlockedUser:
            await pablo.edit("`RITARDATO perchè hai bloccato @Stickers`")
            return
        await client.send_message("stickers", packshortname)
        await asyncio.sleep(0.2)
        limit = "50" if is_anim else "120"
        messi = (await client.get_history("stickers", 1))[0]
        while limit in messi.text:
            pack += 1
            packname = f"Pacchetto di @{nm} Numero {pack}"
            packshortname = f"pacchetto_{message.from_user.id}_{pack}"
            if is_anim:
                packshortname +="_animated"
                packname += " Animated"
            await client.send_message("stickers", packshortname)
            await asyncio.sleep(0.2)
            messi = (await client.get_history("stickers", 1))[0]
            if messi.text == "Invalid pack selected.":
                if is_anim:
                    await client.send_message("stickers", "/newanimated")
                else:
                    await client.send_message("stickers", "/newpack")
                await asyncio.sleep(0.5)
                await client.send_message("stickers", packname)
                await asyncio.sleep(0.2)
                await client.send_document("stickers", file_name)
                await asyncio.sleep(1)
                await client.send_message("stickers", emoji)
                await asyncio.sleep(0.5)
                await client.send_message("stickers", "/publish")
                if is_anim:
                   await client.send_message("stickers", f"<{packname}>")
                await client.send_message("stickers", "/skip")
                await asyncio.sleep(0.5)
                await client.send_message("stickers", packshortname)
                await pablo.edit(f"UE, sticker aggiunto, disponibile [QUI](https://t.me/addstickers/{packshortname})")
                return
        await client.send_document("stickers", file_name)
        await asyncio.sleep(1)
        await client.send_message("stickers", emoji)
        await asyncio.sleep(0.5)
        await client.send_message("stickers", "/done")
        await pablo.edit(f"UE, sticker aggiunto, disponibile [QUI](https://t.me/addstickers/{packshortname})")
    else:
            if is_anim:
                await client.send_message("stickers", "/newanimated")
            else:
                await client.send_message("stickers", "/newpack")
            await client.send_message("stickers", packname)
            await asyncio.sleep(0.2)
            await client.send_document("stickers", file_name)
            await asyncio.sleep(1)
            await client.send_message("stickers", emoji)
            await asyncio.sleep(0.5)
            await client.send_message("stickers", "/publish")
            await asyncio.sleep(0.5)
            if is_anim:
                   await client.send_message("stickers", f"<{packname}>")
            await client.send_message("stickers", "/skip")
            await asyncio.sleep(0.5)
            await client.send_message("stickers", packshortname)
            await pablo.edit(f"UE, sticker aggiunto, disponibile [QUI](https://t.me/addstickers/{packshortname})")
            if os.path.exists(file_name):
                os.remove(file_name)
Пример #4
0
async def kang_(message: Message):
    """ kang a sticker """
    replied = message.reply_to_message
    if not replied or not replied.media:
        return await message.err("`I can't kang that...`")

    emoji_ = ""
    is_anim = False
    is_video = False
    resize = False

    if replied.photo or replied.document and "image" in replied.document.mime_type:
        resize = True
    elif replied.document and "tgsticker" in replied.document.mime_type:
        is_anim = True
    elif replied.animation or (replied.document and "video" in replied.document.mime_type
                               and replied.document.file_size <= 10485760):
        resize = True
        is_video = True
    elif replied.sticker:
        if not replied.sticker.file_name:
            return await message.edit("`Sticker has no Name!`")
        _ = replied.sticker.emoji
        if _:
            emoji_ = _
        is_anim = replied.sticker.is_animated
        is_video = replied.sticker.is_video
        if not (
            replied.sticker.file_name.endswith('.tgs')
            or replied.sticker.file_name.endswith('.webm')
        ):
            resize = True
    else:
        return await message.edit("`Unsupported File!`")

    if '-d' in message.flags:
        await message.delete()
    else:
        await message.edit(f"`{random.choice(KANGING_STR)}`")
    media = await replied.download(config.Dynamic.DOWN_PATH)
    if not media:
        return await message.edit("`No Media!`")

    args = message.filtered_input_str.split(' ')
    pack = 1
    _emoji = None

    if len(args) == 2:
        _emoji, pack = args
    elif len(args) == 1:
        if args[0].isnumeric():
            pack = int(args[0])
        else:
            _emoji = args[0]

    if _emoji is not None:
        _saved = emoji_
        for k in _emoji:
            if k and k in (
                getattr(pyro_emojis, a) for a in dir(pyro_emojis) if not a.startswith("_")
            ):
                emoji_ += k
        if _saved and _saved != emoji_:
            emoji_ = emoji_[len(_saved):]
    if not emoji_:
        emoji_ = "🤔"

    user = await userge.get_me()
    bot = None
    if userge.has_bot:
        bot = await userge.bot.get_me()

    u_name = user.username
    if u_name:
        u_name = "@" + u_name
    else:
        u_name = user.first_name or user.id

    packname = f"a{user.id}_by_userge_{pack}"
    custom_packnick = kang.CUSTOM_PACK_NAME or f"{u_name}'s Kang Pack"
    packnick = f"{custom_packnick} Vol.{pack}"

    if resize:
        media = await resize_media(media, is_video)
    if is_anim:
        packname += "_anim"
        packnick += " (Animated)"
    if is_video:
        packname += "_video"
        packnick += " (Video)"

    exist = False
    while True:
        if userge.has_bot:
            packname += f"_by_{bot.username}"
        try:
            exist = await message.client.send(
                GetStickerSet(
                    stickerset=InputStickerSetShortName(
                        short_name=packname), hash=0))
        except StickersetInvalid:
            exist = False
            break
        else:
            limit = 50 if (is_anim or is_video) else 120
            if exist.set.count >= limit:
                pack += 1
                packname = f"a{user.id}_by_userge_{pack}"
                packnick = f"{custom_packnick} Vol.{pack}"
                if is_anim:
                    packname += "_anim"
                    packnick += " (Animated)"
                if is_video:
                    packname += "_video"
                    packnick += " (Video)"
                await message.edit(f"`Switching to Pack {pack} due to insufficient space`")
                continue
            break

    if exist is not False:
        sts = await add_sticker(message, packname, media, emoji_)
    else:
        st_type = "anim" if is_anim else "vid" if is_video else "static"
        sts = await create_pack(message, packnick, packname, media, emoji_, st_type)

    if '-d' in message.flags:
        pass
    elif sts:
        out = "__kanged__" if '-s' in message.flags else \
            f"[kanged](t.me/addstickers/{packname})"
        await message.edit(f"**Sticker** {out}**!**")
    if os.path.exists(str(media)):
        os.remove(media)
Пример #5
0
async def kang_on_send(_, message: Message):
    try:
        start_ = await userge.send_message(message.chat.id, "`Kanging...`")
        user = await userge.get_me()
        replied = message
        photo = None
        emoji_ = None
        is_anim = False
        resize = False
        if replied and replied.media:
            if replied.photo:
                resize = True
            elif replied.document and "image" in replied.document.mime_type:
                resize = True
            elif replied.document and "tgsticker" in replied.document.mime_type:
                is_anim = True
            elif replied.sticker:
                if not replied.sticker.file_name:
                    await start_.edit("`Sticker has no Name!`")
                    return
                emoji_ = replied.sticker.emoji
                is_anim = replied.sticker.is_animated
                if not replied.sticker.file_name.endswith(".tgs"):
                    resize = True
            else:
                await start_.edit("`Unsupported File!`")
                return
            await start_.edit(f"`{random.choice(KANGING_STR)}`")
            photo = await userge.download_media(
                message=replied, file_name=Config.DOWN_PATH
            )
        else:
            await start_.edit("`I can't kang that...`")
            return
        if photo:
            pack = 1

            if emoji_ and emoji_ not in (
                getattr(emoji, _) for _ in dir(emoji) if not _.startswith("_")
            ):
                emoji_ = None
            if not emoji_:
                emoji_ = "🤔"

            u_name = user.username
            u_name = "@" + u_name if u_name else user.first_name or user.id
            packname = f"a{user.id}_by_{user.username}_{pack}"
            custom_packnick = Config.CUSTOM_PACK_NAME or f"{u_name}'s kang pack"
            packnick = f"{custom_packnick} vol.{pack}"
            cmd = "/newpack"
            if resize:
                photo = resize_photo(photo)
            if is_anim:
                packname += "_anim"
                packnick += " (Animated)"
                cmd = "/newanimated"
            exist = False
            try:
                exist = await userge.send(
                    GetStickerSet(
                        stickerset=InputStickerSetShortName(short_name=packname), hash=0
                    )
                )
            except StickersetInvalid:
                pass
            if exist is not False:
                async with userge.conversation("Stickers", limit=30) as conv:
                    try:
                        await conv.send_message("/addsticker")
                    except YouBlockedUser:
                        await start_.edit("first **unblock** @Stickers")
                        return
                    await conv.get_response(mark_read=True)
                    await conv.send_message(packname)
                    msg = await conv.get_response(mark_read=True)
                    limit = "50" if is_anim else "120"
                    while limit in msg.text:
                        pack += 1
                        packname = f"a{user.id}_by_userge_{pack}"
                        packnick = f"{custom_packnick} Vol.{pack}"
                        if is_anim:
                            packname += "_anim"
                            packnick += " (Animated)"
                        await start_.edit(
                            "`Switching to Pack "
                            + str(pack)
                            + " due to insufficient space`"
                        )
                        await conv.send_message(packname)
                        msg = await conv.get_response(mark_read=True)
                        if msg.text == "Invalid pack selected.":
                            await conv.send_message(cmd)
                            await conv.get_response(mark_read=True)
                            await conv.send_message(packnick)
                            await conv.get_response(mark_read=True)
                            await conv.send_document(photo)
                            await conv.get_response(mark_read=True)
                            await conv.send_message(emoji_)
                            await conv.get_response(mark_read=True)
                            await conv.send_message("/publish")
                            if is_anim:
                                await conv.get_response(mark_read=True)
                                await conv.send_message(
                                    f"<{packnick}>", parse_mode=None
                                )
                            await conv.get_response(mark_read=True)
                            await conv.send_message("/skip")
                            await conv.get_response(mark_read=True)
                            await conv.send_message(packname)
                            await conv.get_response(mark_read=True)
                            out = f"[kanged](t.me/addstickers/{packname})"
                            await start_.edit(
                                f"**Sticker** {out} __in a Different Pack__**!**"
                            )
                            return
                    await conv.send_document(photo)
                    rsp = await conv.get_response(mark_read=True)
                    if "Sorry, the file type is invalid." in rsp.text:
                        await start_.edit(
                            "`Failed to add sticker, use` @Stickers "
                            "`bot to add the sticker manually.`"
                        )
                        return
                    await conv.send_message(emoji_)
                    await conv.get_response(mark_read=True)
                    await conv.send_message("/done")
                    await conv.get_response(mark_read=True)
            else:
                await start_.edit("`Brewing a new Pack...`")
                async with userge.conversation("Stickers") as conv:
                    try:
                        await conv.send_message(cmd)
                    except YouBlockedUser:
                        await start_.edit("first **unblock** @Stickers")
                        return
                    await conv.get_response(mark_read=True)
                    await conv.send_message(packnick)
                    await conv.get_response(mark_read=True)
                    await conv.send_document(photo)
                    rsp = await conv.get_response(mark_read=True)
                    if "Sorry, the file type is invalid." in rsp.text:
                        await start_.edit(
                            "`Failed to add sticker, use` @Stickers "
                            "`bot to add the sticker manually.`"
                        )
                        return
                    await conv.send_message(emoji_)
                    await conv.get_response(mark_read=True)
                    await conv.send_message("/publish")
                    if is_anim:
                        await conv.get_response(mark_read=True)
                        await conv.send_message(f"<{packnick}>", parse_mode=None)
                    await conv.get_response(mark_read=True)
                    await conv.send_message("/skip")
                    await conv.get_response(mark_read=True)
                    await conv.send_message(packname)
                    await conv.get_response(mark_read=True)
            out = f"[kanged](t.me/addstickers/{packname})"
            await start_.edit(f"**Sticker** {out}**!**")
            if os.path.exists(str(photo)):
                os.remove(photo)
        async for data in STICK_MSG.find():
            chat_ = data["chat_id"]
            msg_ = data["msg_id"]
        await userge.bot.edit_message_text(
            int(chat_), int(msg_), f"**Sticker** {out}**!**"
        )
        await STICK_MSG.drop()
    except Exception as e:
        await userge.send_message(Config.LOG_CHANNEL_ID, e)
Пример #6
0
async def kang(client, message):
    user = await app.get_me()
    replied = message.reply_to_message
    photo = None
    emoji_ = None
    is_anim = False
    resize = False
    if replied and replied.media:
        if replied.photo:
            resize = True
        elif replied.document and "image" in replied.document.mime_type:
            resize = True
        elif replied.document and "tgsticker" in replied.document.mime_type:
            is_anim = True
        elif replied.sticker:
            if not replied.sticker.file_name:
                await message.edit("`Sticker has no Name!`")
                return
            emoji_ = replied.sticker.emoji
            is_anim = replied.sticker.is_animated
            if not replied.sticker.file_name.endswith(".tgs"):
                resize = True
        else:
            await message.edit("`Unsupported File!`")
            return
        await message.edit(f"`{random.choice(KANGING_STR)}`")
        photo = await app.download_media(message=replied)
    else:
        await message.edit("`I can't kang that...`")
        return
    if photo:
        args = get_args(message)
        pack = 1
        if len(args) == 2:
            emoji_, pack = args
        elif len(args) == 1:
            if args[0].isnumeric():
                pack = int(args[0])
            else:
                emoji_ = args[0]

        if emoji_ and emoji_ not in (getattr(emoji, a) for a in dir(emoji)
                                     if not a.startswith("_")):
            emoji_ = None
        if not emoji_:
            emoji_ = "🤔"

        u_name = user.username
        if u_name:
            u_name = "@" + u_name
        else:
            u_name = user.first_name or user.id
        packname = f"a{user.id}_by_zect_{pack}"
        custom_packnick = f"{u_name}'s kang pack"
        packnick = f"{custom_packnick} Vol.{pack}"
        cmd = "/newpack"
        if resize:
            photo = resize_photo(photo)
        if is_anim:
            packname += "_anim"
            packnick += " (Animated)"
            cmd = "/newanimated"
        exist = False
        try:
            exist = await app.send(
                GetStickerSet(stickerset=InputStickerSetShortName(
                    short_name=packname)))
        except StickersetInvalid:
            pass
        if exist is not False:
            try:
                await app.send_message("Stickers", "/addsticker")
            except YouBlockedUser:
                await message.edit("first **unblock** @Stickers")
                return
            await app.send_message("Stickers", packname)
            limit = "50" if is_anim else "120"
            while limit in await get_response(message):
                pack += 1
                packname = f"a{user.id}_by_zect_{pack}"
                packnick = f"{custom_packnick} Vol.{pack}"
                if is_anim:
                    packname += "_anim"
                    packnick += " (Animated)"
                await message.edit("`Switching to Pack " + str(pack) +
                                   " due to insufficient space`")
                await app.send_message("Stickers", packname)
                if await get_response(message) == "Invalid pack selected":
                    await app.send_message("Stickers", cmd)
                    await get_response(message)
                    await app.send_message("Stickers", packnick)
                    await get_response(message)
                    await app.send_document("Stickers", photo)
                    await get_response(message)
                    await app.send_message("Stickers", emoji_)
                    await get_response(message)
                    await app.send_message("Stickers", "/publish")
                    if is_anim:
                        await get_response(message)
                        await app.send_message("Stickers",
                                               f"<{packnick}>",
                                               parse_mode=None)
                    await get_response(message)
                    await app.send_message("Stickers", "/skip")
                    await get_response(message)
                    await app.send_message("Stickers", packname)
                    out = f"[kanged](t.me/addstickers/{packname})"
                    await message.edit(
                        f"**Sticker** {out} __in a Different Pack__**!**")
                    return
            await app.send_document("Stickers", photo)
            time.sleep(0.2)
            rsp = await get_response(message)
            if "Sorry, the file type is invalid." in rsp:
                await message.edit("`Failed to add sticker, use` @Stickers "
                                   "`bot to add the sticker manually.`")
                return
            await app.send_message("Stickers", emoji_)
            await get_response(message)
            await app.send_message("Stickers", "/done")
        else:
            await message.edit("`Brewing a new Pack...`")
            try:
                await app.send_message("Stickers", cmd)
            except YouBlockedUser:
                await message.edit("first **unblock** @Stickers")
                return
            await app.send_message("Stickers", packnick)
            await get_response(message)
            await app.send_document("Stickers", photo)
            await get_response(message)
            rsp = await get_response(message)
            if "Sorry, the file type is invalid." in rsp:
                await message.edit("`Failed to add sticker, use` @Stickers "
                                   "`bot to add the sticker manually.`")
                return
            await app.send_message("Stickers", emoji_)
            await get_response(message)
            await app.send_message("Stickers", "/publish")
            if is_anim:
                await get_response(message)
                await app.send_message("Stickers",
                                       f"<{packnick}>",
                                       parse_mode=None)
            await get_response(message)
            await app.send_message("Stickers", "/skip")
            await get_response(message)
            await app.send_message("Stickers", packname)
        out = f"[kanged](t.me/addstickers/{packname})"
        await message.edit(f"**Sticker** {out}**!**")
        await app.read_history("Stickers")
        if os.path.exists(str(photo)):
            os.remove(photo)
Пример #7
0
    async def cmd_createpack(self, ctx: command.Context) -> str:
        if not ctx.msg.reply_to_message:
            return "__Reply to a message sticker to create a new pack.__"

        reply_msg = ctx.msg.reply_to_message
        if not reply_msg.sticker:
            return "__That message is not a sticker.__"

        num = ctx.input if ctx.input else "1"
        check = self.kang_db.get(num) if self.kang_db is not None else None
        if check:
            try:
                await self.bot.client.send(GetStickerSet(
                    stickerset=InputStickerSetShortName(short_name=check)
                    )
                )
            except StickersetInvalid:
                pass
            else:
                return "__Pack with that name already exists, use 'kang' instead.__"

        emoji = ctx.args[1] if len(ctx.args) > 1 else "❓"
        pack_name = self.bot.user.username + f"_kangPack_VOL{num}"
        async with self.lock:
            await self.db.update_one(
                {"_id": self.name},
                {
                    "$set": {
                        f"pack_name.{num}": pack_name
                    }
                },
                upsert=True
            )

        try:
            await self.bot.client.send(GetStickerSet(
                stickerset=InputStickerSetShortName(short_name=pack_name)
                )
            )
        except StickersetInvalid:
            pass
        else:
            await self.on_load()
            return "__Pack with that name already exists, use 'kang' instead.__"

        await ctx.respond("Creating new pack...")

        sticker_file = await reply_msg.download()
        async with AIOFile(sticker_file, "rb") as sticker:
            sticker_bytes = await sticker.read()
        sticker_buf = io.BytesIO(sticker_bytes)
        await util.image.img_to_png(sticker_buf)

        sticker_buf.seek(0)
        sticker_buf.name = "sticker.png"
        status, result = await self.create_pack(
            sticker_buf, pack_name, emoji=reply_msg.sticker.emoji or emoji
        )
        if status:
            await self.bot.log_stat("stickers_created")

            # Update the database
            await self.on_load()
            return f"[Pack Created]({result})."

        return result