|
@@ -1,5 +1,11 @@
|
|
|
-from flask import Flask, request, abort
|
|
|
import copy
|
|
|
+import fastapi
|
|
|
+import fastapi.staticfiles as fastapiStaticfiles
|
|
|
+app = fastapi.FastAPI()
|
|
|
+app.mount(
|
|
|
+ '/static', fastapiStaticfiles.StaticFiles(directory='static'), name='static')
|
|
|
+
|
|
|
+
|
|
|
from linebot import (
|
|
|
LineBotApi, WebhookHandler
|
|
|
)
|
|
@@ -69,7 +75,6 @@ objelmt7['header']['backgroundColor']='#37C2D8'
|
|
|
jsobj={"type": "carousel", "contents": [objelmt,objelmt2,objelmt3,objelmt4,objelmt5,objelmt6,objelmt7]}
|
|
|
|
|
|
|
|
|
-app = Flask(__name__)
|
|
|
|
|
|
line_bot_api = LineBotApi('FvP2AkKj3FSuTjY8Jhwn23DPIb38yDZBliLrDjRA8j+UOQPku+kH2Bz2coDFl4gruRAiLuHuBbtRpILXlN54zJ+bWF5IwU86FClG47VZxCcDcAkhwqCqjYi/Ju7dBzlg963d9CV1KiiBwoiqvV6J7AdB04t89/1O/w1cDnyilFU=')
|
|
|
handler = WebhookHandler('58a73d69c3ad6416e0b465e64c30526a')
|
|
@@ -77,7 +82,25 @@ handler = WebhookHandler('58a73d69c3ad6416e0b465e64c30526a')
|
|
|
#handler = WebhookHandler('YOUR_CHANNEL_SECRET')
|
|
|
|
|
|
|
|
|
-@app.route("/callback", methods=['POST','GET'])
|
|
|
+@app.post('/callback')
|
|
|
+async def callback(request: fastapi.Request):
|
|
|
+ signature = request.headers['X-Line-Signature']
|
|
|
+ body = await request.body()
|
|
|
+ bot.handle(body.decode('utf-8'), signature)
|
|
|
+ return 'OK'
|
|
|
+
|
|
|
+
|
|
|
+@bot.add(linebotModels.MessageEvent, message=linebotModels.TextMessage)
|
|
|
+def message_text(event):
|
|
|
+ if event.message.text == '叫':
|
|
|
+ lineBotApi.reply_message(
|
|
|
+ event.reply_token, linebotModels.AudioSendMessage(
|
|
|
+ original_content_url=f'{baseUrl}/static/audio/noot_noot.mp3', duration=1000))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#@app.route("/callback", methods=['POST','GET'])
|
|
|
def callback():
|
|
|
# get X-Line-Signature header value
|
|
|
signature = request.headers['X-Line-Signature']
|