Added /cammiechat

This commit is contained in:
Robbe Van Herck 2018-10-03 16:21:02 +02:00
parent e8c86b5a5e
commit 488eb7f275
No known key found for this signature in database
GPG key ID: 4D1C8E8FBD1C7188
2 changed files with 12 additions and 2 deletions

View file

@ -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)

View file

@ -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'