1
0
Fork 0

Add web_app.py

This commit is contained in:
Eric Lay 2025-05-04 20:03:41 -05:00
parent 0ae01fdfc3
commit 3e1c7fd0b0
1 changed files with 21 additions and 0 deletions

21
web_app.py Normal file
View File

@ -0,0 +1,21 @@
from flask import Flask, request, jsonify
from irc_bot import bot
from config import API_TOKEN
appV3 = Flask(__name__)
# Handle incoming chatbox messages
@appV3.route("/incoming", methods=["POST"])
def incoming():
auth_header = request.headers.get("Authorization", "")
if auth_header != f"Bearer {API_TOKEN}":
return jsonify({"error": "Unauthorized"}), 401
data = request.get_json()
user = data.get("username")
text = data.get("text")
if not user or not text:
return jsonify({"error": "Invalid data"}), 400
bot.send_to_channel(f"[CHATBOX] {user}: {text}")
return jsonify({"success": True}), 200