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're spamming my PM, " "which I don't like. Reporting as spam.") 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 f*****g up, " "please restart the bot!", ) LOGS.info("CountPM f****d up") 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 idiot", )
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: 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( "`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: 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): """ 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] > 2: await event.respond( "`Goblok, tolol banget si, udah dibilangin minta izin dulu, kalo gak di izinin ya gausah spam anjing🖕.`\n" "`lu kena block otomatis dari bot, bye🖕 LOLOT.`" ) 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) + ")" + " Lapor, 1 orang kena block bosku", )
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] > PM_LIMIT: await event.respond( "**Maaf Anda Telah Di Blokir Karna Melakukan Spam Chat**" ) try: del COUNT_PM[event.chat_id] del LASTMSG[event.chat_id] except KeyError: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, "**Terjadi Error Saat Menghitung Private Message, Mohon Restart Bot!**", ) return LOGS.info("Gagal menghitung PM yang diterima") await event.client(BlockRequest(event.chat_id)) await event.client(ReportSpamRequest(peer=event.chat_id)) if BOTLOG_CHATID: 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 Diblokir Karna Melakukan Spam Ke Room Chat**", )
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: 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.", )
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( "`Mohon jangan melakukan spam, bot akan otomatis blokir anda jika melakukan spam ðŸ˜.`\n" "`Anda sekarang kami BLOKIR, dikarenakan melakukan spam berulang kali.. silahkan menunggu sampai Owner Buka BLOKIR untuk anda.. maaf`" ) 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 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", )
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", )
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", )
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.`") 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) + ")" + " era solo un altro ritardato mentale", )
) 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. """
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: 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( "`You were spamming my owner's PM, " "which I don't like.`" " `Reporting you as spam.`" ) try: del COUNT_PM[event.chat_id] del LASTMSG[event.chat_id] except KeyError: if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "PMPermit broke, please restart Paperplane.", ) LOGS.info("PMPermit broke, please restart Paperplane.") 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 spamming your PM and has been blocked.", )
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 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 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: return async for message in ultroid.iter_messages( user.id, search=UND, ): await message.delete() async for message in ultroid.iter_messages( user.id, search=UNS, ): await message.delete() message_ = UNAPPROVED_MSG.format( ON=OWNER_NAME, warn=wrn, twarn=WARNS, UND=UND, name=name, fullname=fullname, username=username, count=count, mention=mention, ) await ultroid.send_file( user.id, PMPIC, caption=message_, ) elif event.text == prevmsg: async for message in ultroid.iter_messages( user.id, search=UND, ): await message.delete() message_ = UNAPPROVED_MSG.format( ON=OWNER_NAME, warn=wrn, twarn=WARNS, UND=UND, name=name, fullname=fullname, username=username, count=count, mention=mention, ) await ultroid.send_file( user.id, PMPIC, caption=message_, ) LASTMSG.update({user.id: event.text}) else: async for message in ultroid.iter_messages(user.id, search=UND): await message.delete() message_ = UNAPPROVED_MSG.format( ON=OWNER_NAME, warn=wrn, twarn=WARNS, UND=UND, name=name, fullname=fullname, username=username, count=count, mention=mention, ) await ultroid.send_file( user.id, PMPIC, caption=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: async for message in ultroid.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: 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.", )
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] > 4: await event.respond( "``Anda melakukan spamming pada PM saya, yang tidak saya sukai.`\n" "`Saya tidak akan membiarkan Anda mengobrol dengan saya lagi sampai pemberitahuan lebih lanjut`\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, "Hitung PM tampaknya akan terbelakang, silakan restart bot!", ) return LOGS.info("CountPM menjadi 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) + ")" + " was spammed your PM and got blocked", )
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!", )
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", )
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", )
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") # 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 Di Blokir Karna Melakukan Spam Pesan.`\n" "`Ke Personal Chat!ツ.`") 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 Ke Personal Chat!", )
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 from userbot.modules.sql_helper.globals import gvarstatus except AttributeError: return apprv = is_approved(event.chat_id) NOTIF_OFF = 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 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 him, blocking and reporting you!`") try: del COUNT_PM[event.chat_id] del LASTMSG[event.chat_id] except KeyError: if LOGGER: await event.client.send_message( LOGGER_GROUP, "Count PM is seemingly going retard, restart bot!", ) LOGS.info("CountPM went rarted.") 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", )
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", )
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( "`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.", )
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, file=CUSTOM_PIC, ): await message.delete() await event.reply(f"{CUSTOM_PIC}\n\n{UNAPPROVED_MSG}") else: await event.reply(f"{CUSTOM_PIC}\n\n{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( "✣ __**SISTEM BLOKIR OTOMATIS**__\n\n__Mohon Maaf Nomor Anda Telah Di Blokir Karena Spam Pesan__\n" f"__Ke Room Chat King {DEFAULTUSER}__") try: del COUNT_PM[event.chat_id] del LASTMSG[event.chat_id] except KeyError: if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "king, Terjadi Masalah Saat Menghitung Private Message, Mohon Restart Bot!", ) return LOGS.info("CountPM tidak dibunyikan king") 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 Diblokir Karna Melakukan Spam Ke Room Chat", )
async def permitpm(event): 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'], )
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) _to_delete[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.", )
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 != UNAPPROVED_MSG: 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=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( "`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): """ İ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'], )
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( "`You were spamming my Führer'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 permitpm(event): t_in = Redis("INLINE_PM") inline_pm = False if t_in == "True": inline_pm = True user = await event.get_sender() if user.bot or user.is_self or user.verified: return if 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 = get_display_name(user) 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 not inline_pm: if PMPIC: _to_delete[user.id] = await ultroid.send_file( user.id, PMPIC, caption=message_, ) else: _to_delete[ user.id] = await ultroid_bot.send_message( user.id, message_) else: results = await ultroid.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)) 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 not inline_pm: if PMPIC: _to_delete[user.id] = await ultroid.send_file( user.id, PMPIC, caption=message_, ) else: _to_delete[ user.id] = await ultroid_bot.send_message( user.id, message_) else: try: results = await ultroid.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)) 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 not inline_pm: if 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: try: results = await ultroid.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)) 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.", )