parent
d10af24384
commit
966d1edab4
|
@ -115,7 +115,11 @@ class Post:
|
|||
var.most_recently_deleted_post_id = self.post_id
|
||||
self.deletion_status = False
|
||||
if self.post_will_be_deleted:
|
||||
logger.info(f"Attempting to delete a post {self.post_id} for {await self.get_ratings_string()}")
|
||||
ratings_string = await self.get_ratings_string()
|
||||
if self.ratings:
|
||||
logger.info(f"Attempting to delete a post {self.post_id} for {ratings_string}")
|
||||
else:
|
||||
logger.info(f"Attempting to delete a post {self.post_id} for spam reasons...")
|
||||
|
||||
self.deletion_status = await delete_post(self.post_id)
|
||||
if self.deletion_status == 200:
|
||||
|
|
|
@ -16,12 +16,7 @@ forbidden_strings = [
|
|||
'yahir'
|
||||
]
|
||||
|
||||
forbidden_strings_username = [
|
||||
'ken',
|
||||
'rack',
|
||||
'sjb',
|
||||
'yahir'
|
||||
]
|
||||
forbidden_strings_username = []
|
||||
|
||||
async def check_users():
|
||||
user_details = await get_user_details(var.current_user_id+1)
|
||||
|
|
|
@ -12,7 +12,7 @@ async def get_user_details(user_id):
|
|||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, headers=headers) as response:
|
||||
if response.status != 200:
|
||||
print(f"Failed to fetch data: {response.status}")
|
||||
#print(f"Failed to fetch data for {url}: {response.status}")
|
||||
return None
|
||||
|
||||
data = await response.json()
|
||||
|
|
|
@ -2,9 +2,12 @@ import functions.get_newest_count
|
|||
import var
|
||||
from classes import post
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from functions.delete_post import delete_post
|
||||
from functions.send_message import send_message
|
||||
from functions.suspend_user import suspend_user_for_post
|
||||
from beloved_logger import logger
|
||||
import akismet
|
||||
|
||||
|
||||
async def scan_posts():
|
||||
|
@ -14,6 +17,7 @@ async def scan_posts():
|
|||
|
||||
current_posts_now = var.current_posts_at_start_time
|
||||
new_posts = await functions.get_newest_count.get_newest_count()
|
||||
post_deleted = False
|
||||
if new_posts != 0:
|
||||
current_posts_now = new_posts
|
||||
|
||||
|
@ -32,7 +36,7 @@ async def scan_posts():
|
|||
await send_message(await post_to_analyse.get_as_text_detection_text())
|
||||
|
||||
if var.image_scanning_is_running:
|
||||
if var.scan_new_users_only:
|
||||
if var.scan_new_users_only 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")
|
||||
|
||||
|
@ -42,7 +46,6 @@ async def scan_posts():
|
|||
if current_date < cut_off_date:
|
||||
logger.info(f"User was signed up before {cut_off_date}, so checks won't occur")
|
||||
var.most_recently_deleted_post_id = i
|
||||
return
|
||||
else:
|
||||
logger.info(f"User was signed up after {cut_off_date}, so checks will occur")
|
||||
|
||||
|
@ -64,4 +67,32 @@ async def scan_posts():
|
|||
await send_message(await post_to_analyse.get_as_image_deletion_text())
|
||||
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:
|
||||
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"
|
||||
):
|
||||
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.
|
||||
|
||||
*If this was a mistake don't worry, your post will be subject to human review and your post will be restored as soon possible if it is not spam.*
|
||||
|
||||
❓ If there any questions, problems, or concerns please contact @username
|
||||
"""
|
||||
|
||||
spam_string = f"""A post made by @{post_to_analyse.poster_username} was deleted for tripping the spam filter.
|
||||
"{post_to_analyse.post_name}" at https://{var.site}/admin/posts/{post_to_analyse.post_id}"""
|
||||
post_to_analyse.post_will_be_deleted = True
|
||||
await delete_post(post_to_analyse.post_id)
|
||||
await send_message(spam_string)
|
||||
await send_message(message_string, post_to_analyse.poster_username)
|
||||
|
||||
var.current_posts_at_start_time = current_posts_now
|
||||
|
|
|
@ -4,3 +4,4 @@ python-dotenv~=1.0.0
|
|||
websockets~=11.0.3
|
||||
beautifulsoup4~=4.12.2
|
||||
aiohttp
|
||||
akismet
|
Loading…
Reference in New Issue