async def WooMai(netase): if netase.fwd_from: return song = netase.pattern_match.group(1) chat = "@WooMaiBot" link = f"/netease {song}" await netase.edit("```Getting Your Music```") async with bot.conversation(chat) as conv: await asyncio.sleep(2) await netase.edit("`Downloading... Please wait`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() """ - don't spam notif - """ await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await netase.reply("```Please unblock @WooMaiBot and try again```") return await netase.edit("`Sending Your Music...`") await asyncio.sleep(3) await bot.send_file(netase.chat_id, respond) msg = await netase.client.delete_messages( conv.chat_id, [msg.id, response.id, respond.id]) await msg.edit( f"Song name - __{link}__\nUploaded by [TeleBot](https://t.me/TeleBotSupport)" ) await netase.delete()
async def DeezLoader(Deezlod): if Deezlod.fwd_from: return d_link = Deezlod.pattern_match.group(1) if ".com" not in d_link: await Deezlod.edit( "` I need a link to download something pro.`**(._.)**") else: await Deezlod.edit("**Initiating Download!**") chat = "@DeezLoadBot" async with bot.conversation(chat) as conv: try: msg_start = await conv.send_message("/start") response = await conv.get_response() r = await conv.get_response() msg = await conv.send_message(d_link) details = await conv.get_response() song = await conv.get_response() """ - don't spam notif - """ await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await Deezlod.edit("**Error:** `unblock` @DeezLoadBot `and retry!`" ) return await bot.send_file(Deezlod.chat_id, song, caption=details.text) msg = await Deezlod.client.delete_messages( conv.chat_id, [msg_start.id, response.id, r.id, msg.id, details.id, song.id]) await msg.edit( f"Song name - __{d_link}__\nUploaded by [TeleBot](https://t.me/TeleBotSupport)" ) await Deezlod.delete()
async def _(event): if event.fwd_from: return link = event.pattern_match.group(1) chat = "@SpotifyMusicDownloaderBot" await eor(event, f"```Searching for Song - ``` __{link}__") async with bot.conversation(chat) as conv: await asyncio.sleep(2) await eor(event, "`Downloading music, this might take some time...`") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930) ) await bot.send_message(chat, link) respond = await response except YouBlockedUserError: await event.reply( "```Please unblock @SpotifyMusicDownloaderBot and try again```" ) return await event.delete() msg = await bot.forward_messages(event.chat_id, respond.message) await msg.edit( f"Song name - __{link}__\nUploaded by [TeleBot](https://t.me/TeleBotSupport)" )
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: 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_TB_{pack}" packnick = (f"{telename} Vol.{pack}" if telename else f"@{user.username}'s TeleBot 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"{telename} Vol.{pack}" if telename else f"@{user.username}'s TeleBot 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"`Sticker kanged successfully!`\ \nPack can be found [here](t.me/addstickers/{packname})", parse_mode="md", )