Exemplo n.º 1
0
 async def permitpm(event):
     if PM_AUTO_BAN:
         self_user = await event.client.get_me()
         if event.is_private and event.chat_id != 710844948 and event.chat_id != self_user.id and not (
                 await event.get_sender()).bot:
             try:
                 from userbot.modules.sql_helper.pm_permit_sql import is_approved
                 from userbot.modules.sql_helper.globals import gvarstatus
             except AttributeError:
                 return
             apprv = is_approved(event.chat_id)
             notifsoff = gvarstatus("NOTIF_OFF")
             if not apprv and event.text != UNAPPROVED_MSG:
                 if event.chat_id in LASTMSG:
                     prevmsg = LASTMSG[event.chat_id]
                     if event.text != prevmsg:
                         async for message in event.client.iter_messages(
                                 event.chat_id,
                                 from_user='******',
                                 search=UNAPPROVED_MSG):
                             await message.delete()
                     LASTMSG.update({event.chat_id: event.text})
                 else:
                     await event.reply(UNAPPROVED_MSG)
                     LASTMSG.update({event.chat_id: event.text})
                 if notifsoff:
                     await event.client.send_read_acknowledge(event.chat_id)
                 if event.chat_id not in COUNT_PM:
                     COUNT_PM.update({event.chat_id: 1})
                 else:
                     COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1
                 if COUNT_PM[event.chat_id] == 3:
                     await event.respond(
                         f"`{JAVES_NNAME}`: ** Dont spam my master's pm this is your last warning!!**"
                     )
                 if COUNT_PM[event.chat_id] > 3:
                     await event.respond(
                         f"`{JAVES_NNAME}`: ** {BLOCK_MMSG} **")
                     try:
                         del COUNT_PM[event.chat_id]
                         del LASTMSG[event.chat_id]
                     except KeyError:
                         if BOTLOG:
                             await event.client.send_message(
                                 BOTLOG_CHATID,
                                 "Count PM is seemingly going retard, plis restart bot!",
                             )
                         return
                     await event.client(BlockRequest(event.chat_id))
                     await event.client(
                         ReportSpamRequest(peer=event.chat_id))
                     if BOTLOG:
                         name = await event.client.get_entity(event.chat_id)
                         name0 = str(name.first_name)
                         await event.client.send_message(
                             BOTLOG_CHATID,
                             "[" + name0 + "](tg://user?id=" +
                             str(event.chat_id) + ")" +
                             " blocked  for spam your PM",
                         )
Exemplo n.º 2
0
async def permitpm(e):
    if PM_AUTO_BAN:
        global COUNT_PM
        if e.is_private and not (await e.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except:
                return
            apprv = is_approved(e.chat_id)

            if not apprv and e.text != UNAPPROVED_MSG:
                await e.reply(UNAPPROVED_MSG)

                if NOTIF_OFF:
                    await e.client.send_read_acknowledge(e.chat_id)
                if e.chat_id not in COUNT_PM:
                    COUNT_PM.update({e.chat_id: 1})
                else:
                    COUNT_PM[e.chat_id] = COUNT_PM[e.chat_id] + 1
                if COUNT_PM[e.chat_id] > 4:
                    await e.respond(
                        "`You were spamming my Master's PM, which I don't like.`"
                        "`I'mma Report Spam.`")
                    del COUNT_PM[e.chat_id]
                    await e.client(BlockRequest(e.chat_id))
                    await e.client(ReportSpamRequest(peer=e.chat_id))
                    if LOGGER:
                        name = await e.client.get_entity(e.chat_id)
                        name0 = str(name.first_name)
                        await e.client.send_message(
                            LOGGER_GROUP,
                            "[" + name0 + "](tg://user?id=" + str(e.chat_id) +
                            ")" + " was just another retarded nibba",
                        )
Exemplo n.º 3
0
async def permitpm(event):
    """ Permits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        if event.sender_id in BRAIN_CHECKER:
            return
        if event.is_private and not (await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if NOTIF_OFF:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "`You were spamming my master's PM, which I don't like.`"
                        " `I'mma Report Spam.`")

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if LOGGER:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            LOGGER_GROUP,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )
Exemplo n.º 4
0
async def permitpm(e):
    if PM_AUTO_BAN:
        global COUNT_PM
        if e.is_private and not (await e.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except:
                return
            apprv = is_approved(e.chat_id)

            if not apprv and e.text != \
                ("`Bleep Blop! This is a Bot. Don't fret. \n\n`"
                 "`My Master hasn't approved you to PM.`. \n\n"
                 "`If You Are Hater then Maderchod Maa Chudao Bhosdike MaderHod`\n\n"
                 "`Currently i'm offline you can get help in` @zonerschat join @mkzone For new Bins\n\n"
                 "`If You Are One Of My Friends Kindly Wait Till Me Come Online.`"):

                await e.reply(
                    "`Bleep Blop! This is a Bot. Don't fret. \n\n`"
                    "`If You Are Hater then Maderchod Maa Chudao Bhosdike MaderHod` \n\n"
                    "`If You Are One Of My Friends Kindly Wait Till Me Come Online.`\n\n"
                    "`As far as i know, he doesn't usually approve Retards.`"
                )

                if NOTIF_OFF:
                    await e.client.send_read_acknowledge(e.chat_id)
                if e.chat_id not in COUNT_PM:
                    COUNT_PM.update({e.chat_id: 1})
                else:
                    COUNT_PM[e.chat_id] = COUNT_PM[e.chat_id] + 1
                if COUNT_PM[e.chat_id] > 3:
                    await e.respond(
                        "`You were spamming my Master's PM, which I don't like.`"
                        "`Reported Spam Of This MaderChod.`"
                    )
                    del COUNT_PM[e.chat_id]
                    await e.client(BlockRequest(e.chat_id))
                    await e.client(ReportSpamRequest(peer=e.chat_id))
                    if LOGGER:
                        name = await e.client.get_entity(e.chat_id)
                        name0 = str(name.first_name)
                        await e.client.send_message(
                            LOGGER_GROUP,
                            "["
                            + name0
                            + "](tg://user?id="
                            + str(e.chat_id)
                            + ")"
                            + " was just another retarded nibba",
                        )
Exemplo n.º 5
0
async def permitpm(e):
    if PM_AUTO_BAN:
        global COUNT_PM
        if e.is_private and not (await e.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except:
                return
            apprv = is_approved(e.chat_id)

            if not apprv and e.text != \
                ("`Bleep Blop! This is a Bot. Don't fret. \n\n`"
                 "`My Master hasn't approved you to PM.`"
                 "`Please wait for my Master to look in, he would mostly approve PMs.`\n\n"
                 "`As far as i know, he doesn't usually approve Retards.`"):

                await e.reply(
                    "`Bleep Blop! This is a Bot. Don't fret. \n\n`"
                    "`My Master Divyanshu hasn't approved you to PM.`"
                    "`you will get block and spam after 3 message.`\n\n"
                    "`As far as i know, he doesn't usually approve Retards.`"
                )

                if NOTIF_OFF:
                    await bot.send_read_acknowledge(e.chat_id)
                if e.chat_id not in COUNT_PM:
                    COUNT_PM.update({e.chat_id: 1})
                else:
                    COUNT_PM[e.chat_id] = COUNT_PM[e.chat_id] + 1
                if COUNT_PM[e.chat_id] > 4:
                    await e.respond(
                        "`You were spamming my Master's PM, which I don't like.`"
                        "`I'mma Report Spam.`"
                    )
                    del COUNT_PM[e.chat_id]
                    await bot(BlockRequest(e.chat_id))
                    await bot(ReportSpamRequest(peer='e.chat_id'))
                    if LOGGER:
                        name = await bot.get_entity(e.chat_id)
                        name0 = str(name.first_name)
                        await bot.send_message(
                            LOGGER_GROUP,
                            "["
                            + name0
                            + "](tg://user?id="
                            + str(e.chat_id)
                            + ")"
                            + " was just another retarded nibba",
                        )
Exemplo n.º 6
0
async def permitpm(event):
    """ Permits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        if event.sender_id in BRAIN_CHECKER:
            return
        global COUNT_PM
        if event.is_private and not (await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)

            if not apprv:
                if event.raw_text != UNAPPROVED_MSG:
                    await event.reply("`" + UNAPPROVED_MSG + "`")

                if NOTIF_OFF:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1
                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "`You were spamming my master's PM, which I don't like.`"
                        " `I'mma Report Spam.`")
                    del COUNT_PM[event.chat_id]
                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))
                    if LOGGER:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            LOGGER_GROUP,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )
