async def spam_function(event, spammer, xnxx, sleeptimem, sleeptimet, DelaySpam=False): counter = int(xnxx[0]) if len(xnxx) == 2: spam_message = str(xnxx[1]) for _ in range(counter): if gvarstatus("spamwork") is None: return if event.reply_to_msg_id: await spammer.reply(spam_message) else: await event.client.send_message(event.chat_id, spam_message) await asyncio.sleep(sleeptimet) elif event.reply_to_msg_id and spammer.media: for _ in range(counter): if gvarstatus("spamwork") is None: return spammer = await event.client.send_file(event.chat_id, spammer, caption=spammer.text) await unsavegif(event, spammer) await asyncio.sleep(sleeptimem) if BOTLOG_CHATID: if DelaySpam is not True: if event.is_private: await event.client.send_message( BOTLOG_CHATID, "#SPAM\n" + f"Spam was executed successfully in [User](tg://user?id={event.chat_id}) chat with {counter} times with below message", ) else: await event.client.send_message( BOTLOG_CHATID, "#SPAM\n" + f"Spam was executed successfully in {get_display_name(await event.get_chat())}(`{event.chat_id}`) with {counter} times with below message", ) elif event.is_private: await event.client.send_message( BOTLOG_CHATID, "#DELAYSPAM\n" + f"Delay spam was executed successfully in [User](tg://user?id={event.chat_id}) chat with {counter} times with below message with delay {sleeptimet} seconds", ) else: await event.client.send_message( BOTLOG_CHATID, "#DELAYSPAM\n" + f"Delay spam was executed successfully in {get_display_name(await event.get_chat())}(`{event.chat_id}`) with {counter} times with below message with delay {sleeptimet} seconds", ) spammer = await event.client.send_file(BOTLOG_CHATID, spammer) await unsavegif(event, spammer) return elif event.reply_to_msg_id and spammer.text: spam_message = spammer.text for _ in range(counter): if gvarstatus("spamwork") is None: return await event.client.send_message(event.chat_id, spam_message) await asyncio.sleep(sleeptimet) else: return if DelaySpam is not True: if BOTLOG_CHATID: if event.is_private: await event.client.send_message( BOTLOG_CHATID, "#SPAM\n" + f"Spam was executed successfully in [User](tg://user?id={event.chat_id}) chat with {counter} messages of \n" + f"`{spam_message}`", ) else: await event.client.send_message( BOTLOG_CHATID, "#SPAM\n" + f"Spam was executed successfully in {get_display_name(await event.get_chat())}(`{event.chat_id}`) chat with {counter} messages of \n" + f"`{spam_message}`", ) elif BOTLOG_CHATID: if event.is_private: await event.client.send_message( BOTLOG_CHATID, "#DELAYSPAM\n" + f"Delay Spam was executed successfully in [User](tg://user?id={event.chat_id}) chat with delay {sleeptimet} seconds and with {counter} messages of \n" + f"`{spam_message}`", ) else: await event.client.send_message( BOTLOG_CHATID, "#DELAYSPAM\n" + f"Delay spam was executed successfully in {get_display_name(await event.get_chat())}(`{event.chat_id}`) chat with delay {sleeptimet} seconds and with {counter} messages of \n" + f"`{spam_message}`", )
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 spamming my PM, which フøҜ𝖊ℜ 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!", ) 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): """ İ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): """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 PM, which I didn't like.`\n" "`I Wouldn't let you to chat me again until further notice`\n" "`Bye`") try: del COUNT_PM[event.chat_id] del LASTMSG[event.chat_id] except KeyError: 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() 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 add_pmsg(cust_msg): """Set your own Unapproved message""" if not PM_AUTO_BAN: return await cust_msg.edit( "** Anda Harus Menyetel** `PM_AUTO_BAN` **Ke** `True`" ) try: import userbot.modules.sql_helper.globals as sql except AttributeError: await cust_msg.edit("`Running on Non-SQL mode!`") return await cust_msg.edit("➳ `Sedang Memproses...` ") conf = cust_msg.pattern_match.group(1) custom_message = sql.gvarstatus("unapproved_msg") if conf.lower() == "set": message = await cust_msg.get_reply_message() status = "Pesan" # check and clear user unapproved message first if custom_message is not None: sql.delgvar("unapproved_msg") status = "Pesan" if message: # TODO: allow user to have a custom text formatting # eg: bold, underline, striketrough, link # for now all text are in monoscape msg = message.message # get the plain text sql.addgvar("unapproved_msg", msg) else: return await cust_msg.edit("☙ `Mohon Balas Ke Pesan` ❧") await cust_msg.edit("➳ `Pesan Berhasil Disimpan Ke Room Chat` ") if BOTLOG: await cust_msg.client.send_message( BOTLOG_CHATID, f"**{status} PM Yang Tersimpan Dalam Room Chat Anda:** \n\n{msg}", ) if conf.lower() == "reset": if custom_message is not None: sql.delgvar("unapproved_msg") await cust_msg.edit("➳ `Anda Telah Menghapus Pesan Custom PM Ke Default` ") else: await cust_msg.edit("➳ `Pesan PM Anda Sudah Default Sejak Awal` ") if conf.lower() == "get": if custom_message is not None: await cust_msg.edit( "**Ini Adalah Pesan PM Yang Sekarang Dikirimkan Ke Room Chat Anda:**" f"\n\n{custom_message}" ) else: await cust_msg.edit( "*Anda Belum Menyetel Pesan PM*\n" f"Masih Menggunakan Pesan PM Default: \n\n`{DEF_UNAPPROVED_MSG}`" )
async def add_pmsg(cust_msg): """ Defina sua própria Mensagem não aprovada automática. """ if not PM_AUTO_BAN: return await cust_msg.edit( "Você precisa definir `PM_AUTO_BAN` nas ConfigVars do Heroku para `True`" ) try: import userbot.modules.sql_helper.globals as sql except AttributeError: await cust_msg.edit("`Executando em modo não-SQL!`") return await cust_msg.edit("Processing...") conf = cust_msg.pattern_match.group(1) custom_message = sql.gvarstatus("unapproved_msg") if conf.lower() == "set": message = await cust_msg.get_reply_message() status = "Saved" # check and clear user unapproved message first if custom_message is not None: sql.delgvar("unapproved_msg") status = "Updated" if message: # TODO: allow user to have a custom text formatting # eg: bold, underline, striketrough, link # for now all text are in monoscape msg = message.message # get the plain text sql.addgvar("unapproved_msg", msg) else: return await cust_msg.edit("`Responda a uma mensagem`") await cust_msg.edit( "`Mensagem salva como Mensagem não aprovada automática`") if BOTLOG: await cust_msg.client.send_message( BOTLOG_CHATID, f"***{status} Mensagem não aprovada automática :*** \n\n{msg}") if conf.lower() == "reset": if custom_message is not None: sql.delgvar("unapproved_msg") await cust_msg.edit( "`Mensagem não aprovada automática redefinida para o padrão`") else: await cust_msg.edit( "`Você ainda não definiu uma mensagem personalizada`") if conf.lower() == "get": if custom_message is not None: await cust_msg.edit( "***Esta é a sua Mensagem não aprovada automática atual:***" f"\n\n{custom_message}") else: await cust_msg.edit( "*Você ainda não definiu Mensagem não aprovada automática*\n" f"Usando mensagem padrão: \n\n`{DEF_UNAPPROVED_MSG}`")
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): """ 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 approvepm(apprvpm): """For .ok command, give someone the permissions to PM you.""" try: from userbot.modules.sql_helper.globals import gvarstatus from userbot.modules.sql_helper.pm_permit_sql import approve except AttributeError: return await apprvpm.edit("`Running on Non-SQL mode!`") if apprvpm.reply_to_msg_id: reply = await apprvpm.get_reply_message() replied_user = await apprvpm.client.get_entity(reply.sender_id) uid = replied_user.id name0 = str(replied_user.first_name) elif apprvpm.pattern_match.group(1): inputArgs = apprvpm.pattern_match.group(1) try: inputArgs = int(inputArgs) except ValueError: pass try: user = await apprvpm.client.get_entity(inputArgs) except BaseException: return await apprvpm.edit("**Invalid username/ID.**") if not isinstance(user, User): return await apprvpm.edit( "**Mohon Reply Pesan User Yang ingin diterima.**") uid = user.id name0 = str(user.first_name) else: aname = await apprvpm.client.get_entity(apprvpm.chat_id) if not isinstance(aname, User): return await apprvpm.edit( "**Mohon Reply Pesan User Yang ingin diterima.**") name0 = str(aname.first_name) uid = apprvpm.chat_id # Get user custom msg getmsg = gvarstatus("unapproved_msg") UNAPPROVED_MSG = getmsg if getmsg is not None else DEF_UNAPPROVED_MSG async for message in apprvpm.client.iter_messages(apprvpm.chat_id, from_user="******", search=UNAPPROVED_MSG): await message.delete() try: approve(uid) except IntegrityError: return await apprvpm.edit("**Pesan Anda Sudah Diterima**") await apprvpm.edit(f"**Menerima Pesan Dari** [{name0}](tg://user?id={uid})" ) if BOTLOG: await apprvpm.client.send_message( BOTLOG_CHATID, "**#APPROVED**\n" + "**👤 User:** " + f"[{name0}](tg://user?id={uid})", )
@register(incoming=True, disable_edited=True, disable_errors=True) async def permitpm(event):Nai Mana Tu Bc Le Ab Ban kha. 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()
def petercord_cmd(allow_sudo=True, **args): args["func"] = lambda e: e.via_bot_id is None stack = inspect.stack() previous_stack_frame = stack[1] file_test = Path(previous_stack_frame.filename) file_test = file_test.stem.replace(".py", "") pattern = args["pattern"] groups_only = args.get("groups_only", False) admins_only = args.get("admins_only", False) allow_sudo = args.get("allow_sudo", True) args.get("allow_edited_updates", False) args["incoming"] = args.get("incoming", False) args["outgoing"] = True if bool(args["incoming"]): args["outgoing"] = False if pattern is not None: if pattern.startswith(r"\#"): args["pattern"] = re.compile(pattern) else: args["pattern"] = re.compile(hndlr + pattern) reg = re.compile("(.*)") try: cmd = re.search(reg, pattern) try: cmd = (cmd.group(1).replace( "$", "").replace("?(.*)", "").replace("(.*)", "").replace( "(?: |)", "").replace("| ", "").replace("( |)", "").replace( "?((.|//)*)", "").replace("?P<shortname>\\w+", "")) except BaseException: pass try: CMD_HELP[file_test].append(cmd) except BaseException: CMD_HELP.update({file_test: [cmd]}) except BaseException: pass if gvarstatus("blacklist_chats") is not None: args["blacklist_chats"] = True args["chats"] = blacklist_chats_list() if "admins_only" in args: del args["admins_only"] if "groups_only" in args: del args["groups_only"] if "allow_edited_updates" in args: del args["allow_edited_updates"] def decorator(func): async def wrapper(event): if not allow_sudo: if not event.out: return if not event.out and (str(event.sender_id) not in SUDO_USERS): return chat = await event.get_chat() naam = get_display_name(chat) if event.fwd_from: return if groups_only and event.is_private: return await eor(event, "`Use this in group/channel.`") if admins_only and not chat.admin_rights: return await eor(event, "`I am not an admin.`") try: await func(event) except FloodWaitError as fwerr: await petercord_bot.send_message( int(BOTLOG_CHATID), f"`FloodWaitError:\n{str(fwerr)}\n\nSleeping for {time_formatter((fwerr.seconds + 10)*1000)}`", ) sleep(fwerr.seconds + 10) await petercord_bot.send_message( int(BOTLOG_CHATID), "`Bot is working again`", ) await petercord_bot.send_message( int(BOTLOG_CHATID), "`Bot is working again`", ) except ChatSendInlineForbiddenError: return await eor(event, "`Inline Locked In This Chat.`") except events.StopPropagation: raise events.StopPropagation except KeyboardInterrupt: pass except BaseException as e: LOGS.exception(e) date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) ftext = "**Petercord Client Error:** `Forward this to` @TEAMSquadUserbotSupport\n\n" ftext += "`Py-Petercord Version: " + str(telever) ftext += "\n Petercord Version: " + str(telever) ftext += "\nTelethon Version: " + str(telever) + "\n\n" ftext += "--------START Petercord CRASH LOG--------" ftext += "\nDate: " + date ftext += "\nGroup: " + str(event.chat_id) + " " + str(naam) ftext += "\nSender ID: " + str(event.sender_id) ftext += "\nReplied: " + str(event.is_reply) ftext += "\n\nEvent Trigger:\n" ftext += str(event.text) ftext += "\n\nTraceback info:\n" ftext += str(format_exc()) ftext += "\n\nError text:\n" ftext += str(sys.exc_info()[1]) ftext += "\n\n--------END Petercord CRASH LOG--------" ftext += "\n\n\nLast 5 commits:\n" stdout, stderr = await bash( 'git log --pretty=format:"%an: %s" -5') result = str(stdout.strip()) + str(stderr.strip()) ftext += result + "`" await petercord_bot.send_message( int(BOTLOG_CHATID), ftext, ) petercord_bot.add_event_handler(wrapper, events.NewMessage(**args)) try: CMD_HELP[file_test].append(wrapper) except Exception: CMD_HELP.update({file_test: [wrapper]}) return wrapper return decorator
async def approvepm(apprvpm): """For .approve command, give someone the permissions to PM you.""" try: from userbot.modules.sql_helper.globals import gvarstatus from userbot.modules.sql_helper.pm_permit_sql import approve except AttributeError: return await apprvpm.edit("**Executando em modo não SQL!**") if apprvpm.reply_to_msg_id: reply = await apprvpm.get_reply_message() replied_user = await apprvpm.client.get_entity(reply.sender_id) uid = replied_user.id name0 = str(replied_user.first_name) elif apprvpm.pattern_match.group(1): inputArgs = apprvpm.pattern_match.group(1) try: inputArgs = int(inputArgs) except ValueError: pass try: user = await apprvpm.client.get_entity(inputArgs) except: return await apprvpm.edit("**Nome de usuário/ID inválido.**") if not isinstance(user, User): return await apprvpm.edit( "**Isso pode ser feito apenas com usuários.**") uid = user.id name0 = str(user.first_name) else: aname = await apprvpm.client.get_entity(apprvpm.chat_id) if not isinstance(aname, User): return await apprvpm.edit( "**Isso pode ser feito apenas com usuários.**") name0 = str(aname.first_name) uid = apprvpm.chat_id # Get user custom msg getmsg = gvarstatus("unapproved_msg") UNAPPROVED_MSG = getmsg if getmsg is not None else DEF_UNAPPROVED_MSG async for message in apprvpm.client.iter_messages(apprvpm.chat_id, from_user="******", search=UNAPPROVED_MSG): await message.delete() try: approve(uid) except IntegrityError: return await apprvpm.edit("**O usuário talvez já esteja aprovado.**") await apprvpm.edit( f"[{name0}](tg://user?id={uid}) **permitido mandar mensagens privadas!**" ) if BOTLOG: await apprvpm.client.send_message( BOTLOG_CHATID, "#APPROVED\n" + "Usuário: " + f"[{name0}](tg://user?id={uid})", )
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 mention_afk(mention): """ This function takes care of notifying the people who mention you that you are AFK.""" global COUNT_MSG global USERS global ISAFK global AFFKREASON ISAFK_SQL = False AFKREASON_SQL = None if afk_db: ISAFK_SQL = gvarstatus("AFK_STATUS") AFKREASON_SQL = gvarstatus("AFK_REASON") EXCUSE = AFKREASON_SQL if afk_db else AFKREASON if mention.message.mentioned and not (await mention.get_sender()).bot: if ISAFK or ISAFK_SQL: if mention.sender_id not in USERS: if EXCUSE: await mention.reply(f"`Javes: `{DEFAULTUSER} offline right now.\ \nReason: `{EXCUSE}`") else: await mention.reply(str(choice(AFKSTR))) USERS.update({mention.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 elif mention.sender_id in USERS: if USERS[mention.sender_id] % randint(2, 4) == 0: if EXCUSE: await mention.reply( f"`Javes: ` In case you didn't notice, {DEFAULTUSER} still offline.\ \nReason: `{EXCUSE}`") else: await mention.reply(str(choice(AFKSTR))) USERS[mention.sender_id] = USERS[mention.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: USERS[mention.sender_id] = USERS[mention.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.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 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"`Javes:`{DEFAULTUSER} offline 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"`Javes:: ` In case you didn't notice, {DEFAULTUSER} still offline.\ \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 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 type_afk_is_not_true(notafk): """ This sets your status as not afk automatically when you write something while being afk """ global COUNT_MSG global USERS global ISAFK global AFFKREASON AFKREASON_SQL = None ISAFK_SQL = False if afk_db: ISAFK_SQL = gvarstatus("AFK_STATUS") AFKREASON_SQL = gvarstatus("AFK_REASON") if ISAFK or ISAFK_SQL: if afk_db: delgvar("AFK_STATUS") delgvar("AFK_REASON") ISAFK = False AFKREASON = None if BOTLOG: await notafk.client.send_message( BOTLOG_CHATID, "You've recieved " + str(COUNT_MSG) + " messages from " + str(len(USERS)) + " chats while you were away", ) for i in USERS: name = await notafk.client.get_entity(i) name0 = str(name.first_name) await notafk.client.send_message( BOTLOG_CHATID, "[" + name0 + "](tg://user?id=" + str(i) + ")" + " sent you " + "`" + str(USERS[i]) + " messages`", ) COUNT_MSG = 0 USERS = {}
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): 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 add_pmsg(cust_msg): """Set your own Unapproved message""" if not PM_AUTO_BAN: return await cust_msg.edit( "**Anda Harus Menyetel Var** `PM_AUTO_BAN` **Ke** `True`\n\n**Bila ingin Mengaktifkan PMPERMIT Silahkan Ketik:** `.set var PM_AUTO_BAN True`" ) try: import userbot.modules.sql_helper.globals as sql except AttributeError: await cust_msg.edit("**Running on Non-SQL mode!**") return await cust_msg.edit("`Processing...`") conf = cust_msg.pattern_match.group(1) custom_message = sql.gvarstatus("unapproved_msg") if conf.lower() == "set": message = await cust_msg.get_reply_message() status = "Pesan" # check and clear user unapproved message first if custom_message is not None: sql.delgvar("unapproved_msg") status = "Pesan" if not message: return await cust_msg.edit("**Mohon Reply Ke Pesan**") # TODO: allow user to have a custom text formatting # eg: bold, underline, striketrough, link # for now all text are in monoscape msg = message.message # get the plain text sql.addgvar("unapproved_msg", msg) await cust_msg.edit("**Pesan Berhasil Disimpan Ke Room Chat**") if BOTLOG_CHATID: await cust_msg.client.send_message( BOTLOG_CHATID, f"**{status} PMPERMIT Yang Tersimpan:** \n\n{msg}", ) if conf.lower() == "reset": if custom_message is None: await cust_msg.edit( "`Anda Telah Menghapus Pesan Custom PMPERMIT menjadi Default`" ) else: sql.delgvar("unapproved_msg") await cust_msg.edit("`Pesan PMPERMIT Anda Sudah Default Sejak Awal`") if conf.lower() == "get": if custom_message is not None: await cust_msg.edit( "**Pesan PMPERMIT Yang Sekarang:**" f"\n\n{custom_message}" ) else: await cust_msg.edit( "**Anda Belum Menyetel Pesan Costum PMPERMIT,**\n" f"**Masih Menggunakan Pesan PM Default:**\n\n{DEF_UNAPPROVED_MSG}" )
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 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() 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`" elif minutes > 0: afk_since = f"`{int(minutes)}m {int(seconds)}s`" else: afk_since = f"`{int(seconds)}s`" 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): 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): """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 update_restart_msg(chat_id, msg_id): DEFAULTUSER = ALIVE_NAME or "Set `ALIVE_NAME` ConfigVar!" message = ( f"**WeebProject is back up and running!**\n\n" f"**Telethon :** __{version.__version__}__\n" f"**Python :** __{python_version()}__\n" f"**User :** __{DEFAULTUSER}__" ) await bot.edit_message(chat_id, msg_id, message) return True try: from userbot.modules.sql_helper.globals import delgvar, gvarstatus chat_id, msg_id = gvarstatus("restartstatus").split("\n") try: with bot: bot.loop.run_until_complete( update_restart_msg( int(chat_id), int(msg_id))) except BaseException: pass delgvar("restartstatus") except AttributeError: pass # Global Variables COUNT_MSG = 0 USERS = {} COUNT_PM = {}
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] > 5: await event.respond("`Maaf Kamu Saya Block`\n" "`Karena Telah Melakukan Spam`\n" "`Silahkan Tunggu Owner Saya Membukanya!!`" ) 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 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", )