Okay *now* it posts to the proper url

This commit is contained in:
Siina Mashek 2022-04-19 14:06:44 +03:00
parent 34927807e7
commit 5e4c372d38
2 changed files with 6 additions and 2 deletions

View File

@ -40,6 +40,8 @@ headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json" headers["Content-Type"] = "application/json"
headers["Authorization"] = "Bearer {}".format(config["access_token"]) headers["Authorization"] = "Bearer {}".format(config["access_token"])
post_url = "%s/api/integrations/chat/send" % config["owncast_server"]
def parse_webhook(): def parse_webhook():
hook_type = request.json["type"] hook_type = request.json["type"]
@ -51,10 +53,11 @@ def parse_webhook():
if data: if data:
send_message(data) send_message(data)
def send_message(data): def send_message(data):
data = '{"body": "%s"}' % data data = '{"body": "%s"}' % data
resp = requests.post( resp = requests.post(
config["owncast_server"], post_url,
headers=headers, headers=headers,
data=data.encode('utf-8')) data=data.encode('utf-8'))

View File

@ -13,7 +13,8 @@ except ModuleNotFoundError:
class Quote: class Quote:
def __init__(self, database, user, password): def __init__(self, database, user, password):
self.conn = psycopg2.connect(database=database, user=user, password=password) self.conn = psycopg2.connect(
database=database, user=user, password=password)
self.num_quotes = self._get_num_quotes() self.num_quotes = self._get_num_quotes()
def insert(self, owner, submitter, text): def insert(self, owner, submitter, text):