Skip to content

Instantly share code, notes, and snippets.

@amix
Last active June 24, 2017 10:55
Show Gist options
  • Save amix/b5428febcaff80c84f616453196fe7dc to your computer and use it in GitHub Desktop.
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.
# -*- 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