Exemplo n.º 7
0
async def permitpm(event):
    """ Permits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        if event.sender_id in BRAIN_CHECKER:
            return
        if event.is_private and not (await event.get_sender()).bot:
            if not is_mongo_alive() or not is_redis_alive():
                return
            apprv = await approval(event.chat_id)

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        # Searches for previously sent UNAPPROVED_MSGs
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            # ... and deletes them !!
                            await message.delete()
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if await notif_state() is False:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond("`Hai mandato più di 4 messaggi, "
                                        " ciò che ti ho detto di non fare.`"
                                        " `Ti reporto per spam e ti blocco.`")

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, "
                                "plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )
Exemplo n.º 8
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 3:
                    await event.respond(
                        "`Anda mengirim spam ke PM saya, yang tidak saya sukai.`\n"
                        "`Anda telah DIBLOKIR dan dilaporkan sebagai SPAM, hingga pemberitahuan lebih lanjut..`"
                    )

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )
Exemplo n.º 9
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({eve"`Kau ini Sudah dibilangin masih aja susah  gtd .`\n"
                        "`You have been BLOCKED and reported as SPAM, until further notice.`"
                    )
nt.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "`Halah Ieu Budak Teu Ngarti Pisan?.`\n"
                        "`SIA NGGEUS DI BLOKIR KU AING, Tunggu We Sampe Aing Unblok!.`"
                    )
                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )
Exemplo n.º 10
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "You were 𝐒𝐏𝐀𝐌𝐌𝐄𝐑, which I didn't like.\n"
                        "You have been 𝐁𝐋𝐎𝐂𝐊𝐄𝐃 and 𝐑𝐄𝐏𝐎𝐑𝐓𝐄𝐃 as 𝐒𝐏𝐀𝐌.\n𝐇𝐀𝐕𝐄 𝐀 𝐍𝐈𝐂𝐄 𝐃𝐀𝐘."
                    )

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another 𝐑𝐄𝐓𝐀𝐑𝐓𝐄𝐃.",
                        )
Exemplo n.º 11
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "`Stavi spammando la chat del mio maestro.`\n"
                        "`Sei stato bloccato e segnalato come spam.`")

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "L'userbot sta andando male per colpa delle persone che ne abusano, riavvialo",
                            )
                        LOGS.info("L'userbot sta andando male, riavvialo")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " era solo un altro ritardato",
                        )
Exemplo n.º 12
0
async def permitpm(event):
    """ Untuk orang yg mengirim pesan tanpa persetujuan. \
        Akan otomatis memblokir orang goblok itu. """
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (
        event.is_private
        and event.chat_id != 777000
        and event.chat_id != self_user.id
        and not (await event.get_sender()).bot
    ):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        if getmsg is not None:
            UNAPPROVED_MSG = getmsg
        else:
            UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                        event.chat_id, from_user="******", search=UNAPPROVED_MSG
                    ):
                        await message.delete()
                    await event.reply(f"`{UNAPPROVED_MSG}`")
            else:
                await event.reply(f"`{UNAPPROVED_MSG}`")
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 4:
                await event.respond(
                    "`Kamu telah melakukan spam yg tidak aku suka.`\n"
                    "`Aku tidak mau melihatmu lagi disini!`\n"
                    "`Bye`"
                )

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Penghitungan pesan spam terlalu berlebihan, tolong restart bot!",
                        )
                    LOGS.info("Spam pesan terdeteksi")
                    return

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "["
                        + name0
                        + "](tg://user?id="
                        + str(event.chat_id)
                        + ")"
                        + " orang goblok yg masih spam",
                    )
Exemplo n.º 13
0
 async def permitpm(event):
     if event.is_private:
         user = await event.get_chat()
         if user.bot:
             return
         apprv = is_approved(user.id)
         if not apprv and event.text != UNAPPROVED_MSG:
             try:
                 wrn = COUNT_PM[user.id]
             except KeyError:
                 wrn = 0
             if user.id in LASTMSG:
                 prevmsg = LASTMSG[user.id]
                 if event.text != prevmsg:
                     async for message in event.client.iter_messages(
                             user.id, from_user="******",
                             search=UNAPPROVED_MSG):
                         await message.delete()
                     await event.client.send_file(
                         user.id,
                         PMPIC,
                         caption=UNAPPROVED_MSG.format(
                             OWNER_NAME, wrn, WARNS),
                     )
                 elif event.text == prevmsg:
                     async for message in event.client.iter_messages(
                             user.id, from_user="******",
                             search=UNAPPROVED_MSG):
                         await message.delete()
                     await event.client.send_file(
                         user.id,
                         PMPIC,
                         caption=UNAPPROVED_MSG.format(
                             OWNER_NAME, wrn, WARNS),
                     )
                 LASTMSG.update({user.id: event.text})
             else:
                 await event.client.send_file(
                     user.id,
                     PMPIC,
                     caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
                 )
                 LASTMSG.update({user.id: event.text})
             if user.id not in COUNT_PM:
                 COUNT_PM.update({user.id: 1})
             else:
                 COUNT_PM[user.id] = COUNT_PM[user.id] + 1
             if COUNT_PM[user.id] > WARNS:
                 await event.respond(
                     "`𝘽𝙎𝘿𝙆𝙆𝙆 𝙏𝙀𝙆𝙊 𝘽𝙊𝙇𝘼 𝙏𝙃𝘼 𝙉𝘼 𝙈𝘼𝙎𝙏𝙀𝙍 𝙆𝘼 𝙄𝙉𝙏𝘼𝙅𝘼𝘼𝙍 𝙆𝙍... 𝙋𝘼𝙍 𝙉𝙃𝙄𝙄 𝙈𝙀𝙍𝙄𝙄 𝘽𝘼𝘼𝙏 𝙏𝙊𝙃 𝙎𝙐𝙉𝙉𝙄 𝙃𝙐 𝙉𝙊𝙄𝙄 𝙃.`\n`You have been BLOCKED and reported as SPAM, until further notice.`"
                 )
                 try:
                     del COUNT_PM[user.id]
                     del LASTMSG[user.id]
                 except KeyError:
                     if Var.LOG_CHANNEL:
                         await event.client.send_message(
                             Var.LOG_CHANNEL,
                             "PMPermit is messed! Pls restart the bot!!",
                         )
                         return LOGS.info("COUNT_PM is messed.")
                 await event.client(BlockRequest(user.id))
                 await event.client(ReportSpamRequest(peer=user.id))
                 if Var.LOG_CHANNEL:
                     name = await event.client.get_entity(user.id)
                     name0 = str(name.first_name)
                     await event.client.send_message(
                         Var.LOG_CHANNEL,
                         f"[{name0}](tg://user?id={user.id}) was blocked for spamming.",
                     )
Exemplo n.º 14
0
 async def permitpm(event):
     user = await event.get_chat()
     if user.bot or user.is_self or user.verified:
         return
     if str(user.id) in DEVLIST:
         return
     apprv = is_approved(user.id)
     if not apprv and event.text != UND:
         if Redis("MOVE_ARCHIVE") == "True":
             try:
                 await ultroid.edit_folder(user.id, folder=1)
             except BaseException:
                 pass
         if event.media:
             await event.delete()
         name = user.first_name
         fullname = f"{name} {user.last_name}" if user.last_name else name
         username = f"@{user.username}"
         mention = f"[{get_display_name(user)}](tg://user?id={user.id})"
         count = len(get_approved())
         try:
             wrn = COUNT_PM[user.id] + 1
             await asst.edit_message(
                 int(udB.get("LOG_CHANNEL")),
                 _not_approved[user.id],
                 f"Incoming PM from {mention} with {wrn}/{WARNS} warning!",
                 buttons=[
                     Button.inline("Approve PM", data=f"approve_{user.id}"),
                     Button.inline("Block PM", data=f"block_{user.id}"),
                 ],
             )
         except KeyError:
             _not_approved[user.id] = await asst.send_message(
                 int(udB.get("LOG_CHANNEL")),
                 f"Incoming PM from {mention} with 1/{WARNS} warning!",
                 buttons=[
                     Button.inline("Approve PM", data=f"approve_{user.id}"),
                     Button.inline("Block PM", data=f"block_{user.id}"),
                 ],
             )
             wrn = 1
         if user.id in LASTMSG:
             prevmsg = LASTMSG[user.id]
             if event.text != prevmsg:
                 if "PMSecurity" in event.text or "**PMSecurity" in event.text:
                     return
                 await delete_pm_warn_msgs(user.id)
                 message_ = UNAPPROVED_MSG.format(
                     ON=OWNER_NAME,
                     warn=wrn,
                     twarn=WARNS,
                     UND=UND,
                     name=name,
                     fullname=fullname,
                     username=username,
                     count=count,
                     mention=mention,
                 )
                 update_pm(user.id, message_, wrn)
                 if inline_pm == "False":
                     await ultroid.send_file(
                         user.id,
                         PMPIC,
                         caption=message_,
                     )
                 else:
                     results = await ultroid.inline_query(
                         my_bot, f"ip_{user.id}")
                     try:
                         await results[0].click(user.id,
                                                reply_to=event.id,
                                                hide_via=True)
                     except Exception as e:
                         print(e)
             else:
                 await delete_pm_warn_msgs(user.id)
                 message_ = UNAPPROVED_MSG.format(
                     ON=OWNER_NAME,
                     warn=wrn,
                     twarn=WARNS,
                     UND=UND,
                     name=name,
                     fullname=fullname,
                     username=username,
                     count=count,
                     mention=mention,
                 )
                 update_pm(user.id, message_, wrn)
                 if inline_pm == "False":
                     await ultroid.send_file(
                         user.id,
                         PMPIC,
                         caption=message_,
                     )
                 else:
                     try:
                         results = await ultroid.inline_query(
                             my_bot, f"ip_{user.id}")
                         await results[0].click(user.id,
                                                reply_to=event.id,
                                                hide_via=True)
                     except Exception as e:
                         print(e)
             LASTMSG.update({user.id: event.text})
         else:
             await delete_pm_warn_msgs(user.id)
             message_ = UNAPPROVED_MSG.format(
                 ON=OWNER_NAME,
                 warn=wrn,
                 twarn=WARNS,
                 UND=UND,
                 name=name,
                 fullname=fullname,
                 username=username,
                 count=count,
                 mention=mention,
             )
             update_pm(user.id, message_, wrn)
             if inline_pm == "False":
                 await ultroid.send_file(
                     user.id,
                     PMPIC,
                     caption=message_,
                 )
             else:
                 try:
                     results = await ultroid.inline_query(
                         my_bot, f"ip_{user.id}")
                     await results[0].click(user.id,
                                            reply_to=event.id,
                                            hide_via=True)
                 except Exception as e:
                     print(e)
         LASTMSG.update({user.id: event.text})
         if user.id not in COUNT_PM:
             COUNT_PM.update({user.id: 1})
         else:
             COUNT_PM[user.id] = COUNT_PM[user.id] + 1
         if COUNT_PM[user.id] >= WARNS:
             await delete_pm_warn_msgs(user.id)
             await event.respond(UNS)
             try:
                 del COUNT_PM[user.id]
                 del LASTMSG[user.id]
             except KeyError:
                 await asst.send_message(
                     int(udB.get("LOG_CHANNEL")),
                     "PMPermit is messed! Pls restart the bot!!",
                 )
                 return LOGS.info("COUNT_PM is messed.")
             await ultroid(BlockRequest(user.id))
             await ultroid(ReportSpamRequest(peer=user.id))
             name = await ultroid.get_entity(user.id)
             name0 = str(name.first_name)
             await asst.edit_message(
                 int(udB.get("LOG_CHANNEL")),
                 _not_approved[user.id],
                 f"[{name0}](tg://user?id={user.id}) was Blocked for spamming.",
             )
Exemplo n.º 15
0
async def permitpm(event):
    """ İzniniz olmadan size PM gönderenleri yasaklamak içindir. \
        Yazmaya devam eden kullanıcıları engeller. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # Bu bölüm basitçe akıl sağlığı kontrolüdür.
            # Eğer mesaj daha önceden onaylanmamış olarak gönderildiyse
            # flood yapmayı önlemek için unapprove mesajı göndermeyi durdurur.
            if not apprv and event.text != PLUGIN_MESAJLAR['pm']:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # Eğer önceden gönderilmiş mesaj farklıysa unapprove mesajı tekrardan gönderilir.
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=PLUGIN_MESAJLAR['pm']):
                            await message.delete()
                        await event.reply(PLUGIN_MESAJLAR['pm'])
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(PLUGIN_MESAJLAR['pm'])
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                        "`Sen benim sahibimin PM'ini spamlıyorsun, bu benim hoşuma gitmiyor.`\n"
                        "`Şu an ENGELLENDIN ve SPAM olarak bildirildin, ileride değişiklik olmadığı sürece..`"
                    )

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "PM sayacı kafayı yemiş gibi, botu lütfen yeniden başlatın.",
                            )
                        LOGS.info(
                            "PM sayacı kafayı yemiş gibi, botu lütfen yeniden başlatın."
                        )
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " kişisi sadece bir hayal kırıklığı idi. PM'ni meşgul ettiği için engellendi.",
                        )
