aboutsummaryrefslogtreecommitdiffstats
path: root/community/wacca_plus/wacca_plus.py
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-03-22 23:53:34 -0700
committerPinapelz <yukais@pinapelz.com>2026-03-23 00:17:55 -0700
commit5e31d2870f07085e4c837a17572a3e9eedb6df26 (patch)
tree3b97c5f1b0c139deb0bc4091595f085d754b14bd /community/wacca_plus/wacca_plus.py
parent8f859e4786a02fea69ec086814d4f667f2f01d5d (diff)
Rename SDVX parser to parse_nabla_news_site
Replace parse_exceed_gear_news_site with parse_nabla_news_site and update imports and callers in __init__.py and news_feed.py
Diffstat (limited to 'community/wacca_plus/wacca_plus.py')
-rw-r--r--community/wacca_plus/wacca_plus.py125
1 files changed, 0 insertions, 125 deletions
diff --git a/community/wacca_plus/wacca_plus.py b/community/wacca_plus/wacca_plus.py
deleted file mode 100644
index c15bbf7..0000000
--- a/community/wacca_plus/wacca_plus.py
+++ /dev/null
@@ -1,125 +0,0 @@
-from datetime import datetime
-from dotenv import load_dotenv
-from common import create_database_connection
-from catboxpy.catbox import CatboxClient
-import os
-import time
-import openai
-import json
-
-from summarizer import generate_headline_and_content_from_images
-
-load_dotenv()
-
-def check_is_generation_possible():
- return os.getenv("OPENAI_API_KEY") is not None and os.getenv("DISCORD_AUTHORIZATION") is not None
-
-
-def check_is_announcement_image(img_url: str):
- openai.api_key = os.getenv("OPENAI_API_KEY")
-
- tools = [
- {
- "type": "function",
- "function": {
- "name": "classify_wacca_plus_image",
- "description": "Classify if an image is WACCA PLUS announcement, update, or information",
- "parameters": {
- "type": "object",
- "properties": {
- "is_wacca_plus_related": {
- "type": "boolean",
- "description": "Is this image related to WACCA PLUS?",
- },
- "category": {
- "type": "string",
- "enum": ["announcement", "update", "info", "null"],
- "description": "Category of image if related; otherwise null.",
- },
- },
- "required": ["is_wacca_plus_related", "category"],
- },
- }
- }
- ]
-
- response = openai.chat.completions.create(
- model="gpt-4o",
- messages=[
- {
- "role": "user",
- "content": [
- {"type": "text", "text": "Does this image contain official update, event, or announcement information for the game WACCA PLUS? Ignore unrelated content like gameplay screenshots, score posts, or arcade cabinet photos. Classify accordingly."},
- {"type": "image_url", "image_url": {"url": img_url}},
- ],
- }
- ],
- tools=tools,
- tool_choice={"type": "function", "function": {"name": "classify_wacca_plus_image"}},
- )
-
- tool_args = response.choices[0].message.tool_calls[0].function.arguments
- parsed_result = json.loads(tool_args)
- return parsed_result["is_wacca_plus_related"], parsed_result["category"]
-
-
-def _upload_image_to_catbox(image_url: str):
- client = CatboxClient()
- file_url = client.upload(image_url)
- if not file_url or file_url == "":
- return image_url
- return file_url
-
-def parse_announcement_messages(message_json: dict):
- news_posts = []
- database = create_database_connection()
- for message in message_json:
- type = None
- message_content = message.get("content", "")
- if len(message["attachments"]) == 0:
- continue
- image_attachments = []
- for attachment in message["attachments"]:
- if "image" in attachment["content_type"]:
- image_attachments.append(attachment)
-
- if len(image_attachments) == 0:
- continue
-
- filtered_images = []
- image_urls = [] # save the images before they get encoded
- for image in image_attachments:
- image_urls.append(image["url"])
- entry = database.get_wac_entry(image["id"])
- if entry:
- is_related = entry[0]
- type = entry[1]
- else:
- is_related, type = check_is_announcement_image(image["url"])
- database.add_new_wac_entry(key=image["id"], is_news=is_related, post_type=type)
-
- if not is_related:
- continue
- filtered_images.append({"image": _upload_image_to_catbox(image["url"]), "url": None})
-
- if len(filtered_images) == 0:
- continue
-
- date = message["timestamp"].split("T")[0]
- date_obj = datetime.strptime(date, "%Y-%m-%d")
- unix_time = int(time.mktime(date_obj.timetuple()))
- headline, content = generate_headline_and_content_from_images(image_urls, "WACCA PLUS", message_content)
-
- news_posts.append({
- "date": date,
- "identifier": "WACCA_PLUS",
- "type": type.upper(),
- "timestamp": unix_time,
- "content": content,
- "headline": headline,
- "url": None,
- "images": filtered_images,
- 'is_ai_summary': True
- })
- database.close()
- return news_posts
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage