From 2232bc4267ca2db67e3964b55dbf697d749627ce Mon Sep 17 00:00:00 2001 From: ted Date: Thu, 11 Sep 2025 12:04:59 +0000 Subject: [PATCH] actually make the spam filter work im sozzles teddles --- functions/scan_posts.py | 29 +++++++++++++++++++---------- pip-selfcheck.json | 1 + requirements.txt | 10 +++++----- 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 pip-selfcheck.json diff --git a/functions/scan_posts.py b/functions/scan_posts.py index bdd8b5e..37ceda3 100755 --- a/functions/scan_posts.py +++ b/functions/scan_posts.py @@ -68,17 +68,26 @@ async def scan_posts(): await send_message(message_string, post_to_analyse.poster_username) if var.spam_scanning_is_running and post_to_analyse.poster_sign_up_time: - cut_off_date = datetime.now() - timedelta(days=3) - current_date = datetime.strptime(post_to_analyse.poster_sign_up_time, - "%Y-%m-%d %H:%M:%S") - if current_date > cut_off_date: + cut_off_date = datetime.now() - timedelta(days=1) + current_date = datetime.strptime(post_to_analyse.poster_sign_up_time, "%Y-%m-%d %H:%M:%S") + + if (current_date > cut_off_date): akismet_client = await akismet.AsyncClient.validated_client() - if await akismet_client.comment_check( - comment_content=post_to_analyse.post_description, - comment_type="comment", - comment_author=post_to_analyse.poster_username, - user_ip="0.0.0.0" - ): + comment_is_spam = await akismet_client.comment_check( + comment_content=str(post_to_analyse.post_name) + str(post_to_analyse.post_description), + comment_type="comment", + comment_author=post_to_analyse.poster_username, + user_ip="103.72.61.14" + ) + + if("https:" in post_to_analyse.post_name or "https:" in post_to_analyse.post_description): + if("sketchersunited.org" in post_to_analyse.post_name or "sketchersunited.org" in post_to_analyse.post_description): + pass + else: + # if a user posts to a link whilst being signed up only one day, always remove it as spam + comment_is_spam = True + + if comment_is_spam: message_string = f"""👋 Hello, I am an automatic moderation bot for Sketchers United. Your most recent post titled '{post_to_analyse.post_name}' was removed automatically as it was detected to have spam content. diff --git a/pip-selfcheck.json b/pip-selfcheck.json new file mode 100644 index 0000000..f099f9b --- /dev/null +++ b/pip-selfcheck.json @@ -0,0 +1 @@ +{"last_check":"2025-08-20T13:41:33Z","pypi_version":"25.2"} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 485aad2..f6f2529 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -boto3~=1.28.39 +boto3 requests -python-dotenv~=1.0.0 -websockets~=11.0.3 -beautifulsoup4~=4.12.2 +python-dotenv +websockets +beautifulsoup4 aiohttp -akismet \ No newline at end of file +akismet