From 07a64b100d85a97295acaddfc66fa0f4d83dea7e Mon Sep 17 00:00:00 2001 From: Eric Lay Date: Sun, 18 May 2025 16:53:23 -0500 Subject: [PATCH] Update web_app.py --- web_app.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/web_app.py b/web_app.py index 979e167..db7db2e 100644 --- a/web_app.py +++ b/web_app.py @@ -1,7 +1,9 @@ +import redis from flask import Flask, request, jsonify from irc_bot import bot -from config import API_TOKEN +from config import API_TOKEN, REDIS_PW +r = redis.Redis(host='localhost', port=6969, password=REDIS_PW, db=0) appV3 = Flask(__name__) # Handle incoming chatbox messages @@ -17,5 +19,12 @@ def incoming(): if not user or not text: return jsonify({"error": "Invalid data"}), 400 - bot.send_to_channel(f"[CHATBOX] {user}: {text}") + msg = f"[CHATBOX] {user}: {text}" + try: + r.publish("chatbox_to_irc", msg) + print(f"[REDIS] Published: {msg}") + except Exception as e: + print(f"[-] Redis publish failed: {e}") + return jsonify({"error": "Redis error"}), 500 + return jsonify({"success": True}), 200