async def on_view_blacklist(event): if event.fwd_from: return sensibleleecher = await edit_or_reply(event, "Listing Blacklist xD") all_blacklisted = sql.get_chat_blacklist(event.chat_id) OUT_STR = "Blacklists in the Current Chat:\n" if len(all_blacklisted) > 0: for trigger in all_blacklisted: OUT_STR += f"👉 {trigger} \n" else: OUT_STR = "No BlackLists. Start Saving using `.addblacklist`" if len(OUT_STR) > Config.MAX_MESSAGE_SIZE_LIMIT: with io.BytesIO(str.encode(OUT_STR)) as out_file: out_file.name = "blacklist.text" await borg.send_file( event.chat_id, out_file, force_document=True, allow_cache=False, caption="BlackLists in the Current Chat", reply_to=event, ) await event.delete() else: await sensibleleecher.edit(OUT_STR)
async def on_new_message(event): # TODO: exempt admins from locks name = event.raw_text snips = sql.get_chat_blacklist(event.chat_id) for snip in snips: pattern = r"( |^|[^\w])" + re.escape(snip) + r"( |$|[^\w])" if re.search(pattern, name, flags=re.IGNORECASE): try: await event.delete() except Exception: await event.reply( "I do not have DELETE permission in this chat") sql.rm_from_blacklist(event.chat_id, snip.lower()) break