Created
May 10, 2019 08:56
-
-
Save freakeinstein/b4b8b8bf7c0962dda058821ab8c4830c to your computer and use it in GitHub Desktop.
hangout simple request response
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
#!/usr/bin/env python3 | |
"""Example bot that returns a synchronous response.""" | |
from flask import Flask, request, json | |
app = Flask(__name__) | |
@app.route('/', methods=['POST']) | |
def on_event(): | |
"""Handles an event from Hangouts Chat.""" | |
event = request.get_json() | |
if event['type'] == 'ADDED_TO_SPACE' and event['space']['type'] == 'ROOM': | |
text = 'Thanks for adding me to "%s"!' % event['space']['displayName'] | |
elif event['type'] == 'MESSAGE': | |
text = 'You said: `%s`' % event['message']['text'] | |
else: | |
return | |
return 'OK' #json.jsonify({'text': text}) | |
if __name__ == '__main__': | |
app.run(port=4000, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment