config bans, cascade deletion, add albemic, add enable_stan and get_quotes

This commit is contained in:
Rykov7
2023-04-06 01:11:01 +03:00
parent bcce3aa629
commit 99148b5bb6
5 changed files with 45 additions and 16 deletions
+6 -2
View File
@@ -1,9 +1,12 @@
from .database import session
from .models import Chat
from .config import *
def in_spam_list(message: types.Message) -> bool:
"""Check for mentioning unwanted persons in text."""
if message.from_user.id not in WHITEIDS:
antispam_is_enabled = session.query(Chat.antispam).filter_by(chat_id=message.chat.id).first()[0]
if message.from_user.id not in WHITEIDS and antispam_is_enabled:
for url in SPAM:
if url in message.text.casefold():
return True
@@ -25,7 +28,8 @@ def in_not_allowed(word_list, msg):
def in_delete_list(message: types.Message) -> bool:
"""Check for URLs in message and delete."""
if message.from_user.id not in WHITEIDS:
antispam_is_enabled = session.query(Chat.antispam).filter_by(chat_id=message.chat.id).first()[0]
if message.from_user.id not in WHITEIDS and antispam_is_enabled:
if URL_RX.search(message.text) and in_not_allowed(
ALLOWED_WORDS, message.text
):