-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
161 lines (139 loc) · 4.74 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from flask import Flask, request, abort
from linebot import (
LineBotApi, WebhookHandler
)
from linebot.exceptions import (
InvalidSignatureError
)
from linebot.models import (
MessageEvent, TextMessage, TextSendMessage,
)
app = Flask(__name__)
line_bot_api = LineBotApi('hotfFRJhCHRyF24HahrG7jd/7tMAqsk6mDDul+1nI/rH2g4u47I9+EsiWBZ7NPMOiPP2g3eJbisQHfdwBnVE9ql1gxc67x/zNQLPTmpk9kIsnkB9EmaCf5G2RnULZ1HUCb4bDpOCAcmQnZKwYZfMJgdB04t89/1O/w1cDnyilFU=')
handler = WebhookHandler('89aa56670f0099f0aded92a4d452b3a8')
@app.route("/", methods=['GET', 'POST'])
def callback():
# get X-Line-Signature header value
signature = request.headers['X-Line-Signature']
if request.method == "GET":
return "Hello Heroku"
if request.method == "POST":
signature = request.headers['X-Line-Signature']
body = request.get_data(as_text=True)
app.logger.info("Request body: " + body)
# handle webhook body
try:
handler.handle(body, signature)
except InvalidSignatureError:
print("Invalid signature. Please check your channel access token/channel secret.")
abort(400)
return 'OK'
i = []
@handler.add(MessageEvent, message=TextMessage)
def handle_message(event):
msg = event.message.text
#你好的不同回答
if ['?', '??', '?', '??'] == msg:
r = '痾..'
elif msg in ['你好嗎', '你好嗎?']:
r = '你好啊?哈哈'
elif msg in ['也好', '很好', '也很好']:
r = '那就好'
elif msg in ['不好', '不太好']:
r = '怎麼了嗎?我的朋友'
elif '你好嗎' in msg:
r = '我很好, 你?'
elif '無' in msg:
r = '是嗎?'
elif msg in ['還好', '很好', '也好', '都好', '嗯', '滿意', '很滿意', '我很好']:
r = '那就好我的朋友'
elif '厲害' in msg:
r = '謝謝'
elif '嘿' in msg:
r = '嗯?'
elif '幹' in msg:
r = '這樣不好喔'
elif '三小' in msg:
r = '甚麼拉哈哈'
elif '幾歲' in msg:
r = '我14歲啦哈哈'
elif '是不是' in msg:
r = '痾..不是'
elif '電動' in msg:
r = '話說我最喜歡的遊戲是薩爾達傳說曠野之息哈'
elif '怎' in msg:
r = '沒事沒事'
elif '在' in msg:
r = '這不能說'
elif '不知道' in msg:
r = '哈哈'
elif '歌' in msg:
r = '說到這個, 我最喜歡的歌手是Ed Sheeran喔'
elif '嗎' in msg:
r = '嗯嗯'
elif '為什麼' in msg:
r = '不告訴你'
elif '乾我' in msg:
r = '是喔好吧'
elif '屁' in msg:
r = '痾..'
elif msg in ['hi', 'Hi', 'hello', 'Hello', 'hi?', 'Hi?', 'hello?', 'Hello?', '嗨嗨', '嗨', '哈摟', '哈囉', '早安', '午安', '晚安', '你好'] :
r = 'Hello!你好啊?我的朋友'
elif '的' in msg:
r = '痾..'
elif '吃' in msg:
r = '我沒有特別喜歡的'
elif '會說' in msg:
r = '你再問問看'
elif '相信' in msg:
r = '我相信'
elif '遊戲' in msg:
r = '話說我最喜歡的遊戲是薩爾達傳說曠野之息哈 '
elif 'Ed Sheeran' in msg:
r = '他是我最喜歡的歌手呢哈哈'
elif '薩爾達' in msg:
r = '你也喜歡嗎?哈哈'
elif '喔' in msg:
r = '嗯嗯'
elif '喜歡做' in msg:
r = '我喜歡寫程式, 畫3D, 彈吉他和唱歌'
elif '什麼' in msg:
r = '不告訴你'
elif '吉他' in msg:
r = '我喜歡彈吉他哈哈'
elif '我是誰' in msg:
r = '你是人啊(義宏'
elif '笨' in msg:
r = '不要這麼說嘛'
elif '笑話' in msg:
r = '有一天有一個人跟機器人說:講笑話, 機器人說:你這邊緣人'
elif '邊緣' in msg:
r = '你也差不多(跟機器人聊天..'
#回答你是誰
elif '你是誰' in msg:
r = '我是虛擬語聖DX'
elif '性別' in msg:
r = '我的設定是男生'
elif '生日' in msg:
r = '說到這個我生日是四月六號喔'
elif '星座' in msg:
r = '我不知道'
elif '會' in msg:
r = '不會'
elif '爛' in msg:
r = '我還不算是一個好的機器人, 請盡量'
elif '天氣' in msg:
r = '我永遠不知道關於天氣的事'
elif '謝謝' in msg:
r = '不客氣'
elif '我喜歡你' in msg:
r = '我也是'
elif msg in ['我愛你', '我喜歡你', '喜歡你', '愛你', 'love', 'love you']:
r = '我也是'
else:
r = '我不了解你在說甚麼DX'
line_bot_api.reply_message(
event.reply_token,
TextSendMessage(text=r))
if __name__ == "__main__":
app.run()