Exemplo n.º 1
0
async def WooMai(netase):
    if netase.fwd_from:
        return
    song = netase.pattern_match.group(1)
    chat = "@WooMaiBot"
    link = f"/netease {song}"
    await edit_or_reply(netase, "```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)
    await netase.client.delete_messages(conv.chat_id,
                                        [msg.id, response.id, respond.id])
    await netase.delete()
Exemplo n.º 2
0
async def DeezLoader(Deezlod):
    if Deezlod.fwd_from:
        return
    d_link = Deezlod.pattern_match.group(1)
    if ".com" not in d_link:
        await edit_or_reply(
            Deezlod, "` I need a link to download something pro.`**(._.)**")
    else:
        await edit_or_reply(Deezlod, "**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 edit_or_reply(
                Deezlod, "**Error:** `unblock` @DeezLoadBot `and retry!`")
            return
        await bot.send_file(Deezlod.chat_id, song, caption=details.text)
        await Deezlod.client.delete_messages(
            conv.chat_id,
            [msg_start.id, response.id, r.id, msg.id, details.id, song.id])
        await Deezlod.delete()
Exemplo n.º 3
0
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        jevent = await eor(event, "```Reply to any user message.```")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.text:
        await jevent.edit("```Reply to text message```")
        return
    chat = "@QuotLyBot"
    reply_message.sender
    if reply_message.sender.bot:
        await jevent.edit("```Reply to actual users message.```")
        return
    await jevent.edit("```Making a Quote```")
    async with bot.conversation(chat) as conv:
        try:
            response = conv.wait_event(
                events.NewMessage(incoming=True, from_users=1031952739))
            await bot.forward_messages(chat, reply_message)
            response = await response
        except YouBlockedUserError:
            await jevent.edit("```Please unblock @QuotLyBot and try again```")
            return
        if response.text.startswith("Hi!"):
            await jevent.edit(
                "```Can you kindly disable your forward privacy settings for good?```"
            )
        else:
            await event.delete()
            await bot.forward_messages(event.chat_id, response.message)
Exemplo n.º 4
0
async def _(event):
    if event.fwd_from:
        return
    link = event.pattern_match.group(1)
    chat = "@SpotifyMusicDownloaderBot"
    await edit_or_reply(event, "```Getting Your Music```")
    async with bot.conversation(chat) as conv:
        await asyncio.sleep(2)
        await event.edit(
            "`Downloading music taking some times,  Stay Tuned.....`")
        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()
        await bot.forward_messages(event.chat_id, respond.message)
Exemplo n.º 5
0
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&nbsp;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')
Exemplo n.º 6
0
async def sticker(context):
    """ Fetches images/stickers and add them to your pack. """
    if not context.text[0].isalpha() and context.text[0] not in ("/", "#", "@",
                                                                 "!"):
        user = await bot.get_me()
        if not user.username:
            user.username = user.first_name
        message = await context.get_reply_message()
        custom_emoji = False
        animated = False
        emoji = ""
        await context.edit("Collecting sticker . . .")
        if message and message.media:
            if isinstance(message.media, MessageMediaPhoto):
                photo = BytesIO()
                photo = await bot.download_media(message.photo, photo)
            elif "image" in message.media.document.mime_type.split('/'):
                photo = BytesIO()
                await context.edit("Downloading image . . .")
                await bot.download_file(message.media.document, photo)
                if (DocumentAttributeFilename(file_name='sticker.webp')
                        in message.media.document.attributes):
                    emoji = message.media.document.attributes[1].alt
                    custom_emoji = True
            elif (DocumentAttributeFilename(file_name='AnimatedSticker.tgs')
                  in message.media.document.attributes):
                emoji = message.media.document.attributes[0].alt
                custom_emoji = True
                animated = True
                photo = 1
            else:
                await context.edit("`This file type is not supported.`")
                return
        else:
            await context.edit(
                "`Please reply to a message with an image/sticker.`")
            return

        if photo:
            split_strings = context.text.split()
            if not custom_emoji:
                emoji = "👀"
            pack = 1
            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"pack_{user.id}_{user.username}_{pack}"
            pack_title = f"@{user.username}'s collection ({pack})"
            command = '/newpack'
            file = BytesIO()

            if not animated:
                await context.edit("Resizing image . . .")
                image = await resize_image(photo)
                file.name = "sticker.png"
                image.save(file, "PNG")
            else:
                pack_name += "_animated"
                pack_title += " (animated)"
                command = '/newanimated'

            response = request.urlopen(
                request.Request(f'http://t.me/addstickers/{pack_name}'))
            http_response = response.read().decode("utf8").split('\n')

            if "  A <strong>Telegram</strong> user has created the <strong>Sticker&nbsp;Set</strong>." not in \
                    http_response:
                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"a{user.id}_by_{user.username}_{pack}"
                        pack_title = f"@{user.username}'s collection ({pack})"
                        await context.edit("Switching to pack " + str(pack) +
                                           " since previous pack is full . . ."
                                           )
                        await conversation.send_message(pack_name)
                        chat_response = await conversation.get_response()
                        if chat_response.text == "Invalid pack selected.":
                            await add_sticker(conversation, command,
                                              pack_title, pack_name, bot,
                                              animated, message, context, file,
                                              emoji)
                            await context.edit(
                                f"Sticker has been added to [this](t.me/addstickers/{pack_name}) alternative pack.",
                                parse_mode='md')
                            return
                    await upload_sticker(animated, bot, 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)
            else:
                await context.edit("Pack does not exist, creating . . .")
                async with bot.conversation('Stickers') as conversation:
                    await add_sticker(conversation, command, pack_title,
                                      pack_name, bot, animated, message,
                                      context, file, emoji)

            await context.edit(
                f"Sticker has been added to [this](t.me/addstickers/{pack_name}) pack.",
                parse_mode='md')
Exemplo n.º 7
0
async def _(event):
    chat_id = event.sender_id
    event.sender_id
    if not pmpermit_sql.is_approved(chat_id):
        chat = await event.get_chat()
        if event.fwd_from:
            return
        if not event.is_private:
            return
        PM = (
            "`Hello. You are Accessing The Availabe Menu of My Master,`"
            f"{DEFAULTUSER}.\n"
            "__Let's make this smooth and let me know why you are here ! So Select A Reason And Send it's Number__\n"
            "**Choose one of the following reasons why you are here:**\n\n"
            "`1`. To chat with my master\n"
            "`2`. To Spam my master's Inbox.\n"
            "`3`. To enquire something\n"
            "`4`. To request something\n"
        )
        ONE = "`I Have Registered Your Request ! Don't Worry My Master Will Be Here Soon To Chat With You !` \n\n"
        TWO = "`Please Don't Spam My Master Inbox ! You Have Been Reported Until Further Notice !`"
        FOUR = "`Okay ! I See You Can Request Your Demands ! Please Wait Untill My Master Approves You` !"
        FIVE = "`Okay. please have the basic manners as to not bother my master too much. If he wishes to help you, he will respond to you soon.`\n**Kindly Do not ask repeatdly else you will be blocked and reported.**"
        LWARN = "**This is your last warning. DO NOT send another message else you will be blocked and reported. Keep patience. My master will respond you ASAP.**\n__Use__ `/start` __to go back to the main menu.__"

        async with bot.conversation(chat) as conv:
            if pmpermit_sql.is_approved(chat_id):
                return
            await bot.send_message(chat, PM)
            chat_id = event.sender_id
            chat = await event.get_chat()
            response = await conv.get_response(chat)
            y = response.text
            if y == "1":
                if pmpermit_sql.is_approved(chat_id):
                    return
                await bot.send_message(chat, ONE)
                response = await conv.get_response(chat)
                await event.delete()
                if not response.text == "/start":
                    await response.delete()
                    if pmpermit_sql.is_approved(chat_id):
                        return
                    await bot.send_message(chat, LWARN)
                    response = await conv.get_response(chat)
                    await event.delete()
                    await response.delete()
                    response = await conv.get_response(chat)
                    if not response.text == "/start":
                        if pmpermit_sql.is_approved(chat_id):
                            return
                        await bot.send_message(chat, TWO)
                        await asyncio.sleep(3)
                        await event.client(functions.contacts.BlockRequest(chat_id))
            elif y == "2":
                if pmpermit_sql.is_approved(chat_id):
                    return
                await bot.send_message(chat, LWARN)
                response = await conv.get_response(chat)
                if not response.text == "/start":
                    if pmpermit_sql.is_approved(chat_id):
                        return
                    await bot.send_message(chat, TWO)
                    await asyncio.sleep(3)
                    await event.client(functions.contacts.BlockRequest(chat_id))
            elif y == "3":
                if pmpermit_sql.is_approved(chat_id):
                    return
                await bot.send_message(chat, FOUR)
                response = await conv.get_response(chat)
                await event.delete()
                await response.delete()
                if not response.text == "/start":
                    if pmpermit_sql.is_approved(chat_id):
                        return
                    await bot.send_message(chat, LWARN)
                    await event.delete()
                    response = await conv.get_response(chat)
                    if not response.text == "/start":
                        if pmpermit_sql.is_approved(chat_id):
                            return
                        await bot.send_message(chat, TWO)
                        await asyncio.sleep(3)
                        await event.client(functions.contacts.BlockRequest(chat_id))
            elif y == "4":
                if pmpermit_sql.is_approved(chat_id):
                    return
                await bot.send_message(chat, FIVE)
                response = await conv.get_response(chat)
                if not response.text == "/start":
                    if pmpermit_sql.is_approved(chat_id):
                        return
                    await bot.send_message(chat, LWARN)
                    response = await conv.get_response(chat)
                    if not response.text == "/start":
                        if pmpermit_sql.is_approved(chat_id):
                            return
                        await bot.send_message(chat, TWO)
                        await asyncio.sleep(3)
                        await event.client(functions.contacts.BlockRequest(chat_id))
            else:
                if pmpermit_sql.is_approved(chat_id):
                    return
                await bot.send_message(
                    chat,
                    "`You have entered an invalid command. Please send /start again or do not send another message if you do not wish to be blocked and reported.`",
                )
                response = await conv.get_response(chat)
                z = response.text
                if not z == "/start":
                    if pmpermit_sql.is_approved(chat_id):
                        return
                    await bot.send_message(chat, LWARN)
                    await conv.get_response(chat)
                    if not response.text == "/start":
                        if pmpermit_sql.is_approved(chat_id):
                            return
                        await bot.send_message(chat, TWO)
                        await asyncio.sleep(3)
                        await event.client(functions.contacts.BlockRequest(chat_id))