@Client.on_message(filters.command(['kang', 'kibe', 'steal'], PREFIXES))
@use_chat_lang()
async def kang_sticker(c: Client, m: Message, strings):
    prog_msg = (await m.reply_text(strings('kanging_sticker_msg')))
    bot_username = c.me.username
    sticker_emoji = '🤔'
    packnum = 0
    packname_found = False
    resize = False
    animated = False
    reply = m.reply_to_message
    user = (await c.resolve_peer((m.from_user.username or m.from_user.id)))
    if (reply and reply.media):
        if reply.photo:
            resize = True
        elif reply.document:
            if ('image' in reply.document.mime_type):
                resize = True
            elif ('tgsticker' in reply.document.mime_type):
                animated = True
        elif reply.sticker:
            if (not reply.sticker.file_name):
                return (await prog_msg.edit_text(strings('err_sticker_no_file_name')))
            if reply.sticker.emoji:
                sticker_emoji = reply.sticker.emoji
            animated = reply.sticker.is_animated
            if (not reply.sticker.file_name.endswith('.tgs')):
                resize = True
        else:
            return (await prog_msg.edit_text(strings('invalid_media_string')))
        pack_prefix = ('anim' if animated else 'a')
        packname = f'{pack_prefix}_{m.from_user.id}_by_{bot_username}'
        if (len(m.command) > 1):
            if (m.command[1].isdigit() and (int(m.command[1]) > 0)):
                packnum = m.command.pop(1)
                packname = f'{pack_prefix}{packnum}_{m.from_user.id}_by_{bot_username}'
            if (len(m.command) > 1):
                sticker_emoji = (''.join(set(EMOJI_PATTERN.findall(''.join(m.command[1:])))) or sticker_emoji)
        filename = (await c.download_media(m.reply_to_message))
        if (not filename):
            (await prog_msg.delete())
            return
    elif (m.entities and (len(m.entities) > 1)):
        packname = f'a_{m.from_user.id}_by_{bot_username}'
        pack_prefix = 'a'
        img_url = None
        filename = 'sticker.png'
        for y in m.entities:
            if (y.type == MessageEntityType.URL):
                img_url = m.text[y.offset:(y.offset + y.length)]
                break
        if (not img_url):
            (await prog_msg.delete())
            return
        try:
            r = (await http.get(img_url))
            if (r.status_code == 200):
                with open(filename, mode='wb') as f:
                    f.write(r.read())
        except Exception as r_e:
            return (await prog_msg.edit_text(f'{r_e.__class__.__name__} : {r_e}'))
        if (len(m.command) > 2):
            if (m.command[2].isdigit() and (int(m.command[2]) > 0)):
                packnum = m.command.pop(2)
                packname = f'a{packnum}_{m.from_user.id}_by_{bot_username}'
            if (len(m.command) > 2):
                sticker_emoji = (''.join(set(EMOJI_PATTERN.findall(''.join(m.command[2:])))) or sticker_emoji)
            resize = True
    else:
        return (await prog_msg.delete())
    try:
        if resize:
            filename = resize_image(filename)
        max_stickers = (50 if animated else 120)
        while (not packname_found):
            try:
                stickerset = (await c.invoke(GetStickerSet(stickerset=InputStickerSetShortName(short_name=packname), hash=0)))
                if (stickerset.set.count >= max_stickers):
                    packnum += 1
                    packname = f'{pack_prefix}_{packnum}_{m.from_user.id}_by_{bot_username}'
                else:
                    packname_found = True
            except StickersetInvalid:
                break
        file = (await c.save_file(filename))
        media = (await c.invoke(SendMedia(peer=(await c.resolve_peer(LOG_CHAT)), media=InputMediaUploadedDocument(file=file, mime_type=c.guess_mime_type(filename), attributes=[DocumentAttributeFilename(file_name=filename)]), message=f'#Sticker kang by UserID -> {m.from_user.id}', random_id=c.rnd_id())))
        stkr_file = media.updates[(- 1)].message.media.document
        if packname_found:
            (await prog_msg.edit_text(strings('use_existing_pack')))
            (await c.invoke(AddStickerToSet(stickerset=InputStickerSetShortName(short_name=packname), sticker=InputStickerSetItem(document=InputDocument(id=stkr_file.id, access_hash=stkr_file.access_hash, file_reference=stkr_file.file_reference), emoji=sticker_emoji))))
        else:
            (await prog_msg.edit_text(strings('create_new_pack_string')))
            u_name = m.from_user.username
            if u_name:
                u_name = f'@{u_name}'
            else:
                u_name = str(m.from_user.id)
            stkr_title = f"{u_name}'s "
            if animated:
                stkr_title += 'Anim. '
            stkr_title += 'EduuPack'
            if (packnum != 0):
                stkr_title += f' v{packnum}'
            try:
                (await c.invoke(CreateStickerSet(user_id=user, title=stkr_title, short_name=packname, stickers=[InputStickerSetItem(document=InputDocument(id=stkr_file.id, access_hash=stkr_file.access_hash, file_reference=stkr_file.file_reference), emoji=sticker_emoji)], animated=animated)))
            except PeerIdInvalid:
                return (await prog_msg.edit_text(strings('cant_create_sticker_pack_string'), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('/start', url=f'https://t.me/{bot_username}?start')]])))
    except Exception as all_e:
        (await prog_msg.edit_text(f'{all_e.__class__.__name__} : {all_e}'))
    else:
        markup = InlineKeyboardMarkup([[InlineKeyboardButton(strings('view_sticker_pack_btn'), url=f't.me/addstickers/{packname}')]])
        kanged_success_msg = strings('sticker_kanged_string')
        (await prog_msg.edit_text(kanged_success_msg.format(sticker_emoji=sticker_emoji), reply_markup=markup))
        try:
            os.remove(filename)
        except OSError:
            pass
