2022-04-19 13:27:39 +03:00
|
|
|
#!/usr/bin/env python
|
2022-11-29 19:53:11 +02:00
|
|
|
# import argparse
|
|
|
|
from flask import Flask, Response, request
|
|
|
|
from core import config, fedi, owncast, __version__, root_logger
|
2022-04-27 11:24:45 +03:00
|
|
|
from core.logger import logging
|
2022-04-19 13:27:39 +03:00
|
|
|
|
2022-11-29 19:53:11 +02: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
|
|
|
|
2022-11-29 19:53:11 +02:00
|
|
|
# args = parser.parse_args()
|
2022-05-03 21:37:31 +03:00
|
|
|
app = Flask(__name__)
|
|
|
|
|
2022-11-29 19:53:11 +02:00
|
|
|
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(
|
2022-11-29 19:53:11 +02:00
|
|
|
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)
|
2022-11-29 19:53:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@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
|