|
@@ -5,16 +5,13 @@ from linebot import LineBotApi, WebhookHandler
|
|
|
from linebot.models import (
|
|
|
MessageEvent, TextMessage, TextSendMessage, FollowEvent,
|
|
|
)
|
|
|
-import configparser
|
|
|
|
|
|
app = fastapi.FastAPI()
|
|
|
|
|
|
# bot config
|
|
|
-config = configparser.ConfigParser()
|
|
|
-config.read('config.ini')
|
|
|
+line_bot_api = LineBotApi("SJT7VPT4RMQFLcS27jQBy3FcC24gtDrkcwJWZ5Xzqesr5T78LOKudHEJzt0k3b2S7n4KPwf27J7DVz2c8NQ4plSaaQylEeB1cYrfejaE/RPG/lCIQBYe4iBTzo26s4i2PcmT89837per/lTyvhVIKAdB04t89/1O/w1cDnyilFU=")
|
|
|
+handler = WebhookHandler("411ae3ef7e766739ed2c2c27b249d010")
|
|
|
|
|
|
-line_bot_api = LineBotApi(config.get('line-bot', 'channel_access_token'))
|
|
|
-handler = WebhookHandler(config.get('line-bot', 'channel_secret'))
|
|
|
|
|
|
# callback event
|
|
|
@app.post("/callback")
|
|
@@ -32,19 +29,6 @@ def handle_follow(event):
|
|
|
event.reply_token,
|
|
|
TextSendMessage(text='歡迎加入好友'))
|
|
|
|
|
|
-# # test answer, echo handler
|
|
|
-# @handler.add(MessageEvent, message=TextMessage)
|
|
|
-# def echo(event):
|
|
|
-# if '誰' in event.message.text:
|
|
|
-# line_bot_api.reply_message(
|
|
|
-# event.reply_token,
|
|
|
-# TextSendMessage(text='我是您的專屬祕書'))
|
|
|
-
|
|
|
-# else:
|
|
|
-# line_bot_api.reply_message(
|
|
|
-# event.reply_token,
|
|
|
-# TextSendMessage(text=event.message.text)
|
|
|
-# )
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
uvicorn.run("main:app", host="127.0.0.1", port=5000, reload=True)
|