Showing
13 changed files
with
254 additions
and
0 deletions
No preview for this file type
dogibogi/.DS_Store
0 → 100644
No preview for this file type
dogibogi/OpenbuilderSkills/__init__.py
0 → 100644
File mode changed
dogibogi/OpenbuilderSkills/command.py
0 → 100644
1 | +#-*-coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | +from flask import request | ||
5 | +import datetime | ||
6 | + | ||
7 | +import random | ||
8 | + | ||
9 | +sys.path.append(os.path.dirname(os.path.dirname("main"))) | ||
10 | +from Functions.getInstance import * | ||
11 | +from Functions.checkFunction import * | ||
12 | +from Functions.updateDatabase import * | ||
13 | +from Functions.messageTypes import * | ||
14 | + | ||
15 | +import tones | ||
16 | + | ||
17 | +def get_comeHere_message(): | ||
18 | + payload = request.get_json() | ||
19 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
20 | + # 유저 발화(utterance) 불러오기 | ||
21 | + utterance = getUserUtteranceFromPayload(payload) | ||
22 | + # accountId 불러오기 | ||
23 | + accountId = getAccountIdusingUserKey(kakaoUserKey) | ||
24 | + # petId 불러오기 | ||
25 | + petId = getPetId(kakaoUserKey) | ||
26 | + # petName 불러오기 | ||
27 | + petName = getPetName(petId) | ||
28 | + # relation 불러오기 | ||
29 | + relation = getRelation(kakaoUserKey, petId) | ||
30 | + # font 불러오기 | ||
31 | + font = getFont(kakaoUserKey, petId) | ||
32 | + # 현재 시간 불러오기 | ||
33 | + now = datetime.datetime.now() | ||
34 | + | ||
35 | + # 펫 이미지 리스트 불러오기 | ||
36 | + category = '' | ||
37 | + imageUrls = getPetImageUrls(kakaoUserKey, category) | ||
38 | + imageUrl = getObjectByRandom(imageUrls) | ||
39 | + | ||
40 | + # 사용자가 보낸 메시지 messageLogs Collection에 저장 | ||
41 | + addMessageLogs(kakaoUserKey, 'bot', utterance, now, 'none') | ||
42 | + contextList = [] | ||
43 | + beforeUtterance = getContextParamValue(payload, 'utterance', 'before') | ||
44 | + try: | ||
45 | + repeatCount = int(getContextParamValue(payload, 'utterance', 'repeat')) | ||
46 | + except: | ||
47 | + repeatCount = 1 | ||
48 | + contextList += utteranceRepeatContext(beforeUtterance, utterance, repeatCount) | ||
49 | + qrList = [] | ||
50 | + qrList = addRandomHintQR(qrList, petName) | ||
51 | + qrList = qrList + basicButtonWindow(petName) | ||
52 | + outputList = tones.getMessageOutputList(font, 'comeHere', imageUrl, 0, petName, relation) | ||
53 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
54 | + addMessageLogs('bot', kakaoUserKey, outputList, now, 'none') | ||
55 | + return ordinaryMessageType(contextList, outputList, qrList) |
dogibogi/OpenbuilderSkills/eventMessage.py
0 → 100644
1 | +#-*-coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | +import datetime | ||
5 | +import random | ||
6 | + | ||
7 | +sys.path.append(os.path.dirname(os.path.dirname("main"))) | ||
8 | +from Functions.getInstance import * | ||
9 | +from Functions.checkFunction import * | ||
10 | +from Functions.updateDatabase import * | ||
11 | +from Functions.messageTypes import * | ||
12 | +from Functions import pyjosa | ||
13 | +import tones | ||
14 | + | ||
15 | + | ||
16 | +# TODO 경우의 수를 나눠서 어떤 경우에는 시간에 따라, 보통 상황, 날씨에 따라, 특정 상황에 따라 메시지 선택 | ||
17 | + | ||
18 | + | ||
19 | +# 인식되어 메시지를 보내는 경우 | ||
20 | +def get_detection_message(accountId): | ||
21 | + kakaoUserKey = getKakaoUserKeyUsingAccountId(accountId) | ||
22 | + petId = getPetIdUsingAccountId(accountId) | ||
23 | + | ||
24 | + font = getFont(kakaoUserKey,petId) | ||
25 | + relation = getRelation(kakaoUserKey,petId) | ||
26 | + petName = getPetName(petId) | ||
27 | + | ||
28 | + now = datetime.datetime.now() | ||
29 | + # 상황에 따른 단독 메시지 가져오기 | ||
30 | + if isMorning(now): | ||
31 | + message = tones.getSingleMessage(font, 'morning_detected', petName, relation) | ||
32 | + elif isAfternoon(now): | ||
33 | + message = tones.getSingleMessage(font, 'afternoon_detected', petName, relation) | ||
34 | + elif isEvening(now): | ||
35 | + message = tones.getSingleMessage(font, 'evening_detected', petName, relation) | ||
36 | + else: | ||
37 | + message = '' | ||
38 | + | ||
39 | + msg = pyjosa.replace_josa(message) | ||
40 | + return msg | ||
41 | + | ||
42 | +# 날씨 기반의 선톡을 보내는 경우 | ||
43 | +def get_weather_message(accountId): | ||
44 | + kakao_user_key = getKakaoUserKeyUsingAccountId(accountId) | ||
45 | + pet_id = getPetIdUsingAccountId(accountId) | ||
46 | + | ||
47 | + font = getFont(kakao_user_key, pet_id) | ||
48 | + relation = getRelation(kakao_user_key, pet_id) | ||
49 | + pet_name = getPetName(pet_id) | ||
50 | + | ||
51 | + now = datetime.datetime.now() | ||
52 | + | ||
53 | + morning_weather = get_today_weather()['morningWeather'] | ||
54 | + afternoon_weather = get_today_weather()['afternoonWeather'] | ||
55 | + if morning_weather == '맑음' and afternoon_weather == '맑음': # 오전 오후 모두 맑은날인 경우 | ||
56 | + message = tones.getSingleMessage(font, 'sunny_day_weather', pet_name, relation) | ||
57 | + elif '비' not in morning_weather and '비' not in afternoon_weather: # 오전오후 모두 비가오지 않는 날인 경우 | ||
58 | + message = tones.getSingleMessage(font, 'not_rainy_day_weather', pet_name, relation) | ||
59 | + elif '비' not in morning_weather and '비' in afternoon_weather: # 오전은 아닌데 오후에 비가오는 날인 경우 | ||
60 | + message = tones.getSingleMessage(font, 'rainy_afternoon_weather', pet_name, relation) | ||
61 | + else: | ||
62 | + message = '' | ||
63 | + msg = pyjosa.replace_josa(message) | ||
64 | + return msg |
dogibogi/OpenbuilderSkills/help.py
0 → 100644
1 | +#-*-coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | +from flask import request | ||
5 | +import datetime | ||
6 | + | ||
7 | +import random | ||
8 | + | ||
9 | +sys.path.append(os.path.dirname(os.path.dirname("main"))) | ||
10 | +from Functions.getInstance import * | ||
11 | +from Functions.checkFunction import * | ||
12 | +from Functions.updateDatabase import * | ||
13 | +from Functions.messageTypes import * | ||
14 | +from Config import intentBlockId | ||
15 | + | ||
16 | +# 도움말 시작 | ||
17 | +def get_startHelp_message(): | ||
18 | + contextList = [] | ||
19 | + outputList = [] | ||
20 | + qrList = [] | ||
21 | + | ||
22 | + payload = request.get_json() | ||
23 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
24 | + outputList.append(simpleText('[시스템] 무엇이 궁금하신가요?')) | ||
25 | + | ||
26 | + # help button window | ||
27 | + qrList = helpButtonWindow() | ||
28 | + | ||
29 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
30 | + addMessageLogs('bot', kakaoUserKey, '[도움말]메인', datetime.datetime.now(), 'none') | ||
31 | + | ||
32 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
33 | + | ||
34 | +def get_quitHelp_message(): | ||
35 | + contextList = [] | ||
36 | + outputList = [] | ||
37 | + qrList = [] | ||
38 | + | ||
39 | + payload = request.get_json() | ||
40 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
41 | + petId = getPetId(kakaoUserKey) | ||
42 | + petName = getPetName(petId) | ||
43 | + outputList.append(simpleText('[시스템] 언제든지 다시 질문해주세요')) | ||
44 | + | ||
45 | + # 챗봇 노란버튼 | ||
46 | + qrList = basicButtonWindow(petName) | ||
47 | + | ||
48 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
49 | + addMessageLogs('bot', kakaoUserKey, '[도움말]종료', datetime.datetime.now(), 'none') | ||
50 | + | ||
51 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
52 | + | ||
53 | +def get_serviceIntroduction_message(): | ||
54 | + contextList = [] | ||
55 | + outputList = [] | ||
56 | + qrList = [] | ||
57 | + | ||
58 | + payload = request.get_json() | ||
59 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
60 | + petId = getPetId(kakaoUserKey) | ||
61 | + petName = getPetName(petId) | ||
62 | + | ||
63 | + card_list = serviceIntroductionCardList(petName) | ||
64 | + outputList.append(cardArray(card_list)) | ||
65 | + outputList.append(simpleText('도기보기와 함께라면 밖에서도 우리집 ' + petName + '와 채팅할 수 있어요😊')) | ||
66 | + outputList.append(simpleText(petName + '와 카톡할 준비 되셨나요?')) | ||
67 | + | ||
68 | + # help button window | ||
69 | + qrList = helpButtonWindow() | ||
70 | + | ||
71 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
72 | + addMessageLogs('bot', kakaoUserKey, '[도움말]서비스 소개', datetime.datetime.now(), 'none') | ||
73 | + | ||
74 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
75 | + | ||
76 | + | ||
77 | +# QR코드 스캔 도움말 | ||
78 | +def get_helpQrScan_message(): | ||
79 | + contextList = [] | ||
80 | + outputList = [] | ||
81 | + qrList = [] | ||
82 | + | ||
83 | + payload = request.get_json() | ||
84 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
85 | + outputList.append(simpleText('[시스템] 카메라 초점을 맞춰서 스캔해보시겠어요?')) | ||
86 | + outputList.append(simpleText('그래도 스캔이 잘 되지 않는다면 연락주세요\n\n📧: petpeotalk@gmail.com')) | ||
87 | + | ||
88 | + qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help)) | ||
89 | + | ||
90 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
91 | + addMessageLogs('bot', kakaoUserKey, '[도움말]QR코드스캔', datetime.datetime.now(), 'none') | ||
92 | + | ||
93 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
94 | + | ||
95 | +# 사진추가 도움말 | ||
96 | +def get_helpAddImage_message(): | ||
97 | + contextList = [] | ||
98 | + outputList = [] | ||
99 | + qrList = [] | ||
100 | + | ||
101 | + payload = request.get_json() | ||
102 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
103 | + petId = getPetId(kakaoUserKey) | ||
104 | + petName = getPetName(petId) | ||
105 | + | ||
106 | + outputList.append(simpleText('물론이에요!')) | ||
107 | + outputList.append(simpleText('귀여운 ' + petName + '사진은 언제든지 추가 가능합니다😍')) | ||
108 | + | ||
109 | + qrList.append(blockQuickReply('사진추가하기📸', '사진추가하기📸️', '5d4251ca8192ac0001b8d96e')) | ||
110 | + qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help)) | ||
111 | + | ||
112 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
113 | + addMessageLogs('bot', kakaoUserKey, '[도움말]사진추가', datetime.datetime.now(), 'none') | ||
114 | + | ||
115 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
116 | + | ||
117 | + | ||
118 | +# 사용인원 도움말 | ||
119 | +def get_helpCapacity_message(): | ||
120 | + contextList = [] | ||
121 | + outputList = [] | ||
122 | + qrList = [] | ||
123 | + | ||
124 | + payload = request.get_json() | ||
125 | + kakaoUserKey = getKakaoUserKeyFromPayload(payload) | ||
126 | + outputList.append(simpleText('아쉽게도 아직은 공기계 한 대당 한 명만 이용하실 수 있습니다')) | ||
127 | + outputList.append(simpleText('머지않아 온가족이 도기보기와 함께할 수 있어요!\n' | ||
128 | + '기대해주실거죠?☺')) | ||
129 | + | ||
130 | + qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help)) | ||
131 | + | ||
132 | + # 메시지 로그 저장 sender: bot, receiver: user | ||
133 | + addMessageLogs('bot', kakaoUserKey, '[도움말]사용인원', datetime.datetime.now(), 'none') | ||
134 | + | ||
135 | + return ordinaryMessageType(contextList, outputList, qrList) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
dogibogi/OpenbuilderSkills/minigame.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/question.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/setting.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/statement.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/system.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/userAction.py
0 → 100644
This diff is collapsed. Click to expand it.
dogibogi/OpenbuilderSkills/userEmotion.py
0 → 100644
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment