ameliabot/bot.py

39 lines
1.1 KiB
Python
Raw Permalink Normal View History

2022-04-19 13:27:39 +03:00
#!/usr/bin/env python
# import argparse
from flask import Flask, Response, request
from core import config, fedi, owncast, __version__, root_logger
from core.logger import logging
2022-04-19 13:27:39 +03:00
# parser = argparse.ArgumentParser(description="Stream service selection")
# parser.add_argument("-s", "--service",
# default="all",
# help="connect to a service. Needs all, twitch, fedi, or owncast")
2022-04-19 13:27:39 +03:00
# args = parser.parse_args()
2022-05-03 21:37:31 +03:00
app = Flask(__name__)
logging.debug("Loaded %s, running ameliabot v%s" % (
config["DEFAULT"]["BotName"], __version__))
2022-04-19 13:27:39 +03:00
# the url of the Owncast API for bot posts
owncast_url = "{}/api/integrations/chat/send".format(
config["owncast"]["ServerURL"])
2022-04-19 13:27:39 +03:00
@app.route('/webhook/owncast', methods=['POST'])
def respond():
owncast.parse_webhook()
return Response(status=200)
@app.route('/webhook/fedi', methods=['POST'])
def fedipost():
args = request.args
repo = args.get("repo")
# Incredibly insecure lmao
if repo != None:
fedi.parse_webhook(args.get("repo"))
return Response(status=200)
return 400