@Client.on_message(filters.command(['kang', 'kibe', 'steal'], PREFIXES))
@use_chat_lang()
async def kang_sticker(c: Client, m: Message, strings):
    prog_msg = (await m.reply_text(strings('kanging_sticker_msg')))
    bot_username = c.me.username
    sticker_emoji = '🤔'
    packnum = 0
    packname_found = False
    resize = False
    animated = False
    reply = m.reply_to_message
    user = (await c.resolve_peer((m.from_user.username or m.from_user.id)))
    if (reply and reply.media):
        if reply.photo:
            resize = True
        elif reply.document:
            if ('image' in reply.document.mime_type):
                resize = True
            elif ('tgsticker' in reply.document.mime_type):
                animated = True
        elif reply.sticker:
            if (not reply.sticker.file_name):
                return (await prog_msg.edit_text(strings('err_sticker_no_file_name')))
            if reply.sticker.emoji:
                sticker_emoji = reply.sticker.emoji
            animated = reply.sticker.is_animated
            if (not reply.sticker.file_name.endswith('.tgs')):
                resize = True
        else:
            return (await prog_msg.edit_text(strings('invalid_media_string')))
        pack_prefix = ('anim' if animated else 'a')
        packname = f'{pack_prefix}_{m.from_user.id}_by_{bot_username}'
        if (len(m.command) > 1):
            if (m.command[1].isdigit() and (int(m.command[1]) > 0)):
                packnum = m.command.pop(1)
                packname = f'{pack_prefix}{packnum}_{m.from_user.id}_by_{bot_username}'
            if (len(m.command) > 1):
                sticker_emoji = (.join(set(EMOJI_PATTERN.findall(.join(m.command[1:])))) or sticker_emoji)
        filename = (await c.download_media(m.reply_to_message))
        if (not filename):
            (await prog_msg.delete())
            return
    elif (m.entities and (len(m.entities) > 1)):
        packname = f'a_{m.from_user.id}_by_{bot_username}'
        pack_prefix = 'a'
        img_url = None
        filename = 'sticker.png'
        for y in m.entities:
            if (y.type == MessageEntityType.URL):
                img_url = m.text[y.offset:(y.offset + y.length)]
                break
        if (not img_url):
            (await prog_msg.delete())
            return
        try:
            r = (await http.get(img_url))
            if (r.status_code == 200):
                with open(filename, mode='wb') as f:
                    f.write(r.read())
        except Exception as r_e:
            return (await prog_msg.edit_text(f'{r_e.__class__.__name__} : {r_e}'))
        if (len(m.command) > 2):
            if (m.command[2].isdigit() and (int(m.command[2]) > 0)):
                packnum = m.command.pop(2)
                packname = f'a{packnum}_{m.from_user.id}_by_{bot_username}'
            if (len(m.command) > 2):
                sticker_emoji = (.join(set(EMOJI_PATTERN.findall(.join(m.command[2:])))) or sticker_emoji)
            resize = True
    else:
        return (await prog_msg.delete())
    try:
        if resize:
            filename = resize_image(filename)
        max_stickers = (50 if animated else 120)
        while (not packname_found):
            try:
                stickerset = (await c.invoke(GetStickerSet(stickerset=InputStickerSetShortName(short_name=packname), hash=0)))
                if (stickerset.set.count >= max_stickers):
                    packnum += 1
                    packname = f'{pack_prefix}_{packnum}_{m.from_user.id}_by_{bot_username}'
                else:
                    packname_found = True
            except StickersetInvalid:
                break
        file = (await c.save_file(filename))
        media = (await c.invoke(SendMedia(peer=(await c.resolve_peer(LOG_CHAT)), media=InputMediaUploadedDocument(file=file, mime_type=c.guess_mime_type(filename), attributes=[DocumentAttributeFilename(file_name=filename)]), message=f'#Sticker kang by UserID -> {m.from_user.id}', random_id=c.rnd_id())))
        stkr_file = media.updates[(- 1)].message.media.document
        if packname_found:
            (await prog_msg.edit_text(strings('use_existing_pack')))
            (await c.invoke(AddStickerToSet(stickerset=InputStickerSetShortName(short_name=packname), sticker=InputStickerSetItem(document=InputDocument(id=stkr_file.id, access_hash=stkr_file.access_hash, file_reference=stkr_file.file_reference), emoji=sticker_emoji))))
        else:
            (await prog_msg.edit_text(strings('create_new_pack_string')))
            u_name = m.from_user.username
            if u_name:
                u_name = f'@{u_name}'
            else:
                u_name = str(m.from_user.id)
            stkr_title = f"{u_name}'s "
            if animated:
                stkr_title += 'Anim. '
            stkr_title += 'EduuPack'
            if (packnum != 0):
                stkr_title += f' v{packnum}'
            try:
                (await c.invoke(CreateStickerSet(user_id=user, title=stkr_title, short_name=packname, stickers=[InputStickerSetItem(document=InputDocument(id=stkr_file.id, access_hash=stkr_file.access_hash, file_reference=stkr_file.file_reference), emoji=sticker_emoji)], animated=animated)))
            except PeerIdInvalid:
                return (await prog_msg.edit_text(strings('cant_create_sticker_pack_string'), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('/start', url=f'https://t.me/{bot_username}?start')]])))
    except Exception as all_e:
        (await prog_msg.edit_text(f'{all_e.__class__.__name__} : {all_e}'))
    else:
        markup = InlineKeyboardMarkup([[InlineKeyboardButton(strings('view_sticker_pack_btn'), url=f't.me/addstickers/{packname}')]])
        kanged_success_msg = strings('sticker_kanged_string')
        (await prog_msg.edit_text(kanged_success_msg.format(sticker_emoji=sticker_emoji), reply_markup=markup))
        try:
            os.remove(filename)
        except OSError:
            pass