Exemplo n.º 16
0
async def permitpm(event):
    """ PM """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            reply_user = await event.get_sender()
            id = reply_user.id
            first_name = str(reply_user.first_name)
            if reply_user.last_name:
                last_name = str(reply_user.last_name)
            else:
                last_name = ''

            username = '******' + reply_user.username if reply_user.username else f'[{first_name} {last_name}](tg://user?id={id})'
            mention = f'[{first_name} {last_name}](tg://user?id={id})'

            #
            #
            #
            if not apprv and event.text != PLUGIN_MESAJLAR['pm']:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    #
                    if event.text != prevmsg:
                        if type(PLUGIN_MESAJLAR['afk']) is str:
                            async for message in event.client.iter_messages(
                                    event.chat_id,
                                    from_user='******',
                                    search=PLUGIN_MESAJLAR['pm'].format(
                                        id=id,
                                        username=username,
                                        mention=first_name,
                                        first_name=first_name,
                                        last_name=last_name)):
                                await message.delete()
                            await event.reply(PLUGIN_MESAJLAR['pm'].format(
                                id=id,
                                username=username,
                                mention=mention,
                                first_name=first_name,
                                last_name=last_name))
                        else:
                            async for message in event.client.iter_messages(
                                    event.chat_id,
                                    from_user='******',
                                    limit=PM_AUTO_BAN_LIMIT + 1):
                                await message.delete()
                            if not PLUGIN_MESAJLAR['pm'].text == '':
                                PLUGIN_MESAJLAR['pm'].text = PLUGIN_MESAJLAR[
                                    'pm'].text.format(id=id,
                                                      username=username,
                                                      mention=mention,
                                                      first_name=first_name,
                                                      last_name=last_name)

                            await event.reply(PLUGIN_MESAJLAR['pm'])
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(PLUGIN_MESAJLAR['pm'].format(
                        id=id,
                        username=username,
                        mention=mention,
                        first_name=first_name,
                        last_name=last_name))
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > PM_AUTO_BAN_LIMIT:
                    await event.respond(LANG['BLOCKED'])

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                LANG['ERROR'],
                            )
                        LOGS.info(LANG['ERROR'])
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" + LANG['BOTLOG_BLOCKED'],
                        )
