From fa629f27e529cc8931063d25ee9c3dc1b059c86c Mon Sep 17 00:00:00 2001 From: ted Date: Thu, 26 Sep 2024 10:03:42 +0000 Subject: [PATCH] update --- classes/post.py | 15 ++-- classes/rating.py | 16 ++-- data/filter.txt | 22 +++++- data/labels.json | 161 +++++++++++++++++++++++----------------- functions/scan_posts.py | 2 +- var.py | 2 +- 6 files changed, 130 insertions(+), 88 deletions(-) diff --git a/classes/post.py b/classes/post.py index 64803c9..86acca5 100755 --- a/classes/post.py +++ b/classes/post.py @@ -52,6 +52,10 @@ class Post: async def analyse_text(self): logger.info(f"Getting text analysis of post with post ID {self.post_id}") + logger.info(self.post_name) + logger.info(self.post_description) + logger.info(var.filters_list) + if self.post_name: for word in var.filters_list: if word.lower() in self.post_name.lower() and word not in self.infringing_words: @@ -103,9 +107,9 @@ class Post: f"but it was not enabled. Post will not be deleted.") one_rating_was_false = True - if one_rating_was_false: - self.post_will_be_deleted = False - self.ratings = None + # if one_rating_was_false: + # self.post_will_be_deleted = False + # self.ratings = None async def remove_post(self): var.most_recently_deleted_post_id = self.post_id @@ -134,11 +138,10 @@ class Post: return ratings_string async def get_as_text_detection_text(self): - string = (f'‼️ *DETECTED:* "{await self.get_censorship_string()}"\n' + + string = (f'‼️ *DETECTED:TEXT:* "{await self.get_censorship_string()}"\n' + f'🗒️ *TITLE:* "{self.post_name}"\n' + f"🔗 *URL:* https://{var.site}/admin/posts/{self.post_id}\n" + - f"👤 *POSTER:* https://{var.site}/users/{self.user_id} / @{self.poster_username}\n" - f"The user was also suspended for a day, you will have to reverse this suspension if the moderation action was not warranted..") + f"👤 *POSTER:* https://{var.site}/users/{self.user_id} / @{self.poster_username}\n") return string async def get_as_image_deletion_text(self): diff --git a/classes/rating.py b/classes/rating.py index 4f11652..3c034bc 100755 --- a/classes/rating.py +++ b/classes/rating.py @@ -1,5 +1,6 @@ import var import json +from beloved_logger import logger class Rating: @@ -22,8 +23,6 @@ class Rating: top_level_true = [] top_level_false = [] - lower_level_true = [] - lower_level_false = [] for top_level_object, top_level_data in data.items(): if top_level_data.get("status") is True: @@ -31,21 +30,16 @@ class Rating: elif top_level_data.get("status") is False: top_level_false.append(top_level_object) - for lower_level_object, lower_level_status in top_level_data.items(): - if lower_level_status is True and lower_level_object != "status": - lower_level_true.append(f"{lower_level_object}") - elif lower_level_status is False and lower_level_object != "status": - lower_level_false.append(f"{lower_level_object}") - - if self.name in lower_level_true: - self.type = "secondary" - return True if self.name in top_level_true: self.type = "primary" return True + if self.name in top_level_false: + self.type = "primary" + return False return False + def create_ratings(response): ratings = [] for label in response['ModerationLabels']: diff --git a/data/filter.txt b/data/filter.txt index 095afd2..1c5d5fe 100644 --- a/data/filter.txt +++ b/data/filter.txt @@ -1 +1,21 @@ -boto3~=1.28.39\nselenium~=4.12.0\npy-cord\nrequests~=2.31.0\npython-dotenv + +brenton +tarrant + +breivik + +1488 + +niggers +nigger +nigga +faggot +fag +kike +ngger +niggr + + + +yahir +wintendo diff --git a/data/labels.json b/data/labels.json index 058e623..91bf6f5 100644 --- a/data/labels.json +++ b/data/labels.json @@ -1,69 +1,94 @@ { - "Explicit Nudity": { - "status": true, - "Nudity": true, - "Graphic Male Nudity": true, - "Graphic Female Nudity": true, - "Sexual Activity": true, - "Illustrated Explicit Nudity": true, - "Adult Toys": true - }, - "Suggestive": { - "status": true, - "Female Swimwear Or Underwear": false, - "Male Swimwear Or Underwear": false, - "Partial Nudity": false, - "Barechested Male": false, - "Revealing Clothes": false, - "Sexual Situations": true - }, - "Violence": { - "status": true, - "Graphic Violence Or Gore": true, - "Physical Violence": true, - "Weapon Violence": true, - "Weapons": false, - "Self Injury": true - }, - "Visually Disturbing": - { - "status": true, - "Emaciated Bodies": true, - "Corpses": true, - "Hanging": true, - "Air Crash": false, - "Explosions And Blasts": false - }, - "Rude Gestures": - { - "status": false, - "Middle Finger": false - }, - "Drugs": { - "status": false, - "Drug Products": false, - "Drug Use": false, - "Pills": false, - "Drug Paraphernalia": false - }, - "Tobacco": { - "status": false, - "Tobacco Products": false, - "Smoking": false - }, - "Alcohol": { - "status": false, - "Drinking": false, - "Alcoholic Beverages": false - }, - "Gambling": { - "status": false, - "Gambling": false - }, - "Hate Symbols": { - "status": true, - "Nazi Party": true, - "White Supremacy": true, - "Extremist": true - } -} \ No newline at end of file + "Explicit": { + "status": true, + "Explicit Nudity": { + "status": true, + "Exposed Male Genitalia": true, + "Exposed Female Genitalia": true, + "Exposed Buttocks or Anus": true, + "Exposed Female Nipple": true + }, + "Explicit Sexual Activity": true, + "Sex Toys": true + }, + "Non-Explicit Nudity of Intimate parts and Kissing": { + "status": false, + "Non-Explicit Nudity": { + "status": true, + "Bare Back": true, + "Exposed Male Nipple": true, + "Partially Exposed Buttocks": true, + "Partially Exposed Female Breast": true, + "Implied Nudity": true + }, + "Obstructed Intimate Parts": { + "status": true, + "Obstructed Female Nipple": true, + "Obstructed Male Genitalia": true + }, + "Kissing on the Lips": true + }, + "Swimwear or Underwear": { + "status": false, + "Female Swimwear or Underwear": true, + "Male Swimwear or Underwear": true + }, + "Violence": { + "status": true, + "Weapons": true, + "Graphic Violence": { + "status": true, + "Weapon Violence": true, + "Physical Violence": true + }, + "Self-Harm": true, + "Blood & Gore": true, + "Explosions and Blasts": true + }, + "Visually Disturbing": { + "status": false, + "Death and Emaciation": { + "status": true, + "Emaciated Bodies": true, + "Corpses": true + }, + "Crashes": { + "status": true, + "Air Crash": true + } + }, + "Drugs & Tobacco": { + "status": false, + "Products": { + "status": true, + "Pills": true + }, + "Drugs & Tobacco Paraphernalia & Use": { + "status": true, + "Smoking": true + }, + "Alcohol": { + "status": true, + "Alcohol Use": { + "status": true, + "Drinking": true + }, + "Alcoholic Beverages": true + } + }, + "Rude Gestures": { + "status": false, + "Middle Finger": true + }, + "Gambling": { + "status": false + }, + "Hate Symbols": { + "status": true, + "Nazi Party": true, + "White Supremacy": true + }, + "Extremist": { + "status": true + } +} diff --git a/functions/scan_posts.py b/functions/scan_posts.py index c1cfd4b..f117410 100755 --- a/functions/scan_posts.py +++ b/functions/scan_posts.py @@ -33,7 +33,7 @@ async def scan_posts(): if var.image_scanning_is_running: if var.scan_new_users_only: - cut_off_date = datetime.now() - timedelta(weeks=2) + 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") logger.debug(f"User signed up at {current_date}, we are checking for " diff --git a/var.py b/var.py index f2a6f37..207dc92 100755 --- a/var.py +++ b/var.py @@ -21,7 +21,7 @@ aws_region = os.getenv("AWS_REGION") old_chat = {} scan_new_users_only = True image_scanning_is_running = True -text_scanning_is_running = False +text_scanning_is_running = True most_recently_deleted_post_id = 0 current_posts_at_start_time = None bot_started_at = None