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}" 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
async def sticker_pack_info_(message: Message): """ get sticker pack info """ replied = message.reply_to_message if not replied: await message.edit("`Maaf ada Kesalahan Server!`") return if not replied.sticker: await message.edit("`Pakai Reply Goblok.....`") return await message.edit("`Sabar Sedang Colong Sticker..`") get_stickerset = await message.client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=replied.sticker.set_name))) pack_emojis = [] for document_sticker in get_stickerset.packs: if document_sticker.emoticon not in pack_emojis: pack_emojis.append(document_sticker.emoticon) out_str = f"**Sticker Title:** `{get_stickerset.set.title}\n`" \ f"**Sticker Short Name:** `{get_stickerset.set.short_name}`\n" \ f"**Archived:** `{get_stickerset.set.archived}`\n" \ f"**Official:** `{get_stickerset.set.official}`\n" \ f"**Masks:** `{get_stickerset.set.masks}`\n" \ f"**Animated:** `{get_stickerset.set.animated}`\n" \ f"**Stickers In Pack:** `{get_stickerset.set.count}`\n" \ f"**Emojis In Pack:**\n{' '.join(pack_emojis)}" await message.edit(out_str)
async def sticker_pack_info_(message: Message): """ get sticker pack info """ replied = message.reply_to_message if not replied: await message.edit("`I can't fetch info from nothing, can I ?!`") return if not replied.sticker: await message.edit("`Reply to a sticker to get the pack details`") return await message.edit("`Fetching details of the sticker pack, please wait..`") get_stickerset = await message.client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=replied.sticker.set_name))) pack_emojis = [] for document_sticker in get_stickerset.packs: if document_sticker.emoticon not in pack_emojis: pack_emojis.append(document_sticker.emoticon) out_str = (f"**Sticker Title:** `{get_stickerset.set.title}\n`" f"**Sticker Short Name:** `{get_stickerset.set.short_name}`\n" f"**Archived:** `{get_stickerset.set.archived}`\n" f"**Official:** `{get_stickerset.set.official}`\n" f"**Masks:** `{get_stickerset.set.masks}`\n" f"**Animated:** `{get_stickerset.set.animated}`\n" f"**Stickers In Pack:** `{get_stickerset.set.count}`\n" f"**Emojis In Pack:**\n{' '.join(pack_emojis)}") await message.edit(out_str)
def packinfo(client, message): reply = message.reply_to_message if not reply: edit(message, f'`{get_translation("packinfoError")}`') return if not reply.sticker: edit(message, f'`{get_translation("packinfoError2")}`') return edit(message, f'`{get_translation("processing")}`') get_stickerset = client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=reply.sticker.set_name))) pack_emojis = [] for document_sticker in get_stickerset.packs: if document_sticker.emoticon not in pack_emojis: pack_emojis.append(document_sticker.emoticon) out = get_translation('packinfoResult', [ '**', '`', get_stickerset.set.title, get_stickerset.set.short_name, get_stickerset.set.official, get_stickerset.set.archived, get_stickerset.set.animated, get_stickerset.set.count, ' '.join(pack_emojis) ]) edit(message, out)
async def packinfo(client, message): engine = message.Engine pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) if not message.reply_to_message: await pablo.edit(engine.get_string("NEEDS_REPLY").format("Sticker")) return if not message.reply_to_message.sticker: await pablo.edit(engine.get_string("NEEDS_REPLY").format("Sticker")) return if not message.reply_to_message.sticker.set_name: await pablo.delete() return stickerset = await client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=message.reply_to_message.sticker.set_name))) emojis = [] for stucker in stickerset.packs: if stucker.emoticon not in emojis: emojis.append(stucker.emoticon) output = f"""**Sticker Pack Title **: `{stickerset.set.title}` **Sticker Pack Short Name **: `{stickerset.set.short_name}` **Stickers Count **: `{stickerset.set.count}` **Archived **: `{stickerset.set.archived}` **Official **: `{stickerset.set.official}` **Masks **: `{stickerset.set.masks}` **Animated **: `{stickerset.set.animated}` **Emojis In Pack **: `{' '.join(emojis)}` """ await pablo.edit(output)
async def sticker_pack_info_(message: Message): """ çıkartma paket bilgisini al """ replied = message.reply_to_message if not replied: await message.edit("`Hiçbir şeyden bilgi alamıyorum, değil mi?`") return if not replied.sticker: await message.edit( "`Paket bilgisini almak için bir çıkartmayı yanıtlayın`") return await message.edit( "`Çıkartma paketinin bilgisi alınıyor, lütfen bekleyin ..`") get_stickerset = await message.client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=replied.sticker.set_name))) pack_emojis = [] for document_sticker in get_stickerset.packs: if document_sticker.emoticon not in pack_emojis: pack_emojis.append(document_sticker.emoticon) out_str = f"** paket adı:** `{get_stickerset.set.title}\n`" \ f"**Stikır Kısa Adı:** `{get_stickerset.set.short_name}`\n" \ f"**Arşivlendi mi?:** `{get_stickerset.set.archived}`\n" \ f"**Resmi:** `{get_stickerset.set.official}`\n" \ f"**Maskeler:** `{get_stickerset.set.masks}`\n" \ f"**Animasyonlu mu?:** `{get_stickerset.set.animated}`\n" \ f"**Paketteki Çıkartma sayısı:** `{get_stickerset.set.count}`\n" \ f"**Paketteki Emojiler:**\n{' '.join(pack_emojis)}" await message.edit(out_str)
async def packinfo(client, message): pablo = await edit_or_reply(message, "`Caricamento...`") if not (message.reply_to_message or message.reply_to_message.sticker): await pablo.edit("Coglione rispondi a uno sticker...") return if not message.reply_to_message.sticker.set_name: await pablo.edit("`MHHHHHHHHH`") return stickerset = await client.send( GetStickerSet( stickerset=InputStickerSetShortName( short_name=message.reply_to_message.sticker.set_name))) emojis = [] for stucker in stickerset.packs: if stucker.emoticon not in emojis: emojis.append(stucker.emoticon) output = f"""**Titolo**: `{stickerset.set.title}` **Nome corto **: `{stickerset.set.short_name}` **Numero stickers**: `{stickerset.set.count}` **Archiviato**: `{stickerset.set.archived}` **Ufficiali**: `{stickerset.set.official}` **Maschere**: `{stickerset.set.masks}` **Animati**: `{stickerset.set.animated}` **Emoji**: `{' '.join(emojis)}` """ await pablo.edit(output)
def get_sticker_title(client: Client, short_name: str, normal: bool = False, printable: bool = True, cache: bool = True) -> Optional[str]: # Get sticker set's title result = None try: result = glovar.sticker_titles.get(short_name) if result and cache: return glovar.sticker_titles[short_name] sticker_set = InputStickerSetShortName(short_name=short_name) flood_wait = True while flood_wait: flood_wait = False try: the_set = client.send(GetStickerSet(stickerset=sticker_set)) if isinstance(the_set, messages_StickerSet): inner_set = the_set.set if isinstance(inner_set, StickerSet): result = t2t(inner_set.title, normal, printable) except FloodWait as e: flood_wait = True wait_flood(e) glovar.sticker_titles[short_name] = result except Exception as e: logger.warning(f"Get sticker {short_name} title error: {e}", exc_info=True) return result
async def packinfo(client, message): pablo = await edit_or_reply(message, "`Processing...`") if not (message.reply_to_message or message.reply_to_message.sticker): await pablo.edit("Please Reply To Sticker...") return if not message.reply_to_message.sticker.set_name: await pablo.edit("`Seems Like A Stray Sticker!`") return stickerset = await client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=message.reply_to_message.sticker.set_name))) emojis = [] for stucker in stickerset.packs: if stucker.emoticon not in emojis: emojis.append(stucker.emoticon) output = f"""**Sticker Pack Title **: `{stickerset.set.title}` **Sticker Pack Short Name **: `{stickerset.set.short_name}` **Stickers Count **: `{stickerset.set.count}` **Archived **: `{stickerset.set.archived}` **Official **: `{stickerset.set.official}` **Masks **: `{stickerset.set.masks}` **Animated **: `{stickerset.set.animated}` **Emojis In Pack **: `{' '.join(emojis)}` """ await pablo.edit(output)
def pack_created(name): try: set_name = InputStickerSetShortName(short_name=name) set = GetStickerSet(stickerset=set_name) client.send(data=set) return True except BaseException as e: return False
async def cmd_copysticker(self, ctx: command.Context) -> str: if not ctx.msg.reply_to_message: return "__Reply to a sticker to copy it.__" pack_VOL = None emoji = "" for arg in ctx.args: if util.text.has_emoji(arg): # Allow for emoji split across several arguments, since some clients # automatically insert spaces emoji += arg else: pack_VOL = arg if not pack_VOL: pack_name = self.kang_db.get( "1") if self.kang_db is not None else None else: pack_name = self.kang_db.get( pack_VOL) if self.kang_db is not None else None if not pack_name: ret = await self.cmd_createpack(ctx) await self.on_load() return ret try: await self.bot.client.send( GetStickerSet(stickerset=InputStickerSetShortName( short_name=pack_name))) except StickersetInvalid: ret = await self.cmd_createpack(ctx) return ret reply_msg = ctx.msg.reply_to_message await ctx.respond("Copying sticker...") 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.add_sticker(sticker_buf, pack_name, emoji=emoji or reply_msg.sticker.emoji) if status: await self.bot.log_stat("stickers_created") return f"[Sticker copied]({result})." return result
def pack_created(pname): try: set_name = InputStickerSetShortName( short_name=TEMP_SETTINGS[pname]) set = GetStickerSet(stickerset=set_name, hash=0) client.invoke(query=set) return True except BaseException: return False
async def add_sticker(message: Message, short_name: str, sticker: str, emoji: str) -> bool: if userge.has_bot: media = (await userge.bot.send(UploadMedia( peer=await userge.bot.resolve_peer('stickers'), media=InputMediaUploadedDocument( mime_type=userge.guess_mime_type(sticker) or "application/zip", file=( await userge.bot.save_file(sticker) ), force_file=True, thumb=None, attributes=[ DocumentAttributeFilename(file_name=os.path.basename(sticker)) ] ) ) )).document await userge.bot.send( AddStickerToSet( stickerset=InputStickerSetShortName( short_name=short_name), sticker=InputStickerSetItem( document=InputDocument( id=media.id, access_hash=media.access_hash, file_reference=media.file_reference), emoji=emoji))) else: async with userge.conversation('Stickers', limit=30) as conv: try: await conv.send_message('/addsticker') except YouBlockedUser: await message.edit('first **unblock** @Stickers') return False await conv.get_response(mark_read=True) await conv.send_message(short_name) await conv.get_response(mark_read=True) await conv.send_document(sticker) 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 False await conv.send_message(emoji) await conv.get_response(mark_read=True) await conv.send_message('/done') await conv.get_response(mark_read=True) return True
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)
async def kang_(message: Message): """ kang a sticker """ user = await userge.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 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_ and emoji_ not in emoji.UNICODE_EMOJI: 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_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)
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)
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.invoke( 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)
async def packinfo(client, message): engine = message.Engine pablo = await edit_or_reply(message, engine.get_string("KANG_MAGIC_")) if not message.reply_to_message: await pablo.edit(engine.get_string("NEEDS_REPLY").format("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"FRIDAY_{message.from_user.id}_{pack}" non = [None, "None"] emoji = "😁" try: Hell = Hell.strip() if Hell.isalpha(): emoji = "😁" elif not Hell.isnumeric(): emoji = Hell 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( engine.get_string("UNSUPPORTED").format("Media")) 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(engine.get_string("UNSUPPORTED").format("Media")) 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`") await client.unblock_user("stickers") 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 prev_pack = int(pack) - 1 await pablo.edit( engine.get_string("KANG_FULL").format(prev_pack, pack)) 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( engine.get_string("ADDED_STICKER").format( emoji, 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( engine.get_string("ADDED_STICKER").format(emoji, 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( engine.get_string("ADDED_STICKER").format(emoji, packshortname)) if os.path.exists(file_name): os.remove(file_name)
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!`") await message.edit(f"`{random.choice(KANGING_STR)}`") media = await userge.download_media(message=replied, file_name=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(emoji, a) for a in dir(emoji) if not a.startswith("_")): emoji_ += k if _saved and _saved != emoji_: emoji_ = emoji_[len(_saved):] if not emoji_: emoji_ = "🤔" user = await userge.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}" cmd = '/newpack' if resize: media = await resize_media(media, is_video) if is_anim: packname += "_anim" packnick += " (Animated)" cmd = '/newanimated' if is_video: packname += "_video" packnick += " (Video)" cmd = '/newvideo' exist = False try: exist = await message.client.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: return await message.edit('first **unblock** @Stickers') 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 or is_video) 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)" if is_video: packname += "_video" packnick += " (Video)" await message.edit( f"`Switching to Pack {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(media) 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(media) 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: return await message.edit('first **unblock** @Stickers') await conv.get_response(mark_read=True) await conv.send_message(packnick) await conv.get_response(mark_read=True) await conv.send_document(media) 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(media)): os.remove(media)
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"FRIDAY_{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("`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)
async def kang_sticker(c: Client, m: Message): prog_msg = await m.reply_text(await tld(m.chat.id, "stickers_kanging")) user = await c.get_me() bot_username = user.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: # mime_type: image/webp resize = True elif "tgsticker" in reply.document.mime_type: # mime_type: application/x-tgsticker animated = True elif reply.sticker: if not reply.sticker.file_name: return await prog_msg.edit_text(await tld( m.chat.id, "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(await tld(m.chat.id, "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: # provide pack number to kang in desired pack packnum = m.command.pop(1) packname = f"{pack_prefix}{packnum}_{m.from_user.id}_by_{bot_username}" if len(m.command) > 1: # matches all valid emojis in input 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: # Failed to download await prog_msg.delete() return elif m.entities and len(m.entities) > 1: packname = f"c{m.from_user.id}_by_{bot_username}" pack_prefix = "a" # searching if image_url is given img_url = None filename = "sticker.png" for y in m.entities: if y.type == "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: # m.command[1] is image_url 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.edit_text(await tld(m.chat.id, "stickers_kang_noreply")) try: if resize: filename = resize_image(filename) max_stickers = 50 if animated else 120 while not packname_found: try: stickerset = await c.send( 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.send( SendMedia( peer=(await c.resolve_peer(CHAT_LOGS)), 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(), ), ) msg_ = media.updates[-1].message stkr_file = msg_.media.document if packname_found: await prog_msg.edit_text(await tld(m.chat.id, "use_existing_pack")) await c.send( 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(await tld(m.chat.id, "create_new_pack_string")) stkr_title = f"{m.from_user.first_name[:32]}'s " if animated: stkr_title += "Anim. " stkr_title += "Smudge Pack" if packnum != 0: stkr_title += f" v{packnum}" try: await c.send( 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( await tld(m.chat.id, "stickers_pack_contact_pm"), 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: await prog_msg.edit_text( (await tld(m.chat.id, "sticker_kanged_string")).format(packname, sticker_emoji)) # Cleanup await c.delete_messages(chat_id=CHAT_LOGS, message_ids=msg_.id, revoke=True) try: os.remove(filename) except OSError: pass
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)