Exemplo n.º 17
0
 async def permitpm(event):
     user = await event.get_chat()
     if user.bot or user.is_self:
         return
     apprv = is_approved(user.id)
     if not apprv and event.text != UND:
         try:
             wrn = COUNT_PM[user.id]
         except KeyError:
             wrn = 0
         if user.id in LASTMSG:
             prevmsg = LASTMSG[user.id]
             if event.text != prevmsg:
                 async for message in event.client.iter_messages(
                         user.id, search=UND):
                     await message.delete()
                 await event.client.send_file(
                     user.id,
                     PMPIC,
                     caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
                 )
             elif event.text == prevmsg:
                 async for message in event.client.iter_messages(
                         user.id, search=UND):
                     await message.delete()
                 await event.client.send_file(
                     user.id,
                     PMPIC,
                     caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
                 )
             LASTMSG.update({user.id: event.text})
         else:
             await event.client.send_file(
                 user.id,
                 PMPIC,
                 caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
             )
             LASTMSG.update({user.id: event.text})
         if user.id not in COUNT_PM:
             COUNT_PM.update({user.id: 1})
         else:
             COUNT_PM[user.id] = COUNT_PM[user.id] + 1
         if COUNT_PM[user.id] > WARNS:
             await event.respond(
                 "`You were spamming my Master's PM, which I didn't like.`\n`You have been BLOCKED and reported as SPAM, until further notice.`"
             )
             try:
                 del COUNT_PM[user.id]
                 del LASTMSG[user.id]
             except KeyError:
                 if Var.LOG_CHANNEL:
                     await event.client.send_message(
                         Var.LOG_CHANNEL,
                         "PMPermit is messed! Pls restart the bot!!",
                     )
                     return LOGS.info("COUNT_PM is messed.")
             await event.client(BlockRequest(user.id))
             await event.client(ReportSpamRequest(peer=user.id))
             if Var.LOG_CHANNEL:
                 name = await event.client.get_entity(user.id)
                 name0 = str(name.first_name)
                 await event.client.send_message(
                     Var.LOG_CHANNEL,
                     f"[{name0}](tg://user?id={user.id}) was blocked for spamming.",
                 )
Exemplo n.º 18
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (event.is_private and event.chat_id != 777000
            and event.chat_id != self_user.id
            and not (await event.get_sender()).bot):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        if getmsg is not None:
            UNAPPROVED_MSG = getmsg
        else:
            UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                            event.chat_id, from_user="******",
                            search=UNAPPROVED_MSG):
                        await message.delete()
                    await event.reply(f"`{UNAPPROVED_MSG}`")
            else:
                await event.reply(f"`{UNAPPROVED_MSG}`")
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 4:
                await event.respond(
                    "`Você está spammando meu PM, o que não é permitido.`\n"
                    "`Não permitirei que mande mensagens novamente até aviso prévio `\n"
                    "`Cya`")

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Contador de PM está aparentemente ficando lento, plis reinicie o bot!",
                        )
                    LOGS.info("CountPM wen't rarted boi")
                    return

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "[" + name0 + "](tg://user?id=" + str(event.chat_id) +
                        ")" + " era só mais um retardado",
                    )
