Last active
June 24, 2017 10:55
-
-
Save amix/b5428febcaff80c84f616453196fe7dc to your computer and use it in GitHub Desktop.
How to implement the `/appear room-name` slash command on Twist using Flask.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Start video conversations from Twist by just typing `/appear room-name` | |
""" | |
from flask import Flask | |
from flask import jsonify | |
from flask import request | |
app = Flask(__name__) | |
@app.route('/applet_appear/incoming', methods=['POST']) | |
def incoming(): | |
event_type = request.form['event_type'] | |
if event_type == 'ping': | |
return jsonify({'content': 'pong'}) | |
else: | |
content = request.form['content'] | |
command = request.form['command'] | |
command_argument = request.form['command_argument'] | |
appear_url = 'https://appear.in/%s' % command_argument | |
content = content.replace(u'%s %s' % (command, command_argument), | |
u'📹 [%s](%s)' % (command_argument, appear_url)) | |
return jsonify({ | |
'content': content, | |
}) | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment