async def hehe(args): ultroid_bot = args.client xx = await args.eor(get_string("com_1")) user = ultroid_bot.me username = user.username if not username: username = user.first_name else: username = "******" + username message = await args.get_reply_message() photo = None is_anim, is_vid = False, False emoji = None if not message: return await xx.eor(get_string("sts_6")) if message.photo: photo = io.BytesIO() photo = await ultroid_bot.download_media(message.photo, photo) elif message.file and "image" in message.file.mime_type.split("/"): photo = io.BytesIO() await ultroid_bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt elif message.file and "video" in message.file.mime_type.split("/"): xy = await message.download_media() if (message.file.duration or 0) <= 10: is_vid = True photo = await TgConverter.create_webm(xy) else: y = cv2.VideoCapture(xy) heh, lol = y.read() cv2.imwrite("ult.webp", lol) photo = "ult.webp" elif message.file and "tgsticker" in message.file.mime_type: await ultroid_bot.download_file( message.media.document, "AnimatedSticker.tgs", ) attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt is_anim = True photo = 1 elif message.message: photo = await create_quotly(message) else: return await xx.edit(get_string("com_4")) if not udB.get_key("language") or udB.get_key("language") == "en": ra = random.choice(KANGING_STR) else: ra = get_string("sts_11") await xx.edit(f"`{ra}`") if photo: splat = args.text.split() pack = 1 if not emoji: emoji = "🏵" if len(splat) == 3: pack = splat[2] # User sent ultroid_both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): pack = int(splat[1]) else: emoji = splat[1] packname = f"ult_{user.id}_{pack}" packnick = f"{username}'s Pack {pack}" cmd = "/newpack" file = io.BytesIO() if is_vid: packname += "_vid" packnick += " (Video)" cmd = "/newvideo" elif is_anim: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" else: image = con.resize_photo_sticker(photo) file.name = "sticker.png" image.save(file, "PNG") response = requests.get(f"http://t.me/addstickers/{packname}") htmlstr = response.text.split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with ultroid_bot.conversation("@Stickers") as conv: try: await conv.send_message("/addsticker") except YouBlockedUserError: LOGS.info("Unblocking @Stickers for kang...") await ultroid_bot( functions.contacts.UnblockRequest("stickers")) await conv.send_message("/addsticker") await conv.get_response() await conv.send_message(packname) x = await conv.get_response() if x.text.startswith( "Alright! Now send me the video sticker."): await conv.send_file(photo, force_document=True) x = await conv.get_response() t = "50" if (is_anim or is_vid) else "120" while t in x.message: pack += 1 packname = f"ult_{user.id}_{pack}" packnick = f"{username}'s Pack {pack}" if is_anim: packname += "_anim" packnick += " (Animated)" elif is_vid: packnick += " (Video)" packname += "_vid" await xx.edit(get_string("sts_13").format(pack)) await conv.send_message("/addsticker") await conv.get_response() await conv.send_message(packname) x = await conv.get_response() if x.text.startswith( "Alright! Now send me the video sticker."): await conv.send_file(photo, force_document=True) x = await conv.get_response() if x.text in [ "Invalid pack selected.", "Invalid set selected." ]: await conv.send_message(cmd) await conv.get_response() await conv.send_message(packnick) await conv.get_response() if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: if is_vid: file = photo else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await conv.send_message("/skip") await conv.get_response() await conv.send_message(packname) await conv.get_response() await xx.edit( get_string("sts_7").format(packname), parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") elif "send me an emoji" not in x.message: if is_vid: file = photo else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit(get_string("sts_8"), ) return await conv.send_message(emoji) await conv.get_response() await conv.send_message("/done") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) else: await xx.edit("`Brewing a new Pack...`") async with ultroid_bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() await conv.send_message(packnick) await conv.get_response() if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: if is_vid: file = photo else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit(get_string("sts_8"), ) return await conv.send_message(emoji) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await conv.send_message("/skip") await conv.get_response() await conv.send_message(packname) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await xx.edit( get_string("sts_12").format(emoji, packname), parse_mode="md", ) try: os.remove(photo) except BaseException: pass
async def stickertopic(context): try: if len(context.parameter) >= 1: if context.parameter[0][0].lower() == "y": as_file = True elif context.parameter[0][0].lower() == "n": as_file = False elif not context.parameter[0]: as_file = False else: raise IndexError else: as_file = False except: await context.edit("出错了呜呜呜 ~ 无效的参数。") return user = await bot.get_me() if not user.username: user.username = user.first_name message = await context.get_reply_message() custom_emoji = False animated = False await context.edit("开始转换...\n0%") if message and message.media: if isinstance(message.media, MessageMediaPhoto): photo = BytesIO() photo = await bot.download_media(message.photo, photo) elif isinstance(message.media, MessageMediaWebPage): await context.edit("出错了呜呜呜 ~ 目标不是贴纸 。") sleep(2) await context.delete() return elif "image" in message.media.document.mime_type.split('/'): photo = BytesIO() await context.edit("正在转换...\n████40%") await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): custom_emoji = True elif (DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in message.media.document.attributes): photo = BytesIO() await bot.download_file(message.media.document, "AnimatedSticker.tgs") for _ in range(len(message.media.document.attributes)): try: break except: pass custom_emoji = True animated = True photo = 1 else: await context.edit("出错了呜呜呜 ~ 目标不是贴纸 。") sleep(2) await context.delete() return else: await context.edit("出错了呜呜呜 ~ 目标不是贴纸 。") sleep(2) await context.delete() return if photo: if not custom_emoji: await context.edit("出错了呜呜呜 ~ 目标不是贴纸 。") sleep(2) await context.delete() return if not animated: await context.edit("正在转换...\n███████70%") image = Image.open(photo) filename = "sticker" + str(random())[2:] + ".png" image.save(filename, "PNG") else: await context.edit("出错了呜呜呜 ~ 目标不是**静态**贴纸 。") sleep(2) await context.delete() return await context.edit("正在上传...\n██████████99%") await bot.send_file(context.chat_id, filename, force_document=as_file) try: await context.delete() except: pass try: remove(filename) except: pass try: remove("AnimatedSticker.tgs") except: pass
async def kang(args): """ For .get or .kang command, kangs stickers or creates new ones. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Unsupported File!`") return else: await args.edit("`I can't kang that...`") return if photo: splat = args.text.split() if not emojibypass: emoji = "◾" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"{user.username}{pack}" packnick = f"{user.first_name} #{pack}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with bot.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"{user.username}{pack}" packnick = f"{user.first_name} Animated #{pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"`Sticker added in a Different Pack !\ \nThis Pack is Newly created!\ \nYour pack can be found [here](t.me/addstickers/{packname})", parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Get a Sticker ...`") async with bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"**Successfully added!**.\nYour sticker are saved in [this pack](t.me/addstickers/{packname})", parse_mode="md", )
async def kang(args): # sourcery no-metrics "To kang a sticker." photo = None emojibypass = False is_anim = False emoji = None message = await args.get_reply_message() user = await args.client.get_me() if not user.username: try: user.first_name.encode("utf-8").decode("ascii") username = user.first_name except UnicodeDecodeError: username = f"cat_{user.id}" else: username = user.username userid = user.id if message and message.media: if isinstance(message.media, MessageMediaPhoto): catevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await args.client.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): catevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await args.client.download_file(message.media.document, photo) if ( DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes ): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: catevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") await args.client.download_file( message.media.document, "AnimatedSticker.tgs" ) attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await edit_delete(args, "`Unsupported File!`") return else: await edit_delete(args, "`I can't kang that...`") return if photo: splat = ("".join(args.text.split(maxsplit=1)[1:])).split() emoji = emoji if emojibypass else "😂" pack = 1 if len(splat) == 2: if char_is_emoji(splat[0][0]): if char_is_emoji(splat[1][0]): return await catevent.edit("check `.info stickers`") pack = splat[1] # User sent both emoji = splat[0] elif char_is_emoji(splat[1][0]): pack = splat[0] # User sent both emoji = splat[1] else: return await catevent.edit("check `.info stickers`") elif len(splat) == 1: if char_is_emoji(splat[0][0]): emoji = splat[0] else: pack = splat[0] packnick = pack_nick(username, pack, is_anim) packname = pack_name(userid, pack, is_anim) cmd = "/newpack" stfile = io.BytesIO() if is_anim: cmd = "/newanimated" else: image = await resize_photo(photo) stfile.name = "sticker.png" image.save(stfile, "PNG") response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}") ) htmlstr = response.read().decode("utf8").split("\n") if ( " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr ): async with args.client.conversation("Stickers") as conv: packname, emoji = await add_to_pack( catevent, conv, args, packname, pack, userid, username, is_anim, stfile, emoji, cmd, ) await edit_delete( catevent, f"`Sticker kanged successfully!\ \nYour Pack is` [here](t.me/addstickers/{packname}) `and emoji for the kanged sticker is {emoji}`", parse_mode="md", time=10, ) else: await catevent.edit("`Brewing a new Pack...`") async with args.client.conversation("Stickers") as conv: otherpack, packname, emoji = await newpacksticker( catevent, conv, cmd, args, pack, packnick, stfile, emoji, packname, is_anim, ) if otherpack: await edit_delete( catevent, f"`Sticker kanged to a Different Pack !\ \nAnd Newly created pack is` [here](t.me/addstickers/{packname}) `and emoji for the kanged sticker is {emoji}`", parse_mode="md", time=10, ) else: await edit_delete( catevent, f"`Sticker kanged successfully!\ \nYour Pack is` [here](t.me/addstickers/{packname}) `and emoji for the kanged sticker is {emoji}`", parse_mode="md", time=10, )
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ user = await borg.get_me() if not user.username: try: user.first_name.encode("utf-8").decode("ascii") user.username = user.first_name except UnicodeDecodeError: user.username = f"cat_{user.id}" message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await borg.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await borg.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await borg.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Unsupported File!`") return else: await args.edit("`I can't kang that...`") return if photo: splat = args.text.split() emoji = emoji if emojibypass else "🌚" pack = 1 if len(splat) == 3: if char_is_emoji(splat[1]): if char_is_emoji(splat[2]): return await args.edit("check `.help kang1`") pack = splat[2] # User sent both emoji = splat[1] elif char_is_emoji(splat[2]): pack = splat[1] # User sent both emoji = splat[2] else: return await args.edit("check `.help kang1`") elif len(splat) == 2: if char_is_emoji(splat[1]): emoji = splat[1] else: pack = splat[1] packname = f"bang_bros_{pack}" packnick = f"@{user.username}'s Secret Layer Vol.{pack}" cmd = "/newpack" file = io.BytesIO() if is_anim: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" else: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with borg.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while ("Whoa! That's probably enough stickers for one pack, give it a break" in x.text): try: val = int(pack) pack = val + 1 except ValueError: pack = 1 if is_anim: packname = f"{user.username}_{pack}_anim" packnick = f"@{user.username}'s Layer Vol.{pack} (Animated)" else: packname = f"{user.username}_{pack}" packnick = f"@{user.username}'s Layer Vol.{pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if ("You can list several emoji in one message, but I recommend using no more than two per sticker" not in rsp.text): await borg.send_read_acknowledge(conv.chat_id) await args.edit( f"Failed to add sticker, use @Stickers bot to add the sticker manually.\n**error :**{rsp.txt}" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await borg.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker added in a Different Pack !\ \nThis Pack is Newly created!\ \nYour pack can be found [here](t.me/addstickers/{packname}) and emoji of the sticker added is {emoji}", parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if ("You can list several emoji in one message, but I recommend using no more than two per sticker" not in rsp.text): await borg.send_read_acknowledge(conv.chat_id) await args.edit( f"Failed to add sticker, use @Stickers bot to add the sticker manually.\n**error :**{rsp.text}" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) else: await args.edit("`Brewing a new Pack...`") async with borg.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if ("You can list several emoji in one message, but I recommend using no more than two per sticker" not in rsp.text): await args.edit( f"Failed to add sticker, use @Stickers bot to add the sticker manually.\n**error :**{rsp}" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await borg.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await borg.send_read_acknowledge(conv.chat_id) await args.edit( f"**Kanged in moi [Collection](t.me/addstickers/{packname})!**")
async def kang(args): user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if ( DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes ): emoji = message.media.document.attributes[1].alt if emoji != "👑": emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: return await args.edit("`File Tidak Didukung Lord!`") else: return await args.edit("`Gagal Mengambil Sticker Ini!`") if photo: splat = args.text.split() if not emojibypass: emoji = "👑" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] u_name = user.username user.first_name packname = f"by{u_name}_{pack}" custom_packnick = f"{pack} punya @{u_name}" or f"{custompack}" packnick = f"{custom_packnick}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}") ) htmlstr = response.read().decode("utf8").split("\n") if ( " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr ): async with bot.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"by{u_name}_{pack}" packnick = f"{custom_packnick}" await args.edit( "`Switching to Pack " + str(pack) + " due to insufficient space`" ) await conv.send_message(packname) x = await conv.get_response() if x.text == "Gagal Memilih Pack.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) return await args.edit( "__S1 dalam pencurian berhasil mencuri__" f" [stickers](t.me/addstickers/{packname})__!__", parse_mode="md", ) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: return await args.edit( "`Gagal Menambahkan Sticker, Gunakan` @Stickers ` Bot Untuk Menambahkan Sticker Anda.`" ) await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Membuat Pack Sticker Baru`") async with bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: return await args.edit( "`Gagal Menambahkan Sticker, Gunakan` @Stickers ` Bot Untuk Menambahkan Sticker.`" ) await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( "__S1 dalam pencurian berhasil mencuri__" f" [stickers](t.me/addstickers/{packname})__!__", parse_mode="md", )
async def _(event): if not event.reply_to_msg_id: await event.edit("`Reply to Any media..`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`reply to a image/sticker/video`") return await event.edit("`Downloading Media..`") if reply_message.photo: await bot.download_media( reply_message, "wc.png", ) elif ( DocumentAttributeFilename(file_name="AnimatedSticker.tgs") in reply_message.media.document.attributes ): await bot.download_media( reply_message, "wc.tgs", ) os.system("lottie_convert.py wc.tgs wc.png") elif reply_message.video: video = await bot.download_media( reply_message, "wc.mp4", ) extractMetadata(createParser(video)) os.system("ffmpeg -i wc.mp4 -vframes 1 -an -s 480x360 -ss 1 wc.png") else: await bot.download_media( reply_message, "wc.png", ) try: await event.edit("`Processing..`") text = open("resources/alice.txt", encoding="utf-8").read() image_color = np.array(Image.open("wc.png")) image_color = image_color[::1, ::1] image_mask = image_color.copy() image_mask[image_mask.sum(axis=2) == 0] = 255 edges = np.mean( [ gaussian_gradient_magnitude(image_color[:, :, i] / 255.0, 2) for i in range(3) ], axis=0, ) image_mask[edges > 0.08] = 255 wc = WordCloud( max_words=2500, mask=image_mask, max_font_size=35, random_state=38, relative_scaling=0, ) wc.generate(text) image_colors = ImageColorGenerator(image_color) wc.recolor(color_func=image_colors) wc.to_file("wc.png") await event.client.send_file( event.chat_id, "wc.png", reply_to=event.reply_to_msg_id, ) await event.delete() os.system("rm *.png *.mp4 *.tgs *.webp") except BaseException as e: os.system("rm *.png *.mp4 *.tgs *.webp") return await event.edit(str(e))
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ if not args.text[0].isalpha() and args.text[0] not in ("/", "#", "@", "!"): user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False if message and message.media: if isinstance(message.media, MessageMediaPhoto): photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True else: await args.edit("`Unsupported File!`") return else: await args.edit("`Reply to photo to kang it bisi.`") return if photo: image = await resize_photo(photo) splat = args.text.split() if not emojibypass: emoji = "🤔" pack = "1" if len(splat) == 3: pack = splat[2] #User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): #User wants to push into different pack, but is okay with thonk as emote. pack = int(splat[1]) else: #User sent just custom emote, wants to push to default pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') file = io.BytesIO() file.name = "sticker.png" image.save(file, "PNG") if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) await conv.get_response() file.seek(0) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit( "Userbot sticker pack doesn't exist! Making a new one!") async with bot.conversation('Stickers') as conv: await conv.send_message('/newpack') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message( f"@{user.username}'s userbot pack {pack}") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker copied! Now i go awey [here](t.me/addstickers/{packname})", parse_mode='md')
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = "" await args.edit("`Kanging..........`") if message and message.media: if isinstance(message.media, MessageMediaPhoto): photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif (DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in message.media.document.attributes): emoji = message.media.document.attributes[0].alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Unsupported File!`") return else: await args.edit("`Reply to photo to kang it bruh`") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s userbot pack {pack}" cmd = '/newpack' file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " animated" cmd = '/newanimated' response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while x.text == PACK_FULL: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s userbot pack {pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await bot.forward_messages('Stickers', [message.id], args.chat_id) else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker added in a Different Pack! This Pack is Newly created! Your pack can be found [here](t.me/addstickers/{packname})", parse_mode='md') return if is_anim: await bot.forward_messages('Stickers', [message.id], args.chat_id) else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("Userbot sticker pack \ doesn't exist! Making a new one!") async with bot.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await bot.forward_messages('Stickers', [message.id], args.chat_id) else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker added! Your pack can be found [here](t.me/addstickers/{packname})", parse_mode='md')
async def kang(event): await event.edit("`Kanging…`") reply = await event.get_reply_message() static_sticker = True from_image = False if reply: kang_image_data = await ldr.get_image(reply) if kang_image_data and not reply.document: from_image = True kang_emojis = event.args or "🤔" elif reply.document and DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply.media.document.attributes: static_sticker = False kang_image_data = reply.document kang_emojis = reply.file.emoji or "🤔" elif reply.sticker and reply.document and DocumentAttributeFilename(file_name='sticker.webp') in reply.media.document.attributes: kang_emojis = reply.file.emoji or "🤔" elif kang_image_data: from_image = True kang_emojis = event.args or "🤔" else: await event.edit("`Reply to an image or sticker to kang it!`") return else: await event.edit("`Reply to an image or sticker to kang it!`") return image_io = io.BytesIO() await event.client.download_media(kang_image_data, image_io) if from_image: try: sticker_image = Image.open(image_io) except: await event.edit("`You can't kang that!`") return image_io = resize_image(sticker_image) elif static_sticker: sticker_image = Image.open(image_io) if sticker_image.width != 512 or sticker_image.height != 512: image_io = resize_image(sticker_image) else: image_io = io.BytesIO() sticker_image.save(image_io, "PNG") image_io.name = "sticker.png" image_io.seek(0) else: image_io.name = "sticker.tgs" image_io.seek(0) me = await event.client.get_me() pack_number = 1 if not static_sticker: pack_nickname = f"@{me.username or me.first_name}'s kang pack {pack_number} animated" pack_name = f"a{me.id}_kangpack_{pack_number}_anim" cmd = '/newanimated' else: pack_nickname = f"@{me.username or me.first_name}'s kang pack {pack_number}" pack_name = f"a{me.id}_kangpack_{pack_number}" cmd = '/newpack' response = urllib.request.urlopen(urllib.request.Request(f'http://t.me/addstickers/{pack_name}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with event.client.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_message(pack_name) sticker_response = await conv.get_response() while sticker_response.text == pack_full: pack_number += 1 if not static_sticker: pack_nickname = f"@{me.username or me.first_name}'s kang pack {pack_number} animated" pack_name = f"a{me.id}_kangpack_{pack_number}_anim" else: pack_nickname = f"@{me.username or me.first_name}'s kang pack {pack_number}" pack_name = f"a{me.id}_kangpack_{pack_number}" await event.edit(f"`Switching to pack {pack_number} due to insufficient space.`") await conv.send_message(pack_name) sticker_response = await conv.get_response() if sticker_response.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_message(pack_nickname) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_file(image_io, force_document=True) await conv.get_response() await conv.send_message(kang_emojis) await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if not static_sticker: await conv.get_response() await conv.send_message(f"<{pack_nickname}>") await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(pack_name) await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await event.edit(f"`Sticker added in a different Pack! This pack is newly created! Your pack can be found `[here](t.me/addstickers/{pack_name})") return await conv.send_file(image_io, force_document=True) await conv.get_response() await conv.send_message(kang_emojis) await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) else: await event.edit("`Userbot sticker pack doesn't exist! Making a new one!`") async with event.client.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_message(pack_nickname) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_file(image_io, force_document=True) await conv.get_response() await conv.send_message(kang_emojis) await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if not static_sticker: await conv.get_response() await conv.send_message(f"<{pack_nickname}>") await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(pack_name) await event.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await event.client.send_read_acknowledge(conv.chat_id) await event.edit(f"`Sticker added! Your pack can be found `[here](t.me/addstickers/{pack_name})")
async def _handle_matrix_file( self, sender_id: TelegramID, event_id: EventID, space: TelegramID, client: 'MautrixTelegramClient', content: MediaMessageEventContent, reply_to: TelegramID, caption: TextMessageEventContent = None) -> None: mime = content.info.mimetype if isinstance(content.info, (ImageInfo, VideoInfo)): w, h = content.info.width, content.info.height else: w = h = None file_name = content["net.maunium.telegram.internal.filename"] max_image_size = config["bridge.image_as_file_size"] * 1000**2 if config["bridge.parallel_file_transfer"] and content.url: file_handle, file_size = await parallel_transfer_to_telegram( client, self.main_intent, content.url, sender_id) else: if content.file: if not decrypt_attachment: self.log.warning( f"Can't bridge encrypted media event {event_id}:" " matrix-nio not installed") return file = await self.main_intent.download_media(content.file.url) file = decrypt_attachment(file, content.file.key.key, content.file.hashes.get("sha256"), content.file.iv) else: file = await self.main_intent.download_media(content.url) if content.msgtype == MessageType.STICKER: if mime != "image/gif": mime, file, w, h = util.convert_image(file, source_mime=mime, target_type="webp") else: # Remove sticker description file_name = "sticker.gif" file_handle = await client.upload_file(file) file_size = len(file) file_handle.name = file_name attributes = [DocumentAttributeFilename(file_name=file_name)] if w and h: attributes.append(DocumentAttributeImageSize(w, h)) if (mime == "image/png" or mime == "image/jpeg") and file_size < max_image_size: media = InputMediaUploadedPhoto(file_handle) else: media = InputMediaUploadedDocument(file=file_handle, attributes=attributes, mime_type=mime or "application/octet-stream") if caption: if caption.formatted_body and caption.format == Format.HTML: caption, entities = formatter.matrix_to_telegram( caption.formatted_body) else: caption, entities = formatter.matrix_text_to_telegram( content.body) else: caption, entities = None, None async with self.send_lock(sender_id): if await self._matrix_document_edit(client, content, space, caption, media, event_id): return try: response = await client.send_media(self.peer, media, reply_to=reply_to, caption=caption, entities=entities) except (PhotoInvalidDimensionsError, PhotoSaveFileInvalidError, PhotoExtInvalidError): media = InputMediaUploadedDocument(file=media.file, mime_type=mime, attributes=attributes) response = await client.send_media(self.peer, media, reply_to=reply_to, caption=caption, entities=entities) self._add_telegram_message_to_db(event_id, space, 0, response) await self._send_delivery_receipt(event_id)
def test_download_files(self): m = Mock() m.document.attributes = [DocumentAttributeFilename('download.png')] m.document.size = 0 self.client.download_files('foo', [m])
async def pack_kang(event): if event.fwd_from: return user = await event.client.get_me() if user.username: username = user.username else: try: user.first_name.encode("utf-8").decode("ascii") username = user.first_name except UnicodeDecodeError: username = f"cat_{user.id}" photo = None userid = user.id is_anim = False emoji = None reply = await event.get_reply_message() cat = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not reply or media_type(reply) is None or media_type( reply) != "Sticker": return await edit_delete( event, "** ⪼ الرد على أي ملصق لإرسال جميع الملصقات في تلك الحزمة**") try: stickerset_attr = reply.document.attributes[1] icssevent = await edit_or_reply( event, "** ⪼ إحضار تفاصيل حزمة الملصقات ، برجاء الانتظار**") except BaseException: return await edit_delete(event, "**هذا ليس ملصقًا. الرد على ملصق**", 5) try: get_stickerset = await event.client( GetStickerSetRequest( InputStickerSetID( id=stickerset_attr.stickerset.id, access_hash=stickerset_attr.stickerset.access_hash, ))) except: return await edit_delete( icssevent, "⪼ أعتقد أن هذا الملصق ليس جزءًا من أي حزمة. لذا ، لا أستطيع أن احول هذا الملصق الى حزمتي", ) kangst = 1 reqd_sticker_set = await event.client( functions.messages.GetStickerSetRequest( stickerset=types.InputStickerSetShortName( short_name=f"{get_stickerset.set.short_name}"))) noofst = get_stickerset.set.count blablapacks = [] blablapacknames = [] pack = None for message in reqd_sticker_set.documents: if "image" in message.mime_type.split("/"): await edit_or_reply( icssevent, f"**جاري استنساخ حزمه الملصقات ↫ العدد : {kangst}/{noofst}**", ) photo = io.BytesIO() await event.client.download_file(message, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.attributes): emoji = message.attributes[1].alt elif "tgsticker" in message.mime_type: await edit_or_reply( icssevent, f"⪼ **جاري استنساخ حزمه الملصقات ↫ العدد : {kangst}/{noofst} 𓆰.**", ) await event.client.download_file(message, "AnimatedSticker.tgs") attributes = message.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt is_anim = True photo = 1 else: await edit_delete(catevent, "`Unsupported File!`") return if photo: splat = ("".join(event.text.split(maxsplit=1)[1:])).split() emoji = emoji or "😹" if pack is None: pack = 1 if len(splat) == 1: pack = splat[0] elif len(splat) > 1: return await edit_delete( icssevent, "** ⪼ عذرًا ، لا يمكن استخدام الاسم المعطى للحزمة أو لا توجد حزمة بهذا الاسم**", ) try: ics = Get(ics) await event.client(ics) except BaseException: pass packnick = pack_nick(username, pack, is_anim) packname = pack_name(userid, pack, is_anim) cmd = "/newpack" stfile = io.BytesIO() if is_anim: cmd = "/newanimated" else: image = await resize_photo(photo) stfile.name = "sticker.png" image.save(stfile, "PNG") response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." in htmlstr): async with event.client.conversation("Stickers") as conv: pack, icspackname = await newpacksticker( icssevent, conv, cmd, event, pack, packnick, stfile, emoji, packname, is_anim, pkang=True, ) else: async with event.client.conversation("Stickers") as conv: pack, icspackname = await add_to_pack( icssevent, conv, event, packname, pack, userid, username, is_anim, stfile, emoji, cmd, pkang=True, ) if icspackname not in blablapacks: blablapacks.append(icspackname) blablapacknames.append(pack) kangst += 1 await asyncio.sleep(2) result = "`This sticker pack is kanged into the following your sticker pack(s):`\n" for i in range(len(blablapacks)): result += f" • [pack {blablapacknames[i]}](t.me/addstickers/{blablapacks[i]})" await icssevent.edit(result)
async def kang(args): photo = None emojibypass = False is_anim = False emoji = None message = await args.get_reply_message() user = await args.client.get_me() if not user.username: try: user.first_name.encode("utf-8").decode("ascii") username = user.first_name except UnicodeDecodeError: username = f"cat_{user.id}" else: username = user.username userid = user.id if message and message.media: if isinstance(message.media, MessageMediaPhoto): icssevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await args.client.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): icssevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await args.client.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: icssevent = await edit_or_reply(args, f"`{random.choice(KANGING_STR)}`") await args.client.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await edit_delete(args, "⪼ ملف غير مدعم") return else: await edit_delete(args, "⪼ لايوجد ملصق او صوره لصنعه... ") return if photo: splat = ("".join(args.text.split(maxsplit=1)[1:])).split() emoji = emoji if emojibypass else "😹" pack = 1 if len(splat) == 2: if char_is_emoji(splat[0][0]): if char_is_emoji(splat[1][0]): return await catevent.edit("↮") pack = splat[1] # User sent both emoji = splat[0] elif char_is_emoji(splat[1][0]): pack = splat[0] # User sent both emoji = splat[1] else: return await icssevent.edit("↮") elif len(splat) == 1: if char_is_emoji(splat[0][0]): emoji = splat[0] else: pack = splat[0] packnick = pack_nick(username, pack, is_anim) packname = pack_name(userid, pack, is_anim) cmd = "/newpack" stfile = io.BytesIO() if is_anim: cmd = "/newanimated" else: image = await resize_photo(photo) stfile.name = "sticker.png" image.save(stfile, "PNG") response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with args.client.conversation("Stickers") as conv: packname, emoji = await add_to_pack( icssevent, conv, args, packname, pack, userid, username, is_anim, stfile, emoji, cmd, ) await edit_delete( icssevent, f"`⪼ تم صنع الملصق بنجاح \ \n⪼ لأضافه الملصق` [اضغط هنا](t.me/addstickers/{packname}) ` استخدم ↫ {emoji}` للعثور على الملصقات المصنوعه", parse_mode="md", time=10, ) else: await icssevent.edit("** ⪼ جاري صنع حزمه...**") async with args.client.conversation("Stickers") as conv: otherpack, packname, emoji = await newpacksticker( icssevent, conv, cmd, args, pack, packnick, stfile, emoji, packname, is_anim, ) if otherpack: await edit_delete( icssevent, f"`⪼ تم صنع الملصق لحزمه مختلفه !\ \n⪼ والحزمة التي تم إنشاؤها حديثًا هي` [اضغط هنا](t.me/addstickers/{packname}) ` استخدم↫ {emoji}` للعثور على الملصقات المصنوعه ", parse_mode="md", time=10, ) else: await edit_delete( icssevent, f"`⪼ تم صنع الملصق بنجاح\ \n⪼ تم صنع الملصق بنجاح الحزمه ` [هنا](t.me/addstickers/{packname}) ` سمايل الملصق هو {emoji}`", parse_mode="md", time=10, )
async def dizla(args): """ .dızla komutu çıkartmaları başka paketten alır ya da yeni bir çıkartma oluşturur. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{PLUGIN_MESAJLAR['dızcı']}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): await args.edit(f"`{PLUGIN_MESAJLAR['dızcı']}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{PLUGIN_MESAJLAR['dızcı']}`") await bot.download_file(message.media.document, 'AnimatedSticker.tgs') attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Desteklenmeyen dosya!`") return else: await args.edit("`Bunu dızlayamam...`") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # Kullanıcı ikisini de gönderebilir emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # Kullanıcı başka pakete eklemek istiyor. pack = int(splat[1]) else: # Kullanıcı sadece özel emoji istedi, varsayılan pakete eklemek istiyor. emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s @AsenaUserBot pack {pack}" cmd = '/newpack' file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animasyonlu)" cmd = '/newanimated' response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s @AsenaUserBot pack {pack}" await args.edit("`Yetersiz paket alanından dolayı " + str(pack) + " numaralı pakete geçiliyor`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Geçersiz paket seçildi.": await conv.send_message(cmd) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Kullanıcının sürekli bildirim almamasını sağlar. await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`Çıkartma başka bir pakete eklendi.\ \nBu paket yeni oluşturuldu.\ \nYeni paket [burada](t.me/addstickers/{packname}) bulunabilir.", parse_mode='md') return if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Çıkartma ekleme başarısız, ` @Stickers `botu ile elle eklemeyi deneyin.`" ) return await conv.send_message(emoji) # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Yeni paket oluşturuluyor...`") async with bot.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Çıkartma ekleme başarısız, ` @Stickers `botu ile elle eklemeyi deneyin.`" ) return await conv.send_message(emoji) # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Kullanıcının sürekli bildirim almamasını sağlar. await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Kullanıcının sürekli bildirim almamasını sağlar. await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`Çıkartma başarıyla pakete eklendi.`\ \nPaket [şurada](t.me/addstickers/{packname}) bulunabilir.", parse_mode='md')
async def sticker(context): """ Fetches images/stickers and add them to your pack. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await context.get_reply_message() custom_emoji = False animated = False emoji = "" await context.edit("Collecting sticker . . .") if message and message.media: if isinstance(message.media, MessageMediaPhoto): photo = BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): photo = BytesIO() await context.edit("Downloading image . . .") await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt custom_emoji = True elif (DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in message.media.document.attributes): photo = BytesIO() await bot.download_file(message.media.document, "AnimatedSticker.tgs") for index in range(len(message.media.document.attributes)): try: emoji = message.media.document.attributes[index].alt break except: pass custom_emoji = True animated = True photo = 1 else: await context.edit("`This file type is not supported.`") return else: await context.edit("`Please reply to a message with an image/sticker.`" ) return if photo: split_strings = context.text.split() if not custom_emoji: emoji = "👀" pack = 1 sticker_already = False if len(split_strings) == 3: pack = split_strings[2] emoji = split_strings[1] elif len(split_strings) == 2: if split_strings[1].isnumeric(): pack = int(split_strings[1]) else: emoji = split_strings[1] pack_name = f"{user.username}_{pack}" pack_title = f"@{user.username} 的私藏 ({pack})" command = '/newpack' file = BytesIO() if not animated: await context.edit("Resizing image . . .") image = await resize_image(photo) file.name = "sticker.png" image.save(file, "PNG") else: pack_name += "_animated" pack_title += " (animated)" command = '/newanimated' response = request.urlopen( request.Request(f'http://t.me/addstickers/{pack_name}'), context=ssl.create_default_context(cafile=certifi.where())) if not response.status == 200: await context.edit("Failed to connect to the telegram . . .") return http_response = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in \ http_response: for _ in range(20): # 最多重试20次 try: async with bot.conversation('Stickers') as conversation: await conversation.send_message('/addsticker') await conversation.get_response() await bot.send_read_acknowledge(conversation.chat_id) await conversation.send_message(pack_name) chat_response = await conversation.get_response() while chat_response.text == "Whoa! That's probably enough stickers for one pack, give it a break. \ A pack can't have more than 120 stickers at the moment.": pack += 1 pack_name = f"{user.username}_{pack}" pack_title = f"@{user.username} 的私藏 ({pack})" await context.edit( "Switching to pack " + str(pack) + " since previous pack is full . . .") await conversation.send_message(pack_name) chat_response = await conversation.get_response() if chat_response.text == "Invalid pack selected.": await add_sticker(conversation, command, pack_title, pack_name, animated, message, context, file, emoji) await context.edit( f"Sticker has been added to [this](t.me/addstickers/{pack_name}) pack.", parse_mode='md') return await upload_sticker(animated, message, context, file, conversation) await conversation.get_response() await conversation.send_message(emoji) await bot.send_read_acknowledge(conversation.chat_id) await conversation.get_response() await conversation.send_message('/done') await conversation.get_response() await bot.send_read_acknowledge(conversation.chat_id) break except AlreadyInConversationError: if not sticker_already: await context.edit( "Another command is adding stickers, trying again . . . " ) sticker_already = True else: pass await sleep(.5) except Exception: raise else: await context.edit("Pack does not exist, creating . . .") async with bot.conversation('Stickers') as conversation: await add_sticker(conversation, command, pack_title, pack_name, animated, message, context, file, emoji) notification = await context.edit( f"Sticker has been added to [this](t.me/addstickers/{pack_name}) pack.", parse_mode='md') await sleep(5) try: await notification.delete() except: pass
async def kang(args): user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt if emoji != "": emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: return await args.edit("`Unsupported File!`") else: return await args.edit("`Itu ga bisa dicolong...`") if photo: splat = args.text.split() if not emojibypass: emoji = "⚫" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s kang pack Vol.{pack}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with bot.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s kang pack Vol.{pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) return await args.edit( "`Sticker ditambahkan ke pack ynag berbeda !" "\nIni pack yang baru saja kamu buat!" f"\nKlik [disini](t.me/addstickers/{packname}) untuk liat pack kamj", parse_mode="md", ) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: return await args.edit( "`gagal menambahkan sticker, gunakan` @Stickers `bot untuk menambahkan sticker.`" ) await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Buat Pack sticker baru`") async with bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: return await args.edit( "`gagal menambahkan sticker, gunakan` @Stickers `bot untuk menambahkan sticker.`" ) await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( "`Sticker Sukses Tercolong!`" f"\nKlik [disini](t.me/addstickers/{packname}) kalo mau pake pack stikerku", parse_mode="md", )
async def ascii(event): if not event.reply_to_msg_id: await event.edit("`Reply to Any media..`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`reply to a image/sticker/video`") return await event.edit("`Downloading Media..`") if reply_message.photo: IMG = await bot.download_media( reply_message, "ascii.png", ) elif ( DocumentAttributeFilename(file_name="AnimatedSticker.tgs") in reply_message.media.document.attributes ): await bot.download_media( reply_message, "ASCII.tgs", ) os.system("lottie_convert.py ASCII.tgs ascii.png") IMG = "ascii.png" elif reply_message.video: video = await bot.download_media( reply_message, "ascii.mp4", ) extractMetadata(createParser(video)) os.system("ffmpeg -i ascii.mp4 -vframes 1 -an -s 480x360 -ss 1 ascii.png") IMG = "ascii.png" else: IMG = await bot.download_media( reply_message, "ascii.png", ) try: await event.edit("`Processing..`") list = await random_color() color1 = list[0] color2 = list[1] bgcolor = bground await asciiart(IMG, color1, color2, bgcolor) cmd = event.pattern_match.group(1) if cmd == "asciis": os.system("cp ascii.png ascii.webp") ascii_file = "ascii.webp" else: ascii_file = "ascii.png" await event.client.send_file( event.chat_id, ascii_file, force_document=False, reply_to=event.reply_to_msg_id, ) await event.delete() os.system("rm *.png") os.system("rm *.webp") os.system("rm *.mp4") os.system("rm *.tgs") except BaseException as e: os.system("rm *.png") os.system("rm *.webp") os.system("rm *.mp4") os.system("rm *.tgs") return await event.edit(str(e))
async def _handle_matrix_file( self, sender_id: TelegramID, event_id: EventID, space: TelegramID, client: 'MautrixTelegramClient', content: MediaMessageEventContent, reply_to: TelegramID, caption: TextMessageEventContent = None) -> None: mime = content.info.mimetype w, h = content.info.width, content.info.height file_name = content["net.maunium.telegram.internal.filename"] max_image_size = config["bridge.image_as_file_size"] * 1000**2 if config["bridge.parallel_file_transfer"]: file_handle, file_size = await parallel_transfer_to_telegram( client, self.main_intent, content.url, sender_id) else: file = await self.main_intent.download_media(content.url) if content.msgtype == MessageType.STICKER: if mime != "image/gif": mime, file, w, h = util.convert_image(file, source_mime=mime, target_type="webp") else: # Remove sticker description file_name = "sticker.gif" file_handle = await client.upload_file(file) file_size = len(file) file_handle.name = file_name attributes = [DocumentAttributeFilename(file_name=file_name)] if w and h: attributes.append(DocumentAttributeImageSize(w, h)) if (mime == "image/png" or mime == "image/jpeg") and file_size < max_image_size: media = InputMediaUploadedPhoto(file_handle) else: media = InputMediaUploadedDocument(file=file_handle, attributes=attributes, mime_type=mime or "application/octet-stream") caption, entities = self._matrix_event_to_entities( caption) if caption else (None, None) async with self.send_lock(sender_id): if await self._matrix_document_edit(client, content, space, caption, media, event_id): return try: response = await client.send_media(self.peer, media, reply_to=reply_to, caption=caption, entities=entities) except (PhotoInvalidDimensionsError, PhotoSaveFileInvalidError, PhotoExtInvalidError): media = InputMediaUploadedDocument(file=media.file, mime_type=mime, attributes=attributes) response = await client.send_media(self.peer, media, reply_to=reply_to, caption=caption, entities=entities) self._add_telegram_message_to_db(event_id, space, 0, response)
async def kang(args): if not args.text[0].isalpha() and args.text[0] not in ("/", "#", "@", "!"): user = await bot.get_me() userid = user.id username = user.username if not username: username = user.first_name message = await args.get_reply_message() photo = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) emojibypass = False elif "image" in message.media.document.mime_type.split('/'): photo = io.BytesIO() await bot.download_file(message.media.document, photo) if DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes: emoji = message.media.document.attributes[1].alt emojibypass = True else: await args.edit("`Unsupported File!`") return else: await args.edit("`Reply to photo to kang it bruh`") return if photo: image = Image.open(photo) maxsize = (512, 512) if (image.width and image.height) < 512: size1 = image.width size2 = image.height if image.width > image.height: scale = 512/size1 size1new = 512 size2new = size2 * scale else: scale = 512/size2 size1new = size1 * scale size2new = 512 size1new = math.floor(size1new) size2new = math.floor(size2new) sizenew = (size1new, size2new) image = image.resize(sizenew) else: image.thumbnail(maxsize) splat = args.text.split() if not emojibypass: emoji = "🤔" pack = "1" if len(splat) == 3: pack = splat[2] #User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): #User wants to push into different pack, but is okay with thonk as emote. pack = int(splat[1]) else: #User sent just custom emote, wants to push to default pack emoji = splat[1] packname = f"a{userid}_by_{username}_{pack}" response = urllib.request.urlopen(urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') file = io.BytesIO() file.name = "sticker.png" image.save(file, "PNG") if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) await conv.get_response() file.seek(0) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("userbot sticker pack doesn't exist! Making a new one!") async with bot.conversation('Stickers') as conv: await conv.send_message('/newpack') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(f"@{username}'s userbot pack {pack}") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"sticker added! Your pack can be found [here](t.me/addstickers/{packname})", parse_mode='md')
async def hehe(args): xx = await eor(args, "`Processing...`") user = await ultroid_bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await xx.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await ultroid_bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await xx.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await ultroid_bot.download_file(message.media.document, photo) if ( DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes ): emoji = message.media.document.attributes[1].alt elif "video" in message.media.document.mime_type.split("/"): await xx.edit(f"`{random.choice(KANGING_STR)}`") xy = await message.download_media() y = cv2.VideoCapture(xy) heh, lol = y.read() cv2.imwrite("ult.webp", lol) photo = "ult.webp" elif "tgsticker" in message.media.document.mime_type: await xx.edit(f"`{random.choice(KANGING_STR)}`") await ultroid_bot.download_file( message.media.document, "AnimatedSticker.tgs", ) attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt is_anim = True photo = 1 else: await xx.edit("`Unsupported File!`") return else: await xx.edit("`I can't kang that...`") return if photo: splat = args.text.split() emoji = "🏵" pack = 1 if len(splat) == 3: pack = splat[2] # User sent ultroid_both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): pack = int(splat[1]) else: emoji = splat[1] packname = f"ult_{user.id}_{pack}" packnick = f"@{user.username}'s Pack {pack}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}"), ) htmlstr = response.read().decode("utf8").split("\n") if ( " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr ): async with ultroid_bot.conversation("@Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"ult_{user.id}_{pack}" packnick = f"@{user.username}'s Pack {pack}" await xx.edit( "`Switching to Pack " + str(pack) + " due to insufficient space`", ) await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await xx.edit( f"`Sticker added in a Different Pack !\ \nThis Pack is Newly created!\ \nYour pack can be found` [here](t.me/addstickers/{packname})", parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`", ) return await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) else: await xx.edit("`Brewing a new Pack...`") async with ultroid_bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`", ) return await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await xx.edit( f"`Kanged!`\ \n`Emoji` - {emoji}\ \n`Sticker Pack` [here](t.me/addstickers/{packname})", parse_mode="md", ) try: os.remove(photo) except BaseException: pass
async def transform(event): if not event.reply_to_msg_id: await event.edit("`Reply to Any media..`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`reply to a image/sticker`") return await event.edit("`Downloading Media..`") if reply_message.photo: transform = await bot.download_media( reply_message, "transform.png", ) elif (DocumentAttributeFilename(file_name="AnimatedSticker.tgs") in reply_message.media.document.attributes): await bot.download_media( reply_message, "transform.tgs", ) os.system("lottie_convert.py transform.tgs transform.png") transform = "transform.png" elif reply_message.video: video = await bot.download_media( reply_message, "transform.mp4", ) extractMetadata(createParser(video)) os.system( "ffmpeg -i transform.mp4 -vframes 1 -an -s 480x360 -ss 1 transform.png" ) transform = "transform.png" else: transform = await bot.download_media( reply_message, "transform.png", ) try: await event.edit("`Transforming this media..`") cmd = event.pattern_match.group(1) im = Image.open(transform).convert("RGB") if cmd == "mirror": IMG = ImageOps.mirror(im) elif cmd == "flip": IMG = ImageOps.flip(im) elif cmd == "ghost": IMG = ImageOps.invert(im) elif cmd == "bw": IMG = ImageOps.grayscale(im) elif cmd == "poster": IMG = ImageOps.posterize(im, 2) IMG.save(Converted, quality=95) await event.client.send_file(event.chat_id, Converted, reply_to=event.reply_to_msg_id) await event.delete() os.system("rm *.mp4 *.tgs") os.remove(transform) os.remove(Converted) except BaseException: return
async def pack_kang(event): # sourcery no-metrics "To kang entire sticker sticker." user = await event.client.get_me() if user.username: username = user.username else: try: user.first_name.encode("utf-8").decode("ascii") username = user.first_name except UnicodeDecodeError: username = f"cat_{user.id}" photo = None userid = user.id is_anim = False emoji = None reply = await event.get_reply_message() cat = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not reply or media_type(reply) is None or media_type(reply) != "Sticker": return await edit_delete( event, "`reply to any sticker to send all stickers in that pack`" ) try: stickerset_attr = reply.document.attributes[1] catevent = await edit_or_reply( event, "`Fetching details of the sticker pack, please wait..`" ) except BaseException: return await edit_delete( event, "`This is not a sticker. Reply to a sticker.`", 5 ) try: get_stickerset = await event.client( GetStickerSetRequest( InputStickerSetID( id=stickerset_attr.stickerset.id, access_hash=stickerset_attr.stickerset.access_hash, ) ) ) except Exception: return await edit_delete( catevent, "`I guess this sticker is not part of any pack. So, i cant kang this sticker pack try kang for this sticker`", ) kangst = 1 reqd_sticker_set = await event.client( functions.messages.GetStickerSetRequest( stickerset=types.InputStickerSetShortName( short_name=f"{get_stickerset.set.short_name}" ) ) ) noofst = get_stickerset.set.count blablapacks = [] blablapacknames = [] pack = None for message in reqd_sticker_set.documents: if "image" in message.mime_type.split("/"): await edit_or_reply( catevent, f"`This sticker pack is kanging now . Status of kang process : {kangst}/{noofst}`", ) photo = io.BytesIO() await event.client.download_file(message, photo) if ( DocumentAttributeFilename(file_name="sticker.webp") in message.attributes ): emoji = message.attributes[1].alt elif "tgsticker" in message.mime_type: await edit_or_reply( catevent, f"`This sticker pack is kanging now . Status of kang process : {kangst}/{noofst}`", ) await event.client.download_file(message, "AnimatedSticker.tgs") attributes = message.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt is_anim = True photo = 1 else: await edit_delete(catevent, "`Unsupported File!`") return if photo: splat = ("".join(event.text.split(maxsplit=1)[1:])).split() emoji = emoji or "😂" if pack is None: pack = 1 if len(splat) == 1: pack = splat[0] elif len(splat) > 1: return await edit_delete( catevent, "`Sorry the given name cant be used for pack or there is no pack with that name`", ) try: cat = Get(cat) await event.client(cat) except BaseException: pass packnick = pack_nick(username, pack, is_anim) packname = pack_name(userid, pack, is_anim) cmd = "/newpack" stfile = io.BytesIO() if is_anim: cmd = "/newanimated" else: image = await resize_photo(photo) stfile.name = "sticker.png" image.save(stfile, "PNG") response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}") ) htmlstr = response.read().decode("utf8").split("\n") if ( " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." in htmlstr ): async with event.client.conversation("Stickers") as conv: pack, catpackname = await newpacksticker( catevent, conv, cmd, event, pack, packnick, stfile, emoji, packname, is_anim, pkang=True, ) else: async with event.client.conversation("Stickers") as conv: pack, catpackname = await add_to_pack( catevent, conv, event, packname, pack, userid, username, is_anim, stfile, emoji, cmd, pkang=True, ) if catpackname not in blablapacks: blablapacks.append(catpackname) blablapacknames.append(pack) kangst += 1 await asyncio.sleep(2) result = "`This sticker pack is kanged into the following your sticker pack(s):`\n" for i in enumerate(blablapacks): result += f" • [pack {blablapacknames[i]}](t.me/addstickers/{blablapacks[i]})" await catevent.edit(result)
async def glitch(event): if not event.reply_to_msg_id: await event.edit("`I Wont Glitch A Ghost!`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`reply to a image/sticker`") return await event.edit("`Downloading Media..`") if reply_message.photo: glitch_file = await bot.download_media( reply_message, "glitch.png", ) elif (DocumentAttributeFilename(file_name="AnimatedSticker.tgs") in reply_message.media.document.attributes): await bot.download_media( reply_message, "anim.tgs", ) os.system("lottie_convert.py anim.tgs anim.png") glitch_file = "anim.png" elif reply_message.video: video = await bot.download_media( reply_message, "glitch.mp4", ) extractMetadata(createParser(video)) os.system( "ffmpeg -i glitch.mp4 -vframes 1 -an -s 480x360 -ss 1 glitch.png") glitch_file = "glitch.png" else: glitch_file = await bot.download_media( reply_message, "glitch.png", ) try: value = int(event.pattern_match.group(1)) if value > 8: raise ValueError except ValueError: value = 2 await event.edit("```Glitching This Media..```") await asyncio.sleep(2) glitcher = ImageGlitcher() img = Image.open(glitch_file) glitch_img = glitcher.glitch_image(img, value, color_offset=True, gif=True) DURATION = 200 LOOP = 0 glitch_img[0].save( Glitched, format="GIF", append_images=glitch_img[1:], save_all=True, duration=DURATION, loop=LOOP, ) await event.edit("`Uploading Glitched Media..`") c_time = time.time() nosave = await event.client.send_file( event.chat_id, Glitched, force_document=False, reply_to=event.reply_to_msg_id, progress_callback=lambda d, t: asyncio.get_event_loop().create_task( progress(d, t, event, c_time, "[UPLOAD]")), ) await event.delete() os.remove(Glitched) await bot( functions.messages.SaveGifRequest( id=types.InputDocument( id=nosave.media.document.id, access_hash=nosave.media.document.access_hash, file_reference=nosave.media.document.file_reference, ), unsave=True, )) os.remove(glitch_file) os.system("rm *.tgs *.mp4")
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ if not args.text[0].isalpha() and args.text[0] not in ("/", "#", "@", "!"): user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, 'AnimatedSticker.tgs') attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("Unsupported File!") return else: await args.edit("I can't kang that...") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username} Sabertooth Ngentot{pack}" cmd = '/newpack' file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = '/newanimated' response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username} Sabertooth Ngentot{pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker added in a Different Pack! This Pack is Newly created! Your pack can be found [lihat disini](t.me/addstickers/{packname})", parse_mode='md') return if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "Failed to add sticker, use @Stickers bot to add the sticker manually." ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("Brewing a new Pack...") async with bot.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "Failed to add sticker, use @Stickers bot to add the sticker manually." ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"Sticker Berhasil Dicury/Successfully stolen! [lihat disini](t.me/addstickers/{packname})", parse_mode='md')
async def filenamecmd(self, message): """.filename <filename> + reply.file""" reply = await message.get_reply_message() if not reply or not reply.file: await message.edit(self.strings["wf"]) return name = utils.get_args_raw(message) if not name: await message.edit(self.strings["wn"]) return fn = reply.file.name if not fn: fn = "" fs = reply.file.size [await message.edit(f"<b>Downloading {fn}</b>") if fs > 500000 else ...] file = await reply.download_media(bytes) [await message.edit(f"<b>Uploading</b> <code>{name}</code>") if fs > 500000 else ...] await message.client.send_file(message.to_id, file, force_document=True, reply_to=reply, attributes=[DocumentAttributeFilename(file_name=name)]) await message.delete()
async def _(event): if event.fwd_from: return if not event.is_reply: await event.edit("Reply to a photo to add to my personal sticker pack." ) return reply_message = await event.get_reply_message() sticker_emoji = "🔥" input_str = event.pattern_match.group(1) if input_str: sticker_emoji = input_str if not is_message_image(reply_message): await event.edit("Invalid message type") return me = borg.me userid = event.from_id packname = f"{userid}'s @UniBorg Pack" packshortname = f"Uni_Borg_{userid}" # format: Uni_Borg_userid await event.edit("Processing this sticker. Please Wait!") async with borg.conversation("@Stickers") as bot_conv: now = datetime.datetime.now() dt = now + datetime.timedelta(minutes=1) file = await borg.download_file(reply_message.media) with BytesIO(file) as mem_file, BytesIO() as sticker: resize_image(mem_file, sticker) sticker.seek(0) uploaded_sticker = await borg.upload_file( sticker, file_name="@UniBorg_Sticker.png") if not await stickerset_exists(bot_conv, packshortname): await silently_send_message(bot_conv, "/cancel") response = await silently_send_message(bot_conv, "/newpack") if response.text != "Yay! A new stickers pack. How are we going to call it? Please choose a name for your pack.": await event.edit( f"**FAILED**! @Stickers replied: {response.text}") return response = await silently_send_message(bot_conv, packname) if not response.text.startswith("Alright!"): await event.edit( f"**FAILED**! @Stickers replied: {response.text}") return await bot_conv.send_file(InputMediaUploadedDocument( file=uploaded_sticker, mime_type='image/png', attributes=[ DocumentAttributeFilename("@UniBorg_Sticker.png") ]), force_document=True) await bot_conv.get_response() await silently_send_message(bot_conv, sticker_emoji) await silently_send_message(bot_conv, "/publish") await silently_send_message(bot_conv, "/skip") response = await silently_send_message(bot_conv, packshortname) if response.text == "Sorry, this short name is already taken.": await event.edit( f"**FAILED**! @Stickers replied: {response.text}") return else: await silently_send_message(bot_conv, "/cancel") await silently_send_message(bot_conv, "/addsticker") await silently_send_message(bot_conv, packshortname) await bot_conv.send_file(InputMediaUploadedDocument( file=uploaded_sticker, mime_type='image/png', attributes=[ DocumentAttributeFilename("@UniBorg_Sticker.png") ]), force_document=True) response = await bot_conv.get_response() await silently_send_message(bot_conv, response) await silently_send_message(bot_conv, sticker_emoji) await silently_send_message(bot_conv, "/done") await event.edit( f"sticker added! Your pack can be found [here](t.me/addstickers/{packshortname})" )
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split("/"): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt if emoji != "": emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, "AnimatedSticker.tgs") attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Arquivo não suportado!`") return else: await args.edit("`Não posso roubar isso...`") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username} kang library Book.{pack}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = urllib.request.urlopen( urllib.request.Request(f"http://t.me/addstickers/{packname}")) htmlstr = response.read().decode("utf8").split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with bot.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username} kang library Book.{pack}" await args.edit("`Trocando para pacote " + str(pack) + " devido a espaço insuficiente`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Pack inválido selecionado.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"`Sticker adicionado a um pacote diferente !\ \nEsse pacote foi criado recentemente!\ \nSeu pacote pode ser achado [aqui](t.me/addstickers/{packname})", parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Desculpe, o tipo de arquivo é inválido." in rsp.text: await args.edit( "`Falha ao adicionar adesivo, use` @Stickers `bot para adicionar o adesivo manualmente.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Preparando um novo pacote...`") async with bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Desculpe, o tipo de arquivo é inválido." in rsp.text: await args.edit( "`Falha ao adicionar adesivo, use` @Stickers `bot para adicionar o adesivo manualmente.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit( f"`Sticker roubado com sucesso!`\ \nPacote pode ser achado [aqui](t.me/addstickers/{packname})", parse_mode="md", )
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ kang_meme = random.choice(KANGING_STR) user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{kang_meme}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): await args.edit(f"`{kang_meme}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{kang_meme}`") await bot.download_file(message.media.document, 'AnimatedSticker.tgs') attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`Unsupported File!`") return else: await args.edit("`I can't kang that...`") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s pack Vol.{pack}" cmd = '/newpack' file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = '/newanimated' response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while x.text == PACK_FULL: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s pack Vol.{pack}" await args.edit(f"`{kang_meme}\ \nMoving on to Vol.{str(pack)}..`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`Haha, yes. New kang pack unlocked!\ \nPack can be found [here](t.me/addstickers/{packname})", parse_mode='md') return if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit(f"`{JAVES_NNAME}`: **Brewing a new Pack...**") async with bot.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`{JAVES_NNAME}`: **Sticker kanged successfully!**\ \nPack can be found [here](t.me/addstickers/{packname})", parse_mode='md')
async def colong(args): """ For .kang command, kangs stickers or creates new ones. """ user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit(f"`{random.choice(KANGING_STR)}`") await bot.download_file(message.media.document, 'AnimatedSticker.tgs') attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt emojibypass = True is_anim = True photo = 1 else: await args.edit("`File e Ora Support!`") return else: await args.edit("`aku ga iso nyolong kang...`") return if photo: splat = args.text.split() if not emojibypass: emoji = "🤔" pack = 1 if len(splat) == 3: pack = splat[2] # User sent both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): # User wants to push into different pack, but is okay with # thonk as emote. pack = int(splat[1]) else: # User sent just custom emote, wants to push to default # pack emoji = splat[1] packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s pack Vol.{pack}" cmd = '/newpack' file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = '/newanimated' response = urllib.request.urlopen( urllib.request.Request(f'http://t.me/addstickers/{packname}')) htmlstr = response.read().decode("utf8").split('\n') if " A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr: async with bot.conversation('Stickers') as conv: await conv.send_message('/addsticker') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s pack Vol.{pack}" await args.edit("`Switching to Pack " + str(pack) + " due to insufficient space`") await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`Stickermu nang pack liyane !\ \nIki Pack Sticker Nyarmu!\ \nNyo Link e [here](t.me/addstickers/{packname})", parse_mode='md') return if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message('/done') await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) else: await args.edit("`Nggawe Pack Nyar...`") async with bot.conversation('Stickers') as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file('AnimatedSticker.tgs') remove('AnimatedSticker.tgs') else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await args.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`" ) return await conv.send_message(emoji) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") # Ensure user doesn't get spamming notifications await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await bot.send_read_acknowledge(conv.chat_id) await args.edit(f"`sԵíckҽɾ ճҽɾհαsíl ժí cօlօղց ^_^!`\ \nNyo Pack sing nyar [terbaru](t.me/addstickers/{packname})", parse_mode='md')