setting.py
12 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#-*-coding: utf-8 -*-
import os
import sys
from flask import request
import datetime
import random
sys.path.append(os.path.dirname(os.path.dirname("main")))
from Functions.getInstance import *
from Functions.checkFunction import *
from Functions.updateDatabase import *
from Functions.messageTypes import *
from Functions import pyjosa
# 환경설정 시작
def get_startSetting_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList += settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]메인', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
def get_quitSetting_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
outputList.append(simpleText('[시스템] 설정이 완료되었습니다'))
# 챗봇 노란버튼
qrList = basicButtonWindow(petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]종료', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
def get_tryConnectAfterRegister_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('스마트폰 공기계를 구하셨나보네요😃!'))
outputList.append(simpleText('기기연동을 바로 진행하겠습니다'))
qrList.append(blockQuickReply('생각해볼게요↩️', '생각해볼게요↩️', '5e576884ffa7480001ef080b'))
qrList.append(blockQuickReply('진행합니다', '진행합니다', '5d3fa9d48192ac0001fc4ed1'))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]기기연동시도', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
def get_quitConnectAfterRegister_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
outputList.append(simpleText('준비가 되면 다시 찾아와주세요'))
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList = settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]기기연동취소', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 해당 챗봇과 연동된 모든 사용자데이터를 삭제 시도
def get_tryRemoveUser_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('[시스템] 기기 연동을 해제하시겠습니까?'))
outputList.append(simpleText('⚠️계속 진행할 시 카카오톡 내의 사용자 정보가 모두 삭제됩니다'))
outputList.append(simpleText('(어플리케이션의 계정정보는 삭제되지 않으며, 다시 이용하려면 기기연동을 다시 진행해야합니다.)'))
qrList.append(blockQuickReply('생각해볼게요↩️', '생각해볼게요↩️', '5dc0040fb617ea000165f420'))
qrList.append(blockQuickReply('계속하겠습니다⚠️', '계속하겠습니다⚠️', '5dc00419b617ea000165f422'))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]유저삭제시도', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 유저 삭제 과정 철회
def get_quitRemoveUser_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
outputList.append(simpleText('[시스템] 취소되었습니다'))
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList = settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]유저삭제취소', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# kakaoUserKey로 특정 유저 찾아서 삭제
def get_removeUser_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
# 유저의 모든 게시물 삭제
removeUserAllPost(kakaoUserKey)
# S3에서 유저가 등록한 이미지 삭제
deleteUserImageInStorage(kakaoUserKey)
# 유저 db 삭제
removeUser(kakaoUserKey)
outputList.append(simpleText('[시스템] 기기 연동이 해제되었습니다'))
outputList.append(simpleText('다시 연동하려면 인사를 건네주세요'))
outputList.append(simpleText('(그만)'))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]유저삭제성공', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 반려동물 말투 변경 시도
def get_tryChangeFont_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
outputList.append(simpleText('[시스템] ' + petName + '의 말투를 재설정합니다'))
outputList.append(simpleText('말투를 골라주세요'))
qrList.append(blockQuickReply('생각해볼게요↩️', '생각해볼게요↩️', '5dc0040fb617ea000165f420'))
fonts = getUserFonts(kakaoUserKey)
fontList = []
for font in fonts:
fontList.append(getFontFromVar(font['font']))
qrList = fontSettingWindow(fontList)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]말투변경시도', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 말투 변경 과정 철회
def get_quitChangeFont_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
outputList.append(simpleText('[시스템] 취소되었습니다'))
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList = settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]말투변경취소', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 반려동물과의 관계(relation) 변경 시도
def get_tryChangeRelation_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
outputList.append(simpleText('[시스템] ' + petName + '가 앞으로 당신을 뭐라고 불러주면 좋을까요?'))
qrList.append(blockQuickReply('생각해볼게요↩️', '생각해볼게요↩️', '5dc0040fb617ea000165f420'))
qrList = relationSettingWindow()
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]호칭변경시도', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 반려동물과의 관계(relation) 변경 과정 철회
def get_quitChangeRelation_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
outputList.append(simpleText('[시스템] 취소되었습니다'))
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList = settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]호칭변경취소', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 닉네임 변경 시도
def get_tryChangeNickname_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('[시스템] 새로운 닉네임을 입력해주세요'))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]닉네임변경시도', datetime.datetime.now(), 'none')
contextList.append(contextValue('nickname', 1, {'change_nickname': 'alive'}))
return ordinaryMessageType(contextList, outputList, qrList)
# 닉네임 변경 과정 철회
def get_quitChangeNickname_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
nickname = getUserNickname(kakaoUserKey)
accountId = getAccountIdusingUserKey(kakaoUserKey)
myFonts = getUserProfileFonts(kakaoUserKey)
myDogiPoint = getUserDogiPoint(kakaoUserKey)
myBadges = getUserProfileBadges(kakaoUserKey)
outputList.append(simpleText('[시스템] 취소되었습니다'))
# 프로필 리스트
outputList += userProfileList(accountId, myFonts, myDogiPoint, myBadges, nickname)
# setting button window
qrList = settingButtonWindow(kakaoUserKey, petName)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[환경설정]닉네임변경취소', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)