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 human join Anie bot support chat' @AnieRoSupport` \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", )
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 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.`") 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", )
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global AFFKREASON ISAFK_SQL = False AFKREASON_SQL = None if afk_db: ISAFK_SQL = gvarstatus("AFK_STATUS") AFKREASON_SQL = gvarstatus("AFK_REASON") global USERS global COUNT_MSG EXCUSE = AFKREASON_SQL if afk_db else AFKREASON if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and (ISAFK or ISAFK_SQL): if sender.sender_id not in USERS: if EXCUSE: await sender.reply(f"I'm AFK right now.\ \nReason: `{EXCUSE}`") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if EXCUSE: await sender.reply( f"In case you didn't notice, I'm still AFK.\ \nReason: `{EXCUSE}`") else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG if ( sender.is_private and sender.sender_id != 777000 and not (await sender.get_sender()).bot ): if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import \ is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"I'm AFK right now.\ \nReason: {AFKREASON}" ) else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) else: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply( f"I'm still AFK.\ \nReason: {AFKREASON}" ) else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not (await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"Sorry! I am AFK due to `{AFKREASON}`. I'll respond as soon I come back." ) else: await sender.reply( str(random.choice(AFKSTR)) ) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % 2 == 0: if AFKREASON: await sender.reply( f"Sorry! But I'm still not back yet. Currently busy with `{AFKREASON}`." ) else: await sender.reply( str(random.choice(AFKSTR)) ) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def auto_accept(event): """ Will approve nibbas automatically if you texted them first. """ try: from userbot.modules.sql_helper.pm_permit_sql import is_approved from userbot.modules.sql_helper.pm_permit_sql import approve except AttributeError: return chat = await event.get_chat() if isinstance(chat, User): if is_approved(event.chat_id): return async for message in event.client.iter_messages(chat.id, reverse=True, limit=1): if message.from_id == (await event.client.get_me()).id: approve(chat.id) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#AUTO-APPROVED\n" + "User: "******"[{chat.first_name}](tg://user?id={chat.id})", )
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", )
async def afk_on_pm(sender): """ Siz afk iken PM atanları afk olduğunuza dair bildirmeye yarayan fonksiyondur. """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply(f"{LANG['AFK']}\ \n{LANG['REASON']}: `{AFKREASON}`") else: await sender.reply(PLUGIN_MESAJLAR['afk']) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: if type(PLUGIN_MESAJLAR['afk']) is str: await sender.reply(f"{PLUGIN_MESAJLAR['afk']}\ \n{LANG['REASON']}: `{AFKREASON}`") else: msj = await sender.reply(PLUGIN_MESAJLAR['afk']) await msj.reply(f"{LANG['REASON']}: `{AFKREASON}`") else: await sender.reply(PLUGIN_MESAJLAR['afk']) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def permitpm(e): if PM_AUTO_BAN: global COUNT_PM if e.is_private and not (await e.get_sender()).bot: from userbot.modules.sql_helper.pm_permit_sql import is_approved E=is_approved(e.chat_id) if not E: await e.reply("`Bleep Blop! This is a Bot. Don't fret. \n\nMy 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.`") 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)) 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")
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"`Sorry, my Boss is offline because is {AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % 3 == 0: if AFKREASON: await sender.reply( "`Hello, i'm a bot!`\n\n" f"`Currently my Boss is still offline because {AFKREASON}`\n\n" "`Please wait until my Boss responds to your message.` 😉👍" ) else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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", )
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"Maaf sob 🙏, lagi pindah alam karena `{AFKREASON}`. Saya akan lihat pesanmu setelah saya kembali 😉." ) else: await sender.reply(str(random.choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % 2 == 0: if AFKREASON: await sender.reply( f"Maaf, saya masih ada di dunia yang lain. Terlalu sibuk dengan `{AFKREASON}`." ) else: await sender.reply(str(random.choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Siz afk iken PM atanları afk olduğunuza dair bildirmeye yarayan fonksiyondur. """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply(f"Sahibim şu an AFK.\ \nSebep: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply(f"Sahibim halen AFK.\ \nSebep: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply(f"Aku enggak bukak telegram njinc.\ \nKarena: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply(f"Woy blom bukak telegram cuk!\ \nKarena: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ ISAFK = gvarstatus("AFK_STATUS") global USERS global COUNT_MSG AFKREASON = gvarstatus("AFK_REASON") if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved except AttributeError: return apprv = is_approved(sender.sender_id) if (PM_AUTO_BAN and apprv) and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"Sorry!My Master is AFK due to `{AFKREASON}`. He'll respond as soon he comes back." ) else: await sender.reply(str(random.choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % 2 == 0: if AFKREASON: await sender.reply( f"Sorry! But He's still not back. Currently busy with `{AFKREASON}`." ) else: await sender.reply(str(random.choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def permitpm(event): """ Permits people from PMing you without approval. \ Will block retarded nibbas automatically. """ if PM_AUTO_BAN: if event.is_private 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: 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 spamming my peru master's PM, which I don't like.`" " `I'mma Report Spam, now GTFO.`" ) 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", )
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", )
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG global COUNT_MSG global USERS global ISAFK global USER_AFK # pylint:disable=E0602 global afk_time # pylint:disable=E0602 global afk_start global afk_end user = await bot.get_me() # pylint:disable=E0602 back_alivee = datetime.now() afk_end = back_alivee.replace(microsecond=0) afk_since = "**Belum Lama**" if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() datime_since_afk = now - afk_time # pylint:disable=E0602 time = float(datime_since_afk.seconds) days = time // (24 * 3600) time = time % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if days == 1: afk_since = "**Kemarin**" elif days > 1: if days > 6: date = now + \ datetime.timedelta( days=-days, hours=-hours, minutes=-minutes) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datetime.timedelta(days=-days) afk_since = wday.strftime('%A') elif hours > 1: afk_since = f"`{int(hours)} Jam {int(minutes)} Menit`" elif minutes > 0: afk_since = f"`{int(minutes)} Menit {int(seconds)} Detik`" else: afk_since = f"`{int(seconds)} Detik`" if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"🍁 𝙇𝙖𝙜𝙞 𝘼𝙛𝙠..\n╭╼━━━━┅┅┅┅┄┄┄┄┉┉┄┄ \n┃➠ {ALIVE_NAME} ꜱᴇᴅᴀɴɢ ᴀꜰᴋ\n┃➠ ꜱᴇᴊᴀᴋ: {afk_since}\n┃➠ ᴀʟᴀꜱᴀɴ: {AFKREASON}\n╰╼━┅┅┄┄┄┄┉┉" ) else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply( f"🍁 𝙇𝙖𝙜𝙞 𝘼𝙛𝙠..\n╭╼━━━━┅┅┅┅┄┄┄┄┉┉┄┄┄ \n┃➠ {ALIVE_NAME} ꜱᴇᴅᴀɴɢ ᴀꜰᴋ\n┃➠ ꜱᴇᴊᴀᴋ: {afk_since}\n┃➠ ᴀʟᴀꜱᴀɴ: {AFKREASON}\n╰╼━┅┅┄┄┄┄┉┉" ) else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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", )
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG global COUNT_MSG global USERS global ISAFK global USER_AFK # pylint:disable=E0602 global afk_time # pylint:disable=E0602 global afk_start global afk_end back_alivee = datetime.now() afk_end = back_alivee.replace(microsecond=0) afk_since = "a while ago" if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() datime_since_afk = now - afk_time # pylint:disable=E0602 time = float(datime_since_afk.seconds) days = time // (24 * 3600) time = time % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if days == 1: afk_since = "Yesterday" elif days > 1: if days > 6: date = now + \ datetime.timedelta( days=-days, hours=-hours, minutes=-minutes) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datetime.timedelta(days=-days) afk_since = wday.strftime('%A') elif hours > 1: afk_since = f"`{int(hours)}h{int(minutes)}m` ago" elif minutes > 0: afk_since = f"`{int(minutes)}m{int(seconds)}s` ago" else: afk_since = f"`{int(seconds)}s` ago" if sender.sender_id not in USERS: if AFKREASON: await sender.reply(f"I'm AFK since {afk_since}.\ \nReason: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply(f"I'm still AFK since {afk_since}.\ \nReason: `{AFKREASON}`") else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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", )
async def afk_on_pm(sender): global ISAFK if ISAFK: global USERS global COUNT_MSG global COUNT_MSG global USERS global USER_AFK global afk_time global afk_start global afk_end back_alivee = datetime.now() afk_end = back_alivee.replace(microsecond=0) afk_since = "a while ago" if sender.is_private and sender.sender_id != 710844948 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() datime_since_afk = now - afk_time # pylint:disable=E0602 time = float(datime_since_afk.seconds) days = time // (24 * 3600) time = time % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if days == 1: afk_since = "Yesterday" elif days > 1: if days > 6: date = now + \ datet.timedelta( days=-days, hours=-hours, minutes=-minutes) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datet.timedelta(days=-days) afk_since = wday.strftime('%A') elif hours > 1: afk_since = f"{int(hours)}h {int(minutes)}m ago" elif minutes > 0: afk_since = f"{int(minutes)}m {int(seconds)}s ago" else: afk_since = f"{int(seconds)}s ago" if sender.sender_id not in USERS: if AFKREASON: await sender.reply(f"`{JAVES_NNAME}:`**{AFK_MMSG}**\ \n\n`Reason:` **{AFKREASON}**\n`Since :`**{afk_since}**") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply( f"`{JAVES_NNAME}: ` **In case you didn't notice, My master Still Offline**\ \n\n`Reason:` **{AFKREASON}**\n`Since :`**{afk_since}**" ) else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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 𝐑𝐄𝐓𝐀𝐑𝐓𝐄𝐃.", )
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsecond=0) afk_str = "a while ago" if ( sender.is_private and sender.sender_id != 777000 and not (await sender.get_sender()).bot ): if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() afk_since = now - afk_time day = float(afk_since.seconds) // (24 * 3600) time = float(afk_since.seconds) % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if day == 1: afk_str = "Yesterday" elif day > 1: if day > 6: date = now + datetime.timedelta( days=-day, hours=-hours, minutes=-minutes ) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datetime.timedelta(days=-day) afk_str = wday.strftime("%A") elif hours > 1: afk_str = f"`{int(hours)}jam{int(minutes)}menit{int(seconds)}detik yg lalu.`" elif minutes > 0: afk_str = f"`{int(minutes)}menit{int(seconds)}detik yg lalu.`" else: afk_str = f"`{int(seconds)}detik yg lalu.`" if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"**Sedang offline.**\n**Sejak :** {afk_str}" f"\n**Alasan :** `{AFKREASON}.`" ) else: await sender.reply( f"**Sedang offline.**\n**Sejak :** {afk_str}" "\n**Silahkan hubungi lagi nanti.**" ) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply( f"**Sedang offline.**\n**Sejak :** {afk_str}" f"\n**Alasan :** `{AFKREASON}.`" ) else: await sender.reply( f"**Sedang offline.**\n**Sejak :** {afk_str}" "\n**Silahkan hubungi lagi nanti.**" ) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """Function which informs people that you are AFK in PM""" global ISAFK global USERS global COUNT_MSG global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsecond=0) afk_str = "a while ago" if (sender.is_private and sender.sender_id != 777000 and not (await sender.get_sender()).bot): if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() afk_since = now - afk_time day = float(afk_since.seconds) // (24 * 3600) time = float(afk_since.seconds) % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if day == 1: afk_str = "Yesterday" elif day > 1: if day > 6: date = now + datetime.timedelta( days=-day, hours=-hours, minutes=-minutes) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datetime.timedelta(days=-day) afk_str = wday.strftime("%A") elif hours > 1: afk_str = f"`{int(hours)}h{int(minutes)}m` ago" elif minutes > 0: afk_str = f"`{int(minutes)}m{int(seconds)}s` ago" else: afk_str = f"`{int(seconds)}s` ago" if sender.sender_id not in USERS: if AFKREASON: await sender.reply( "I'm AFK right now, I will be back soon." f"\nReason: `{AFKREASON}`." f"\nAFK since: {afk_str}") else: await sender.reply(str(choice(AFKSTR))) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply("I'm still AFK,I will be back soon." f"\nReason: `{AFKREASON}`." f"\nAFK from: {afk_str}") else: await sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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.", )
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", )
async def afk_on_pm(sender): global ISAFK global USERS global COUNT_MSG if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True from_user = await sender.get_sender() if from_user.username: username = '******' + from_user.username else: username = f'[{from_user.first_name} {from_user.last_name}](tg://user?id={from_user.id})' mention = f'[{from_user.first_name}](tg://user?id={from_user.id})' first_name = from_user.first_name if from_user.last_name: last_name = from_user.last_name else: last_name = '' last_seen_seconds = round(time() - SON_GORULME) last_seen = time_formatter(last_seen_seconds) last_seen_long = time_formatter(last_seen_seconds, False) if apprv and ISAFK: if sender.sender_id not in USERS: if AFKREASON: await sender.reply(LANG['AFK'].format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long ) \ + f"\n{LANG['REASON']}: `{AFKREASON}`") else: if not isinstance(PLUGIN_MESAJLAR['afk'], str): PLUGIN_MESAJLAR['afk'].text = PLUGIN_MESAJLAR[ 'afk'].text.format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long) await sender.reply(PLUGIN_MESAJLAR['afk']) else: await sender.reply(PLUGIN_MESAJLAR['afk'].format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long)) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: if type(PLUGIN_MESAJLAR['afk']) is str: await sender.reply({PLUGIN_MESAJLAR['afk']}.format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long ) \ + f"\n{LANG['REASON']}: `{AFKREASON}`") else: msj = await sender.reply(PLUGIN_MESAJLAR['afk']) await msj.reply(f"{LANG['REASON']}: `{AFKREASON}`") else: if not isinstance(PLUGIN_MESAJLAR['afk'], str): PLUGIN_MESAJLAR['afk'].text = PLUGIN_MESAJLAR[ 'afk'].text.format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long) await sender.reply(PLUGIN_MESAJLAR['afk']) else: await sender.reply(PLUGIN_MESAJLAR['afk'].format( username=username, mention=mention, first_name=first_name, last_name=last_name, last_seen_seconds=last_seen_seconds, last_seen=last_seen, last_seen_long=last_seen_long)) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
async def afk_on_pm(sender): """ Function which informs people that you are AFK in PM """ global ISAFK global USERS global COUNT_MSG global COUNT_MSG global USERS global ISAFK global USER_AFK # pylint:disable=E0602 global afk_time # pylint:disable=E0602 global afk_start global afk_end back_alivee = datetime.now() afk_end = back_alivee.replace(microsecond=0) afk_since = "**a while ago**" if sender.is_private and sender.sender_id != 777000 and not ( await sender.get_sender()).bot: if PM_AUTO_BAN: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved apprv = is_approved(sender.sender_id) except AttributeError: apprv = True else: apprv = True if apprv and ISAFK: now = datetime.now() datime_since_afk = now - afk_time # pylint:disable=E0602 time = float(datime_since_afk.seconds) days = time // (24 * 3600) time = time % (24 * 3600) hours = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time if days == 1: afk_since = "**Yesterday**" elif days > 1: if days > 6: date = now + \ datetime.timedelta( days=-days, hours=-hours, minutes=-minutes) afk_since = date.strftime("%A, %Y %B %m, %H:%I") else: wday = now + datetime.timedelta(days=-days) afk_since = wday.strftime('%A') elif hours > 1: afk_since = f"`{int(hours)}h {int(minutes)}m` **ago**" elif minutes > 0: afk_since = f"`{int(minutes)}m {int(seconds)}s` **ago**" else: afk_since = f"`{int(seconds)}s` **ago**" if sender.sender_id not in USERS: if AFKREASON: await sender.reply( f"My Owner **{DEFAULTUSER}** Is **afk since** {afk_since}.\ \n**Because he is** `{AFKREASON}`") else: await sender.replyf( f"My Owner 👑 {DEFAULTUSER} 👑 is **afk Since** {afk_since}.\nand My Owner has left a word for you only: \n{AFKSK}\n`.` " ) USERS.update({sender.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif apprv and sender.sender_id in USERS: if USERS[sender.sender_id] % randint(2, 4) == 0: if AFKREASON: await sender.reply( f"My Owner **{DEFAULTUSER}** Is {AFKREASON}.\ \n**Since** `{afk_since}`") else: await sender.reply( f"My Owner 👑 {DEFAULTUSER} 👑 is **afk Since** {afk_since}.\nand My Owner has left a word for you only: \n{AFKSK}\n`.` " ) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1
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'], )