1
0
Fork 0

Update web_app.py

This commit is contained in:
Eric Lay 2025-05-18 16:53:23 -05:00
parent f9fa76bbe5
commit 07a64b100d
1 changed files with 11 additions and 2 deletions

View File

@ -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