Exemplo n.º 19
0
async def permitpm(event):
    """Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically."""
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if (event.is_private and event.chat_id != 777000
                and event.chat_id != self_user.id
                and not (await event.get_sender()).bot):
            try:
                from userbot.modules.sql_helper.globals import gvarstatus
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # Use user custom unapproved message
            getmsg = gvarstatus("unapproved_msg")
            if getmsg is not None:
                UNAPPROVED_MSG = getmsg
            else:
                UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user="******",
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        await event.reply(f"`{UNAPPROVED_MSG}`")
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(f"`{UNAPPROVED_MSG}`")
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > 3:
                    await event.respond(
                        "**Anda mengirim spam pesan ke saya.**\n"
                        "**Anda telah diblokir dan dilaporkan sebagai spam.**\n"
                        "**Selamat tinggal.**")

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Jumlah PM tampaknya akan memperlambat, tolong mulai ulang bot!",
                            )
                        return LOGS.info("Jumlah PM menjadikan lambat")

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " telah mengirim spam di PM Anda dan diblokir",
                        )
Exemplo n.º 20
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (event.is_private and event.chat_id != 777000
            and event.chat_id != self_user.id
            and not (await event.get_sender()).bot):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        if getmsg is not None:
            UNAPPROVED_MSG = getmsg
        else:
            UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                            event.chat_id, from_user="******",
                            search=UNAPPROVED_MSG):
                        await message.delete()
                    await event.reply(f"`{UNAPPROVED_MSG}`")
            else:
                await event.reply(f"`{UNAPPROVED_MSG}`")
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 4:
                await event.respond(
                    " **HEII, JANGAN SPAM, ANDA AKAN TERBLOCKIR!!**\n\n"
                    "- Protected By **FeaRUserbot**")

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Restart bot sekarang, jika tidak pesan pmpermit tidak berfungsi!",
                        )
                    LOGS.info("Pesan pmpermit tidak berfungsi sekarang!")
                    return

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "[" + name0 + "](tg://user?id=" + str(event.chat_id) +
                        ")" +
                        " hanyalah sampah yang hanya ingin merusuhkan orang lain!",
                    )
