-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho.py
More file actions
25 lines (21 loc) · 723 Bytes
/
echo.py
File metadata and controls
25 lines (21 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
import requests
from flask import Flask, request, jsonify
from os import environ
from sys import exit
app = Flask(__name__)
endpoint = environ.get('SLACK_WEBHOOK')
@app.route("/", methods=['POST'])
def webhook():
headers = { 'Content-type': 'application/json' }
payload = {
'text': request.form['text'],
'username': '%s (echobot)' % request.form['user_name'],
'icon_emoji': 'splurge', # invalid, basically 'use default slack icon'
}
requests.post(endpoint, data=json.dumps(payload), headers=headers)
return jsonify({"status": "OK"})
if __name__ == "__main__":
if endpoint is None:
exit('Must set SLACK_WEBHOOK')
app.run(host='0.0.0.0', port=3246)