Update web_app.py
This commit is contained in:
parent
f9fa76bbe5
commit
07a64b100d
13
web_app.py
13
web_app.py
|
@ -1,7 +1,9 @@
|
||||||
|
import redis
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
from irc_bot import bot
|
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__)
|
appV3 = Flask(__name__)
|
||||||
|
|
||||||
# Handle incoming chatbox messages
|
# Handle incoming chatbox messages
|
||||||
|
@ -17,5 +19,12 @@ def incoming():
|
||||||
if not user or not text:
|
if not user or not text:
|
||||||
return jsonify({"error": "Invalid data"}), 400
|
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
|
return jsonify({"success": True}), 200
|
||||||
|
|
Loading…
Reference in New Issue