respond to user in chat
This commit is contained in:
parent
67fc364b8e
commit
fd28a7904a
|
@ -35,6 +35,12 @@ def addUserToDatabase(user_id, db):
|
||||||
print("Error occured adding user to db:", e.args[0])
|
print("Error occured adding user to db:", e.args[0])
|
||||||
print("To user:", user_id)
|
print("To user:", user_id)
|
||||||
|
|
||||||
|
def sendChat(message): # TODO: url to constant?
|
||||||
|
url = 'http://localhost:8080/api/integrations/chat/send'
|
||||||
|
headers = {"Authorization": "Bearer " + OWNCAST_ACCESS_TOKEN}
|
||||||
|
r = requests.post(url, headers=headers, json={"body": message})
|
||||||
|
return r.json()
|
||||||
|
|
||||||
@bp.route('/owncastWebhook',methods=['POST'])
|
@bp.route('/owncastWebhook',methods=['POST'])
|
||||||
def owncastWebhook():
|
def owncastWebhook():
|
||||||
data = request.json
|
data = request.json
|
||||||
|
@ -60,7 +66,10 @@ def owncastWebhook():
|
||||||
"SELECT points FROM points WHERE id = ?",
|
"SELECT points FROM points WHERE id = ?",
|
||||||
(user_id,)
|
(user_id,)
|
||||||
)
|
)
|
||||||
print("{}'s points: {}".format(display_name, cursor.fetchone()[0]))
|
message = "{}'s points: {}".format(display_name, cursor.fetchone()[0])
|
||||||
|
print(message)
|
||||||
|
sendChat(message)
|
||||||
|
|
||||||
except Error as e:
|
except Error as e:
|
||||||
print("Error occured reading points:", e.args[0])
|
print("Error occured reading points:", e.args[0])
|
||||||
print("To user:", user_id)
|
print("To user:", user_id)
|
||||||
|
@ -76,7 +85,4 @@ def owncastWebhook():
|
||||||
print("Error occured giving DEBUG points:", e.args[0])
|
print("Error occured giving DEBUG points:", e.args[0])
|
||||||
print("To user:", user_id)
|
print("To user:", user_id)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(debug=True)
|
|
Loading…
Reference in New Issue