From 488eb7f2754a9ea35c9057a81828c87f666f7bc1 Mon Sep 17 00:00:00 2001 From: Robbe Van Herck Date: Wed, 3 Oct 2018 16:21:02 +0200 Subject: [PATCH] Added /cammiechat --- app/app.py | 11 ++++++++++- config.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index f683b2a..e378aa6 100644 --- a/app/app.py +++ b/app/app.py @@ -5,7 +5,6 @@ from flask_sqlalchemy import SQLAlchemy import requests import config - app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = config.DATABASE_URL @@ -128,3 +127,13 @@ def door(username): tokens = request.values.get('text').strip().split() command = tokens[0].lower() return mattermost_response(slotmachien_request(username, command), ephemeral=True) + +@app.route('/cammiechat', methods=['POST']) +@requires_token('cammiechat') +@requires_regular +def cammiechat(username): + headers = { + "X-Username": username + } + requests.post("https://kelder.zeus.ugent.be/messages/", data=request.values.get('text').strip(), headers=headers) + return mattermost_response("Message sent", ephemeral=True) diff --git a/config.py b/config.py index 1ad584a..b4587da 100644 --- a/config.py +++ b/config.py @@ -2,7 +2,8 @@ DATABASE_URL = 'sqlite:////tmp/mattermost.db' tokens = { 'authorize': '123', 'door': '123', - 'revoke': '123' + 'revoke': '123', + 'cammiechat': '123' } slotmachien_url = 'https://kelder.zeus.ugent.be/slotmachien/slack/' slotmachien_token = '123'