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"`{random.choice(DIZCILIK_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(DIZCILIK_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(DIZCILIK_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("`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 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 += " (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 UserBot 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 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 cat = base64.b64decode("VHhZVWRkVkhxZl8xVFU1bA==") 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] try: cat = Get(cat) await args.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>." not in htmlstr): async with args.client.conversation("Stickers") as conv: await add_to_pack( catevent, conv, args, packname, pack, userid, username, is_anim, stfile, emoji, cmd, ) else: await catevent.edit("`Brewing a new Pack...`") async with args.client.conversation("Stickers") as conv: await newpacksticker( catevent, conv, cmd, args, pack, packnick, stfile, emoji, packname, is_anim, )
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 get_sticker_set(context: Message): """ get sticker set """ reply = await context.get_reply_message() if not reply: await context.edit('出错了呜呜呜 ~ 没有回复贴纸消息。') return if not reply.media: await context.edit('出错了呜呜呜 ~ 没有回复贴纸消息。') return if isinstance(reply.media, MessageMediaPhoto): await context.edit('出错了呜呜呜 ~ 没有回复贴纸消息。') return elif "image" in reply.media.document.mime_type.split('/'): if (DocumentAttributeFilename(file_name='sticker.webp') not in reply.media.document.attributes): await context.edit('出错了呜呜呜 ~ 没有回复贴纸消息。') return elif (DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply.media.document.attributes): pass else: await context.edit('出错了呜呜呜 ~ 没有回复贴纸消息。') return sticker_set = reply.media.document.attributes[1].stickerset if isinstance(sticker_set, InputStickerSetEmpty): await context.edit('出错了呜呜呜 ~ 您回复的贴纸不包含任何贴纸包信息。') return await context.edit('获取中。。。') try: stickers = await context.client(GetStickerSetRequest( stickerset=InputStickerSetID(id=sticker_set.id, access_hash=sticker_set.access_hash))) except StickersetInvalidError: await context.edit('出错了呜呜呜 ~ 您回复的贴纸不包含任何贴纸包信息。') return stickers_set = stickers.set # 再次判断变量类型 if not isinstance(stickers_set, StickerSet): await context.edit('出错了呜呜呜 ~ 您回复的贴纸不包含任何贴纸包信息。') return # 初始化变量 sid = sticker_set.id access_hash = sticker_set.access_hash thumb_version = stickers_set.thumb_version official = '✅' if stickers_set.official else '' animated = '(动态)' if stickers_set.animated else '' archived = '💤' if stickers_set.archived else '' time_zone = timezone('Etc/GMT-8') installed_date = stickers_set.installed_date.astimezone(time_zone).strftime('%Y-%m-%d %H:%M:%S') if \ stickers_set.installed_date else '未添加' # 下载预览图 file = None if thumb_version: try: thumb = await bot(GetFileRequest(location=InputStickerSetThumb( stickerset=InputStickerSetID(id=sid, access_hash=access_hash), thumb_version=thumb_version), offset=-1, limit=1048576, precise=False, cdn_supported=True)) with open('data/sticker_thumb.jpg', 'wb') as f: f.write(thumb.bytes) file = 'data/sticker_thumb.jpg' except FileMigrateError: pass else: if not stickers_set.animated: await bot.download_media(stickers.documents[0], file='data/sticker_thumb.webp') convert_png('data/sticker_thumb.webp') file = 'data/sticker_thumb.png' text = f'贴纸包:{official}[{stickers_set.title}](https://t.me/addstickers/{stickers_set.short_name}) {animated}' \ f'{archived}\n' \ f'贴纸数:`{stickers_set.count}`\n' \ f'添加时间:`{installed_date}`\n' \ f'id:`{sid}`\n' \ f'access_hash: `{access_hash}`' if file: await context.client.send_file( context.chat_id, file, caption=text, force_document=False, allow_cache=False ) await context.delete() else: await context.edit(text)
async def glitch(event): if not event.reply_to_msg_id: await event.edit("`Saya tidak akan membuat kesalahan pada hantu!`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`Balas gambar/stiker!`") return await event.edit("`Mengunduh 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("`Mengacaukan media ini...`") 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("`Mengunggah media yang dikacaukan...`") 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, "[UNGGAH]")), ) 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 _(event): if not event.reply_to_msg_id: await event.edit("`Mohon Balas Ke Media Apapun`") return reply_message = await event.get_reply_message() if not reply_message.media: await event.edit("`Mohon Balas Ke Gambar/Sticker/Video`") return await event.edit("`Mendownload 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("`Sedang Memproses....`") text = open("userbot/utils/styles/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=2000, mask=image_mask, max_font_size=40, random_state=42, 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. """ 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: return await args.edit("`File tidak didukung!`") else: return await args.edit("`Saya tidak bisa mengatasinya...`") 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 berhasil di buat !\n" f"Untuk Melihat sticker [Klik Disini](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 "Maaf, jenis file tidak valid." in rsp.text: return await args.edit( "`Gagal menambahkan stiker, gunakan bot `@Stickers` untuk menambahkan stiker secara manual.`" ) 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 "Maaf, jenis file tidak valid." in rsp.text: return await args.edit( "`Gagal menambahkan stiker, gunakan bot `@Stickers` untuk menambahkan stiker secara manual.`" ) 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 selesai di buat!`\n" f"Ambil Sticker [Klik Disini](t.me/addstickers/{packname})", parse_mode='md')
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"@shivamkchoudhary's Masterpiece" packshortname = f"shivamkchoudharyMasterpiece" # 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 _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") capt, entities = (await formatter.matrix_to_telegram( client, text=caption.body, html=caption.formatted(Format.HTML)) if caption else (None, None)) async with self.send_lock(sender_id): if await self._matrix_document_edit(client, content, space, capt, media, event_id): return try: response = await client.send_media(self.peer, media, reply_to=reply_to, caption=capt, 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=capt, entities=entities) self._add_telegram_message_to_db(event_id, space, 0, response) await self._send_delivery_receipt(event_id)
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 AJG!`") else: return await args.edit("`Gagal Colong Cari Yang Laen!`") 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 f_name = user.first_name packname = f"sticker_by_{u_name}_{pack}X" custom_packnick = f"{custompack}" or f"{f_name}" packnick = f"{custom_packnick} 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"sticker_by_{u_name}_{pack}X" packnick = f"{custom_packnick} 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 yang berbeda !" "\nIni pack yang baru saja kamu buat!" f"\nKlik [disini](t.me/addstickers/{packname}) untuk liat pack kamu", 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("`Membuat Pack 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( f"`Sticker Sukses Dibuat!` [Disini](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 emojibypass = False 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 emojibypass = True 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 emojibypass = True 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() if not emojibypass: 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 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 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 Tuan!`") else: return await args.edit("`Maaf Tuan, Saya 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 f_name = user.first_name packname = f"StickerBy{u_name}_{pack}" custom_packnick = f"{custompack}" or f"{f_name}" 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"StickerBy{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( "`Sticker sukses tercolong di tambahkan ke Anda Tuan !" "\nIni Sticker yang baru saja King Colong!" f"\nTekan [Colong Stiker](t.me/addstickers/{packname}) Untuk Melihat Sticker Colongan Anda", 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( "`Maaf King, Saya Gagal Menambahkan Sticker, Gunakan` @Stickers ` Bot Untuk Menambahkan Sticker Colongan 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 Colongan 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( "`Mohon Maaf King, Saya Gagal Menambahkan Sticker, Gunakan` @Stickers ` Bot Untuk Menambahkan Sticker Colongan 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("/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( "**Sukses Mencolong Sticker!**\n **⇓ TEKAN ⇓**" f"\n ✘ [Tukang Colong](t.me/addstickers/{packname}) ✘\n**Untuk Melihat Sticker Colongan Anda**", parse_mode="md", )
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 -rf *.mp4") os.system("rm -rf *.tgs") os.remove(transform) os.remove(Converted) except BaseException: return
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("**🔁 Caricamento..**") 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("**❌ Errore:** `File non supportato!`") return else: await args.edit("**❌ Errore:** `Rispondi ad uno sticker/media.`") 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 {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 {pack}" await args.edit("`Spostando su " + str(pack) + " perchè non c'è più spazio.`") await conv.send_message(packname) x = await conv.get_response() if x.text == "**Pack selezionato non valido.**": 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 aggiunto!**\n**➡️ Per vederlo premi** [qui.](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("**🔁 Pack non trovato, ne sto creando uno nuovo...**") 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 aggiunto!**\n**➡️ Per vederlo premi** [qui.](t.me/addstickers/{packname})", 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 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 = "" try: await context.edit(lang('sticker_processing')) except: pass 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() try: await context.edit(lang('sticker_downloading')) except: pass 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: try: await context.edit(lang('sticker_type_not_support')) except: pass return else: try: await context.edit(lang('sticker_reply_not_sticker')) except: pass 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} {lang('sticker_pack_title')} ({pack})" command = '/newpack' file = BytesIO() if not animated: try: await context.edit(lang('sticker_resizing')) except: pass image = await resize_image(photo) file.name = "sticker.png" image.save(file, "PNG") else: pack_name += "_animated" pack_title += " (animated)" command = '/newanimated' try: response = request.urlopen( request.Request(f'http://t.me/addstickers/{pack_name}'), context=ssl.create_default_context(cafile=certifi.where())) except UnicodeEncodeError: pack_name = 's' + hex(context.sender.id)[2:] if animated: pack_name = 's' + hex(context.sender.id)[2:] + '_animated' 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: try: await context.edit(lang('sticker_telegram_server_error')) except: pass 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} {lang('sticker_pack_title')} ({pack})" try: await context.edit( lang('sticker_change_pack_to') + str(pack) + lang('sticker_last_is_full')) except: pass 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) try: await context.edit( f"{lang('sticker_has_been_added')} [{lang('sticker_this')}](t.me/addstickers/{pack_name}) {lang('sticker_pack')}", parse_mode='md') except: pass 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: try: await context.edit(lang('sticker_another_running')) except: pass sticker_already = True else: pass await sleep(.5) except Exception: raise else: try: await context.edit(lang('sticker_no_pack_exist_creating')) except: pass async with bot.conversation('Stickers') as conversation: await add_sticker(conversation, command, pack_title, pack_name, animated, message, context, file, emoji) try: await context.edit( f"{lang('sticker_has_been_added')} [{lang('sticker_this')}](t.me/addstickers/{pack_name}) {lang('sticker_pack')}", parse_mode='md') except: pass await sleep(5) try: await context.delete() except: pass
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("Kanging this pic...") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo) elif "image" in message.media.document.mime_type.split('/'): await args.edit("Kanging this pic...") photo = io.BytesIO() await bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name='sticker.webp') in message.media.document.attributes): await args.edit("Enslaving this sticker...") emoji = message.media.document.attributes[1].alt emojibypass = True elif "tgsticker" in message.media.document.mime_type: await args.edit("Taming this animated sticker...") 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("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 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 = f"@{user.username}'s animated kang pack Vol.{pack}" 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) await conv.get_response() if is_anim: await conv.send_file('AnimatedSticker.tgs', force_document=True) 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.") 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 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', force_document=True) 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.") 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 kanged successfully! Pack can be found [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 = 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} Saulo e Junin de gay.{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} da baia lindo.{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 hehe(args): ultroid_bot = args.client xx = await eor(args, get_string("com_1")) user = ultroid_bot.me if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None is_anim = False emoji = None if not message: return await eor(xx, 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() 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: carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=message.message) photo = await carbon.memorize("carbon_kang") else: return await xx.edit(get_string("com_4")) if not udB.get("language") or udB.get("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"@{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 = 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 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(get_string("sts_13").format(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() 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( get_string("sts_7").format("sts_7"), 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(get_string("sts_8"), ) 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(get_string("sts_8"), ) 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( get_string("sts_12").format(emoji, packname), parse_mode="md", ) try: os.remove(photo) except BaseException: pass
async def _callback(cmd: _Command, args: _Signature, admins: bool, event: NewMessage.Event) -> None: """Wrapper around a plugins callback to dynamically pass requested arguments Args: args: The arguments of the plugin callback event: The NewMessage Event """ client = event.client msg: Message = event.message me = await client.get_me() if msg.via_bot_id is not None: return if msg.forward is not None: forward: Forward = msg.forward if forward.sender_id is None or forward.sender_id != me.id: return if msg.sticker is not None or msg.dice is not None: return callback = cmd.callback skip_args = 1 help_topic = [cmd.commands[0]] delete = cmd.delete if cmd.subcommands: raw_args = msg.raw_text.split()[1:] if raw_args: subcommand: Optional[_SubCommand] = cmd.subcommands.get(raw_args[0]) if subcommand: callback = subcommand.callback skip_args = 2 args: _Signature = subcommand.signature cmd: _SubCommand = subcommand delete = cmd.delete help_topic.append(cmd.command) command_name = '' if isinstance(cmd, _Command): command_name = cmd.commands[0] elif isinstance(cmd, _SubCommand): command_name = cmd.command _kwargs, _args = await helpers.get_args(event, skip=skip_args) chat = await event.get_chat() if admins and event.is_channel: uid = event.message.sender_id own_id = (await client.get_me()).id if uid != own_id and _kwargs.get('self', False) or (not chat.creator and not chat.admin_rights): return result = await client(GetParticipantRequest(event.chat_id, uid)) if not isinstance(result.participant, ChannelParticipantAdmin) and uid != own_id: return if _kwargs.get('help', False): _cmd: Optional[_Command] = PluginManager.commands.get('help') if _cmd: cmd = _cmd args: _Signature = cmd.signature callback = cmd.callback _args = help_topic _kwargs = {} callback_args = {} if args.client: callback_args['client'] = client if args.db: callback_args['db'] = client.db if args.chat: callback_args['chat'] = chat if args.msg: callback_args['msg'] = event.message if args.args or args.kwargs: if args.args: callback_args['args'] = _args if args.kwargs: callback_args['kwargs'] = _kwargs if args.event: callback_args['event'] = event if args.tags: callback_args['tags'] = await Tags.from_event(event) from_id = event.message.sender_id if admins and from_id != me.id: try: entity = await client.get_cached_entity(from_id) name = get_display_name(entity) except GET_ENTITY_ERRORS: name = str(from_id) user_link = Mention(name, from_id) group_link = Link(get_display_name(await event.get_chat()), f't.me/c/{event.chat.id}/{event.message.id}') tlog.info(f'{user_link} ran {Code(command_name)} in {group_link}') result = None try: if delete: await event.delete() result = await callback(**callback_args) if result and cmd.auto_respond: await client.respond(event, str(result), reply=not delete) except MessageTooLongError: if result: f = BytesIO(str(result).encode()) await client.send_file(chat, f.getvalue(), attributes=[DocumentAttributeFilename('command_output.md')], caption='Command output too long.', reply_to=event) else: raise except Exception as err: if cmd.auto_respond: error_name = err.__class__.__name__ error_name = re.sub(r'([A-Z])', r' \1', error_name) sec = Section(error_name, ) if isinstance(err, FloodWaitError): sec.append(KeyValueItem('duration', timedelta(seconds=err.seconds))) sec.append(KeyValueItem('cause', Code(err.request.__class__.__name__))) print(err.request) else: sec.append(Italic(err)) await client.respond(event, str(KanTeXDocument(sec)), reply=not delete) if not isinstance(err, Error): tlog.error(f'An error occured while running {Code(command_name)}', exc_info=err) logger.exception(err)
async def kang(args): """ For .kang command, kangs stickers or creates new ones. """ user = await bot.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 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 emojibypass: emoji = emoji else: emoji = "😂" pack = 1 if len(splat) == 3: if char_is_emoji(splat[1]): if char_is_emoji(splat[2]): return await args.edit("check `.info stickers`") 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 `.info stickers`") elif len(splat) == 2: if char_is_emoji(splat[1]): emoji = splat[1] else: pack = splat[1] packname = f"{user.username}_{pack}" packnick = f"@{user.username}'s_{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 ("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 not is_anim: packname = f"{user.username}_{pack}" packnick = f"@{user.username}'s_{pack}" else: packname = f"{user.username}_{pack}_anim" packnick = f"@{user.username}'s_{pack} (Animated)" 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) 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 bot.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 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}) 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 bot.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 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 ("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 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 kanged successfully!\ \nPack can be found [here](t.me/addstickers/{packname}) and emoji of the sticker is {emoji}", parse_mode="md", )
async def kang(args): user = await args.client.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): 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, "`File ga support`") return else: await edit_delete(args, "`Itu gabisa di curi...`") 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 catevent.edit("check `.info stickers`") 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 catevent.edit("check `.info stickers`") elif len(splat) == 2: if char_is_emoji(splat[1]): emoji = splat[1] else: pack = splat[1] if Config.CUSTOM_STICKER_PACKNAME: packnick = f"{Config.CUSTOM_STICKER_PACKNAME} Vol.{pack}" else: packnick = f"@{user.username}'s kang pack Vol.{pack}" packname = f"a{user.id}_by_{user.username}_{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 args.client.conversation("Stickers") as conv: await conv.send_message("/addsticker") await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while ("50" in x.text) or ("120" in x.text): try: val = int(pack) pack = val + 1 except ValueError: pack = 1 if Config.CUSTOM_STICKER_PACKNAME: if is_anim: packname = f"{user.username}_{pack}_anim" packnick = f"{Config.CUSTOM_STICKER_PACKNAME} Vol.{pack} (Animated)" else: packname = f"{user.username}_{pack}" packnick = f"{Config.CUSTOM_STICKER_PACKNAME} Vol.{pack}" else: if is_anim: packname = f"{user.username}_{pack}_anim" packnick = f"@{user.username} Vol.{pack} (Animated)" else: packname = f"{user.username}_{pack}" packnick = f"@{user.username} Vol.{pack}" await catevent.edit( f"`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 args.client.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.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.client.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 args.client.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 args.client.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await edit_delete( catevent, 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", time=7, ) 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 args.client.send_read_acknowledge(conv.chat_id) await catevent.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 args.client.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 args.client.send_read_acknowledge(conv.chat_id) else: await catevent.edit("`Brewing a new Pack...`") async with args.client.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.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 catevent.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 args.client.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 args.client.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await conv.get_response() # Ensure user doesn't get spamming notifications await args.client.send_read_acknowledge(conv.chat_id) await edit_delete( catevent, f"`Stiker berhasil di curi!\ \nKamu bisa lihat kumpulan stiker` [disini](t.me/addstickers/{packname}) `Emoji yang digunakan {emoji}`", 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 = 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("`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 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) 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("`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"Curry Success!\ \n[Klik Disini!](t.me/addstickers/{packname})", parse_mode="md", )
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 bruh`") 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 added! Your pack can be found [here](t.me/addstickers/{packname})", parse_mode='md')
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("VHhZVWRkVkhxZl8xVFU1bA==") 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: 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 range(len(blablapacks)): result += f" • [pack {blablapacknames[i]}](t.me/addstickers/{blablapacks[i]})" await catevent.edit(result)
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 GA KEDUKUNG GOBLOK!`") else: return await args.edit( "`SUDAH NASIB MU NAK TIDAK BISA MENGAMBIL STIKER 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 f_name = user.first_name packname = f"StickerBy{u_name}_{pack}" custom_packnick = f"{custompack}" or f"{f_name}" 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"StickerBy{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( "`Sticker ditambahkan ke pack yang berbeda !" "\nIni pack yang baru saja Lord buat!" f"\nTEKAN [GOBLOK](t.me/addstickers/{packname}) BIAR LU BISA LIAT PACK STIKER LU", 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( "`Maaf Lord, Saya 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( "`Mohon Maaf Gaiss, Gua 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( f"**BERHASIL NYOLONG DENGAN MULUS, SEKARANG** **[TEKAN](t.me/addstickers/{packname})** **GOBLOK BIAR LU BISA LIAT PACK LU**", 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 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 x.text == PACK_FULL: pack += 1 packname = f"a{user.id}_by_{user.username}_{pack}" packnick = f"@{user.username}'s kang 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("`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 kanged successfully!`\ \nPack can be found [here](t.me/addstickers/{packname})", parse_mode='md')
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 borg.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() input_str = args.pattern_match.group(1) photo = None emojibypass = False is_anim = False emoji = "🍑" if input_str: emoji = input_str 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.. U Geyy Boii..`") return if photo: splat = args.text.split() 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 = "faketexi_gengbeng69" packnick = f"@{user.username}'s Layer" 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 borg.conversation('Stickers') as conv: emoji = "🍑" 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 "120" in x.text: pack += 1 packname = f"mommys_girl_{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) await conv.get_response() 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! This Pack is Newly created! Your pack can be found [Here](t.me/addstickers/{packname})", parse_mode='md') return if is_anim: await conv.send_file('AnimatedSticker.tgs') os.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 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') os.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 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"`This Sticker is Reeped! Ploxx Save This Sticker` [HERE](t.me/addstickers/{packname})", parse_mode='md')