diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2015-11-07 16:08:12 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2015-11-07 16:11:36 -0500 |
| commit | f039016ad17cc13a68e7ee96c50168967acabeba (patch) | |
| tree | fd37b8e35b69af69c3179515e9a1fa389a16a0e5 /slack.py | |
| parent | 365e75693b6bcf0b8f02e4982943bc5ed3030dd9 (diff) | |
| download | slack-f039016ad17cc13a68e7ee96c50168967acabeba.tar.gz | |
add the xkcd bot
Diffstat (limited to 'slack.py')
| -rw-r--r-- | slack.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1,4 +1,5 @@ from flask import Flask, jsonify, request +from xkcd import get_xkcd app = Flask(__name__) app.config.from_envvar('CONF') @@ -12,5 +13,16 @@ def echo(): } return jsonify(d) +@app.route("/xkcd", methods=['POST']) +def xkcd_view(): + title, url = get_xkcd(request.form['text']) + d = {'response_type': 'in_channel', + 'text': title, + 'attachments': [ + {'image_url':"http:{0}:".format(url)} + ] + } + return jsonify(d) + if __name__=="__main__": app.run() |
