-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.py
44 lines (27 loc) · 827 Bytes
/
example.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#-*- coding:utf-8 -*-
from flask import Flask, request
from kakaoplus import KaKaoAgent
app = Flask(__name__)
KaKao = KaKaoAgent()
@app.route('/', methods=['GET','POST'])
def app_start():
return "App launched Success"
@app.route('/keyboard', methods=['GET'])
def keyboard_handler():
return KaKao.handle_keyboard_webhook()
@app.route('/message', methods=['POST'])
def message_handler():
req = request.get_data(as_text=True)
return KaKao.handle_webhook(req)
@KaKao.handle_keyboard
def handle_keywboard(res):
res.text = True
@KaKao.handle_message
def handle_message(req, res):
echo_message = req.content
res.text = "Echo !!" + echo_message
@KaKao.handle_message(['hello', 'hi'])
def greeting_callback(req, res):
res.text = 'hello my friend'
if __name__ == "__main__":
app.run()