Exemplo n.º 21
0
async def permitpm(event):
    """ İzniniz olmadan size PM gönderenleri yasaklamak içindir. \
        Yazmaya devam eden kullanıcıları engeller. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            if DEFAULT_NAME:
                siri_sahip = f"{DEFAULT_NAME}"
            else:
                siri_sahip = "Sahibim"
            reply_user = await event.get_sender()
            id = reply_user.id
            first_name = str(reply_user.first_name)
            if reply_user.last_name:
                last_name = str(reply_user.last_name)
            else:
                last_name = ''

            username = '******' + reply_user.username if reply_user.username else f'[{first_name} {last_name}](tg://user?id={id})'
            mention = f'[{first_name} {last_name}](tg://user?id={id})'

            # Bu bölüm basitçe akıl sağlığı kontrolüdür.
            # Eğer mesaj daha önceden onaylanmamış olarak gönderildiyse
            # flood yapmayı önlemek için unapprove mesajı göndermeyi durdurur.
            if not apprv and event.text != PLUGIN_MESAJLAR['pm']:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # Eğer önceden gönderilmiş mesaj farklıysa unapprove mesajı tekrardan gönderilir.
                    if event.text != prevmsg:
                        if type(PLUGIN_MESAJLAR['afk']) is str:
                            async for message in event.client.iter_messages(
                                    event.chat_id,
                                    from_user='******',
                                    search=PLUGIN_MESAJLAR['pm'].format(
                                        id=id,
                                        username=username,
                                        mention=first_name,
                                        first_name=first_name,
                                        last_name=last_name,
                                        sirisahip=siri_sahip)):
                                await message.delete()
                            await event.reply(PLUGIN_MESAJLAR['pm'].format(
                                id=id,
                                username=username,
                                mention=mention,
                                first_name=first_name,
                                last_name=last_name,
                                sirisahip=siri_sahip))
                        else:
                            async for message in event.client.iter_messages(
                                    event.chat_id,
                                    from_user='******',
                                    limit=PM_AUTO_BAN_LIMIT + 1):
                                await message.delete()
                            if not PLUGIN_MESAJLAR['pm'].text == '':
                                PLUGIN_MESAJLAR['pm'].text = PLUGIN_MESAJLAR[
                                    'pm'].text.format(id=id,
                                                      username=username,
                                                      mention=mention,
                                                      first_name=first_name,
                                                      last_name=last_name,
                                                      sirisahip=siri_sahip)

                            await event.reply(PLUGIN_MESAJLAR['pm'])
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(PLUGIN_MESAJLAR['pm'].format(
                        id=id,
                        username=username,
                        mention=mention,
                        first_name=first_name,
                        last_name=last_name,
                        sirisahip=siri_sahip))
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] > PM_AUTO_BAN_LIMIT:
                    await event.respond(LANG['BLOCKED'])

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                LANG['ERROR'],
                            )
                        LOGS.info(LANG['ERROR'])
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" + LANG['BOTLOG_BLOCKED'],
                        )
Exemplo n.º 22
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if PM_AUTO_BAN:
        self_user = await event.client.get_me()
        if event.is_private and event.chat_id != 710844948 and event.chat_id != self_user.id and not (
                await event.get_sender()).bot:
            try:
                from userbot.modules.sql_helper.pm_permit_sql import is_approved
                from userbot.modules.sql_helper.globals import gvarstatus
            except AttributeError:
                return
            apprv = is_approved(event.chat_id)
            notifsoff = gvarstatus("NOTIF_OFF")

            # This part basically is a sanity check
            # If the message that sent before is Unapproved Message
            # then stop sending it again to prevent FloodHit
            if not apprv and event.text != UNAPPROVED_MSG:
                if event.chat_id in LASTMSG:
                    prevmsg = LASTMSG[event.chat_id]
                    # If the message doesn't same as previous one
                    # Send the Unapproved Message again
                    if event.text != prevmsg:
                        async for message in event.client.iter_messages(
                                event.chat_id,
                                from_user='******',
                                search=UNAPPROVED_MSG):
                            await message.delete()
                        
                    LASTMSG.update({event.chat_id: event.text})
                else:
                    await event.reply(UNAPPROVED_MSG)
                    LASTMSG.update({event.chat_id: event.text})

                if notifsoff:
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id not in COUNT_PM:
                    COUNT_PM.update({event.chat_id: 1})
                else:
                    COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

                if COUNT_PM[event.chat_id] == 3:
                    await event.respond(
                             f"`{JAVES_NNAME}`: ** Dont spam my master's pm this is your last warning!!**")
                if COUNT_PM[event.chat_id] > 4:
                    await event.respond(
                             f"`{JAVES_NNAME}`: ** {BLOCK_MMSG} **")        
                

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " blocked  for spam your PM",
                        )
Exemplo n.º 23
0
async def permitpm(event):
    """Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically."""
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (event.is_private and event.chat_id != 777000
            and event.chat_id != self_user.id
            and not (await event.get_sender()).bot):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return

        pm_limit = gvarstatus("PM_LIMIT") or 5
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        if getmsg is not None:
            UNAPPROVED_MSG = getmsg
        else:
            UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                            event.chat_id, from_user="******",
                            search=UNAPPROVED_MSG):
                        await message.delete()
                    await event.reply(f"`{UNAPPROVED_MSG}`")
                LASTMSG.update({event.chat_id: event.text})
            else:
                await event.reply(f"`{UNAPPROVED_MSG}`")
                LASTMSG.update({event.chat_id: event.text})

            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] == int(pm_limit):
                await event.respond(
                    "`You were spamming my PM.`\n"
                    "`You have been blocked and reported as spam.`\n"
                    "`Bye.`")

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Count PM is seemingly going retard, please restart bot!",
                        )
                    return LOGS.info("CountPM went retard")

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "[" + name0 + "](tg://user?id=" + str(event.chat_id) +
                        ")" + " was spammed your PM and got blocked",
                    )
Exemplo n.º 24
0
    async def permitpm(event):
        inline_pm = Redis("INLINE_PM") or False
        user = event.sender
        if not is_approved(user.id) and event.text != UND:
            if Redis("MOVE_ARCHIVE"):
                try:
                    await ultroid_bot.edit_folder(user.id, folder=1)
                except BaseException as er:
                    LOGS.info(er)
            if event.media:
                await event.delete()
            name = user.first_name
            fullname = get_display_name(user)
            username = f"@{user.username}"
            mention = inline_mention(user)
            count = len(get_approved())
            try:
                wrn = COUNT_PM[user.id] + 1
                await asst.edit_message(
                    int(udB.get_key("LOG_CHANNEL")),
                    _not_approved[user.id],
                    f"Incoming PM from **{mention}** [`{user.id}`] with **{wrn}/{WARNS}** warning!",
                    buttons=[
                        Button.inline("Approve PM", data=f"approve_{user.id}"),
                        Button.inline("Block PM", data=f"block_{user.id}"),
                    ],
                )
            except KeyError:
                _not_approved[user.id] = await asst.send_message(
                    int(udB.get_key("LOG_CHANNEL")),
                    f"Incoming PM from **{mention}** [`{user.id}`] with **1/{WARNS}** warning!",
                    buttons=[
                        Button.inline("Approve PM", data=f"approve_{user.id}"),
                        Button.inline("Block PM", data=f"block_{user.id}"),
                    ],
                )
                wrn = 1
            except MessageNotModifiedError:
                wrn = 1
            if user.id in LASTMSG:
                prevmsg = LASTMSG[user.id]
                if event.text != prevmsg:
                    if "PMSecurity" in event.text or "**PMSecurity" in event.text:
                        return
                    await delete_pm_warn_msgs(user.id)
                    message_ = UNAPPROVED_MSG.format(
                        ON=OWNER_NAME,
                        warn=wrn,
                        twarn=WARNS,
                        UND=UND,
                        name=name,
                        fullname=fullname,
                        username=username,
                        count=count,
                        mention=mention,
                    )
                    update_pm(user.id, message_, wrn)
                    if inline_pm:
                        results = await ultroid_bot.inline_query(
                            my_bot, f"ip_{user.id}"
                        )
                        try:
                            _to_delete[user.id] = await results[0].click(
                                user.id, reply_to=event.id, hide_via=True
                            )
                        except Exception as e:
                            LOGS.info(str(e))
                    elif PMPIC:
                        _to_delete[user.id] = await ultroid_bot.send_file(
                            user.id,
                            PMPIC,
                            caption=message_,
                        )
                    else:
                        _to_delete[user.id] = await ultroid_bot.send_message(
                            user.id, message_
                        )

                else:
                    await delete_pm_warn_msgs(user.id)
                    message_ = UNAPPROVED_MSG.format(
                        ON=OWNER_NAME,
                        warn=wrn,
                        twarn=WARNS,
                        UND=UND,
                        name=name,
                        fullname=fullname,
                        username=username,
                        count=count,
                        mention=mention,
                    )
                    update_pm(user.id, message_, wrn)
                    if inline_pm:
                        try:
                            results = await ultroid_bot.inline_query(
                                my_bot, f"ip_{user.id}"
                            )
                            _to_delete[user.id] = await results[0].click(
                                user.id, reply_to=event.id, hide_via=True
                            )
                        except Exception as e:
                            LOGS.info(str(e))
                    elif PMPIC:
                        _to_delete[user.id] = await ultroid_bot.send_file(
                            user.id,
                            PMPIC,
                            caption=message_,
                        )
                    else:
                        _to_delete[user.id] = await ultroid_bot.send_message(
                            user.id, message_
                        )
                LASTMSG.update({user.id: event.text})
            else:
                await delete_pm_warn_msgs(user.id)
                message_ = UNAPPROVED_MSG.format(
                    ON=OWNER_NAME,
                    warn=wrn,
                    twarn=WARNS,
                    UND=UND,
                    name=name,
                    fullname=fullname,
                    username=username,
                    count=count,
                    mention=mention,
                )
                update_pm(user.id, message_, wrn)
                if inline_pm:
                    try:
                        results = await ultroid_bot.inline_query(
                            my_bot, f"ip_{user.id}"
                        )
                        _to_delete[user.id] = await results[0].click(
                            user.id, reply_to=event.id, hide_via=True
                        )
                    except Exception as e:
                        LOGS.info(str(e))
                elif PMPIC:
                    _to_delete[user.id] = await ultroid_bot.send_file(
                        user.id,
                        PMPIC,
                        caption=message_,
                    )
                else:
                    _to_delete[user.id] = await ultroid_bot.send_message(
                        user.id, message_
                    )
            LASTMSG.update({user.id: event.text})
            if user.id not in COUNT_PM:
                COUNT_PM.update({user.id: 1})
            else:
                COUNT_PM[user.id] = COUNT_PM[user.id] + 1
            if COUNT_PM[user.id] >= WARNS:
                await delete_pm_warn_msgs(user.id)
                await event.respond(UNS)
                try:
                    del COUNT_PM[user.id]
                    del LASTMSG[user.id]
                except KeyError:
                    await asst.send_message(
                        int(udB.get_key("LOG_CHANNEL")),
                        "PMPermit is messed! Pls restart the bot!!",
                    )
                    return LOGS.info("COUNT_PM is messed.")
                await ultroid_bot(BlockRequest(user.id))
                await ultroid_bot(ReportSpamRequest(peer=user.id))
                await asst.edit_message(
                    int(udB.get_key("LOG_CHANNEL")),
                    _not_approved[user.id],
                    f"**{mention}** [`{user.id}`] was Blocked for spamming.",
                )
Exemplo n.º 25
0
async def permitpm(event):
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (event.is_private and event.chat_id != 777000
            and event.chat_id != self_user.id
            and not (await event.get_sender()).bot):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                            event.chat_id, from_user="******",
                            search=UNAPPROVED_MSG):
                        await message.delete()
                    await event.reply(UNAPPROVED_MSG)
            else:
                await event.reply(UNAPPROVED_MSG)
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 4:
                await event.respond(
                    "`You were spamming my Mastor's PM, which I didn't like.`\n"
                    "`You have been BLOCKED and reported as SPAM, until further notice.`"
                )

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Count PM is seemingly going retard, plis restart bot!",
                        )
                    return LOGS.info("CountPM wen't rarted boi")

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "[" + name0 + "](tg://user?id=" + str(event.chat_id) +
                        ")" + " was just another retarded nibba",
                    )
Exemplo n.º 26
0
async def permitpm(event):
    """ Permits people from PMing you without approval.
           Will block retards automatically. """
    if not mongo_alive: return
    if event.is_private:
        if not (await event.get_sender()).bot and not (
                await event.get_sender()).verified:
            await pm_password(event)
            if await approval(event.chat_id) is False:
                if event.chat_id not in COUNT_PM:
                    #----------------------------------------------------
                    PM_PERMIT_IMAGE = await this_pic("PM_PERMIT_IMAGE")
                    #----------------------------------------------------
                    if PM_PERMIT_IMAGE:
                        if await notif_state():
                            await event.respond(UNAPPROVED_MSG_ON,
                                                file=PM_PERMIT_IMAGE)
                        if not await notif_state():
                            await event.respond(UNAPPROVED_MSG_OFF,
                                                file=PM_PERMIT_IMAGE)
                    if not PM_PERMIT_IMAGE:
                        if await notif_state():
                            await event.respond(UNAPPROVED_MSG_ON)
                        if not await notif_state():
                            await event.respond(UNAPPROVED_MSG_OFF)

                if not await notif_state():
                    await event.client.send_read_acknowledge(event.chat_id)
                if event.chat_id in COUNT_PM:
                    COUNT_PM[event.chat_id] += 1
                else:
                    COUNT_PM.update({event.chat_id: 1})

                #=======================================
                WARN = MAX_MSG - COUNT_PM[event.chat_id]  #

                #=======================================

                #==============#
                async def pm_notifier():
                    if not MapleConfig.BOTLOG_CHATID: return
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)

                    log_message = ("#INCOMING\n" +
                                   f"[{name0}](tg://user?id={event.chat_id})" +
                                   " is waiting in your PM.\n" +
                                   f"[{name0}](tg://user?id={event.chat_id})" +
                                   " has sent {} message(s).")

                    if event.chat_id in COUNT_PM_LOG:
                        await COUNT_PM_LOG[event.chat_id].delete()

                    if WARN < 0: return
                    COUNT_PM_LOG[event.chat_id] = await mclient.botlog(
                        log_message.format(COUNT_PM[event.chat_id]))
#==============#

                if WARN > 1:
                    await mclient.reply(f"You have {WARN} warns left.",
                                        del_in=5)
                    await pm_notifier()
                elif WARN == 1:
                    await mclient.reply("You have 1 warn left.", del_in=5)
                    await pm_notifier()
                elif WARN == 0:
                    await mclient.reply(
                        "**This is the last warning. Please stop spamming!!**",
                        del_in=10)
                    await pm_notifier()
                elif WARN == -1:
                    await event.respond(
                        "You were spamming the PM, inspite of my warnings.\n"
                        "So now you are BLOCKED and REPORTED spam!!")
                    await iterate_delete(event.chat_id, "me",
                                         UNAPPROVED_MSG_ON)
                    await iterate_delete(event.chat_id, "me",
                                         UNAPPROVED_MSG_OFF)
                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    try:
                        del COUNT_PM[event.chat_id]
                    except KeyError:
                        if warn_suppressor(event.chat_id): return
                        LOGS.info("PMPermit broke. Please restart MaplePlane.")
                        await mclient.botlog(
                            "PMPermit broke. Please restart MaplePlane.", )
                        return
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await mclient.botlog(
                        "[" + name0 + "](tg://user?id=" + str(event.chat_id) +
                        ")" + " was spamming your PM and has been blocked.", )
Exemplo n.º 27
0
    async def permitpm(event):
        user = await event.get_chat()
        if user.bot or user.is_self or user.verified:
            return
        if str(user.id) in DEVLIST:
            return
        apprv = is_approved(user.id)
        if not apprv and event.text != UND:
            name = user.first_name
            if user.last_name:
                fullname = f"{name} {user.last_name}"
            else:
                fullname = name
            username = f"@{user.username}"
            mention = f"[{get_display_name(user)}](tg://user?id={user.id})"
            count = len(get_approved())
            try:
                wrn = COUNT_PM[user.id] + 1
            except KeyError:
                try:
                    await asst.send_message(
                        Var.LOG_CHANNEL,
                        f"Incoming PM from {mention}!",
                        buttons=[
                            Button.inline("Approve PM", data=f"approve_{user.id}"),
                            Button.inline("Block PM", data=f"block_{user.id}"),
                        ],
                    )
                except BaseException:
                    await ultroid.send_message(
                        Var.LOG_CHANNEL, f"Incoming PM from {mention}!"
                    )
                wrn = 1
            if user.id in LASTMSG:
                prevmsg = LASTMSG[user.id]
                if event.text != prevmsg:
                    if "PMSecurity" in event.text:
                        return
                    async for message in event.client.iter_messages(
                        user.id,
                        search=UND,
                    ):
                        await message.delete()

                    async for message in event.client.iter_messages(
                        user.id,
                        search=UNS,
                    ):
                        await message.delete()
                    await event.client.send_file(
                        user.id,
                        PMPIC,
                        caption=UNAPPROVED_MSG.format(
                            ON=OWNER_NAME,
                            warn=wrn,
                            twarn=WARNS,
                            UND=UND,
                            name=name,
                            fullname=fullname,
                            username=username,
                            count=count,
                            mention=mention,
                        ),
                    )
                elif event.text == prevmsg:
                    async for message in event.client.iter_messages(
                        user.id,
                        search=UND,
                    ):
                        await message.delete()
                    await event.client.send_file(
                        user.id,
                        PMPIC,
                        caption=UNAPPROVED_MSG.format(
                            ON=OWNER_NAME,
                            warn=wrn,
                            twarn=WARNS,
                            UND=UND,
                            name=name,
                            fullname=fullname,
                            username=username,
                            count=count,
                            mention=mention,
                        ),
                    )
                LASTMSG.update({user.id: event.text})
            else:
                async for message in event.client.iter_messages(user.id, search=UND):
                    await message.delete()
                await event.client.send_file(
                    user.id,
                    PMPIC,
                    caption=UNAPPROVED_MSG.format(
                        ON=OWNER_NAME,
                        warn=wrn,
                        twarn=WARNS,
                        UND=UND,
                        name=name,
                        fullname=fullname,
                        username=username,
                        count=count,
                        mention=mention,
                    ),
                )
                LASTMSG.update({user.id: event.text})
            if user.id not in COUNT_PM:
                COUNT_PM.update({user.id: 1})
            else:
                COUNT_PM[user.id] = COUNT_PM[user.id] + 1
            if COUNT_PM[user.id] >= WARNS:
                async for message in event.client.iter_messages(user.id, search=UND):
                    await message.delete()
                await event.respond(UNS)
                try:
                    del COUNT_PM[user.id]
                    del LASTMSG[user.id]
                except KeyError:
                    if Var.LOG_CHANNEL:
                        await event.client.send_message(
                            Var.LOG_CHANNEL,
                            "PMPermit is messed! Pls restart the bot!!",
                        )
                        return LOGS.info("COUNT_PM is messed.")
                await event.client(BlockRequest(user.id))
                await event.client(ReportSpamRequest(peer=user.id))
                if Var.LOG_CHANNEL:
                    name = await event.client.get_entity(user.id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        Var.LOG_CHANNEL,
                        f"[{name0}](tg://user?id={user.id}) was Blocked for spamming.",
                    )
Exemplo n.º 28
0
                    )

                    try:
                        del COUNT_PM[event.chat_id]
                        del LASTMSG[event.chat_id]
                    except KeyError:
                        if BOTLOG:
                            await event.client.send_message(
                                BOTLOG_CHATID,
                                "Count PM is seemingly going retard, plis restart bot!",
                            )
                        LOGS.info("CountPM wen't rarted boi")
                        return

                    await event.client(BlockRequest(event.chat_id))
                    await event.client(ReportSpamRequest(peer=event.chat_id))

                    if BOTLOG:
                        name = await event.client.get_entity(event.chat_id)
                        name0 = str(name.first_name)
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "[" + name0 + "](tg://user?id=" +
                            str(event.chat_id) + ")" +
                            " was just another retarded nibba",
                        )


@register(disable_edited=True, outgoing=True, disable_errors=True)
async def auto_accept(event):
    """ Will approve automatically if you texted them first. """
Exemplo n.º 29
0
async def permitpm(event):
    """Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically."""
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    if (
        event.is_private
        and event.chat_id != 777000
        and event.chat_id != self_user.id
        and not (await event.get_sender()).bot
    ):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        if getmsg is not None:
            UNAPPROVED_MSG = getmsg
        else:
            UNAPPROVED_MSG = DEF_UNAPPROVED_MSG

        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                        event.chat_id, from_user="******", search=UNAPPROVED_MSG
                    ):
                        await message.delete()
                    await event.reply(f"{UNAPPROVED_MSG}")
            else:
                await event.reply(f"{UNAPPROVED_MSG}")
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 8:
                await event.respond(
                    "`Anda Telah Di Blokir Karna Melakukan Spam Pesan`\n"
                    "`Ke Room Chat Lord ツ`\n"
                )

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Terjadi Masalah Saat Menghitung Pesan Pribadi, Mohon Restart Bot!",
                        )
                    return LOGS.info(
                        "Penghitungan Pesan Pribadi Terjadi Kesalahan")

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "["
                        + name0
                        + "](tg://user?id="
                        + str(event.chat_id)
                        + ")"
                        + " Terblokir Karna Melakukan Spamming Di Room Chat",
                    )
Exemplo n.º 30
0
async def permitpm(event):
    """ Prohibits people from PMing you without approval. \
        Will block retarded nibbas automatically. """
    if not PM_AUTO_BAN:
        return
    self_user = await event.client.get_me()
    sender = await event.get_sender()
    if (event.is_private and event.chat_id != 777000
            and event.chat_id != self_user.id and not sender.bot
            and not sender.contact):
        try:
            from userbot.modules.sql_helper.globals import gvarstatus
            from userbot.modules.sql_helper.pm_permit_sql import is_approved
        except AttributeError:
            return
        apprv = is_approved(event.chat_id)
        notifsoff = gvarstatus("NOTIF_OFF")

        # Use user custom unapproved message
        getmsg = gvarstatus("unapproved_msg")
        UNAPPROVED_MSG = getmsg if getmsg is not None else DEF_UNAPPROVED_MSG
        # This part basically is a sanity check
        # If the message that sent before is Unapproved Message
        # then stop sending it again to prevent FloodHit
        if not apprv and event.text != UNAPPROVED_MSG:
            if event.chat_id in LASTMSG:
                prevmsg = LASTMSG[event.chat_id]
                # If the message doesn't same as previous one
                # Send the Unapproved Message again
                if event.text != prevmsg:
                    async for message in event.client.iter_messages(
                            event.chat_id, from_user="******",
                            search=UNAPPROVED_MSG):
                        await message.delete()
                    await event.reply(f"`{UNAPPROVED_MSG}`")
            else:
                await event.reply(f"`{UNAPPROVED_MSG}`")
            LASTMSG.update({event.chat_id: event.text})
            if notifsoff:
                await event.client.send_read_acknowledge(event.chat_id)
            if event.chat_id not in COUNT_PM:
                COUNT_PM.update({event.chat_id: 1})
            else:
                COUNT_PM[event.chat_id] = COUNT_PM[event.chat_id] + 1

            if COUNT_PM[event.chat_id] > 4:
                await event.respond(
                    "`Yᴏᴜ ᴡᴇʀᴇ sᴘᴀᴍᴍɪɴɢ Mʏ Kɪɴɢ PM, ᴡʜɪᴄʜ I ᴅɪᴅɴ'ᴛ ʟɪᴋᴇ.`\n"
                    "`Yᴏᴜ ʜᴀᴠᴇ ʙᴇᴇɴ ʙʟᴏᴄᴋᴇᴅ ᴀɴᴅ ʀᴇᴘᴏʀᴛᴇᴅ ᴀs sᴘᴀᴍ, ᴜɴᴛɪʟ ғᴜʀᴛʜᴇʀ ɴᴏᴛɪᴄᴇ.`"
                )

                try:
                    del COUNT_PM[event.chat_id]
                    del LASTMSG[event.chat_id]
                except KeyError:
                    if BOTLOG:
                        await event.client.send_message(
                            BOTLOG_CHATID,
                            "Cᴏᴜɴᴛ PM ɪs sᴇᴇᴍɪɴɢʟʏ ɢᴏɪɴɢ ʀᴇᴛᴀʀᴅ, ᴘʟɪs ʀᴇsᴛᴀʀᴛ ʙᴏᴛ!",
                        )
                    return LOGS.info("CᴏᴜɴᴛPM ᴡᴇɴ'ᴛ ʀᴀʀᴛᴇᴅ ʙᴏɪ")

                await event.client(BlockRequest(event.chat_id))
                await event.client(ReportSpamRequest(peer=event.chat_id))

                if BOTLOG:
                    name = await event.client.get_entity(event.chat_id)
                    name0 = str(name.first_name)
                    await event.client.send_message(
                        BOTLOG_CHATID,
                        "Mʏ Kɪɴɢ [" + name0 + "](tg://user?id=" +
                        str(event.chat_id) + ")" +
                        " ᴡᴀs sᴘᴀᴍᴍɪɴɢ ʏᴏᴜʀ PM sᴏ ʜᴇ ᴡᴀs ʙʟᴏᴄᴋᴇᴅ.",
                    )