유소연

add file

No preview for this file type
No preview for this file type
#-*-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 *
import tones
def get_comeHere_message():
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
# 유저 발화(utterance) 불러오기
utterance = getUserUtteranceFromPayload(payload)
# accountId 불러오기
accountId = getAccountIdusingUserKey(kakaoUserKey)
# petId 불러오기
petId = getPetId(kakaoUserKey)
# petName 불러오기
petName = getPetName(petId)
# relation 불러오기
relation = getRelation(kakaoUserKey, petId)
# font 불러오기
font = getFont(kakaoUserKey, petId)
# 현재 시간 불러오기
now = datetime.datetime.now()
# 펫 이미지 리스트 불러오기
category = ''
imageUrls = getPetImageUrls(kakaoUserKey, category)
imageUrl = getObjectByRandom(imageUrls)
# 사용자가 보낸 메시지 messageLogs Collection에 저장
addMessageLogs(kakaoUserKey, 'bot', utterance, now, 'none')
contextList = []
beforeUtterance = getContextParamValue(payload, 'utterance', 'before')
try:
repeatCount = int(getContextParamValue(payload, 'utterance', 'repeat'))
except:
repeatCount = 1
contextList += utteranceRepeatContext(beforeUtterance, utterance, repeatCount)
qrList = []
qrList = addRandomHintQR(qrList, petName)
qrList = qrList + basicButtonWindow(petName)
outputList = tones.getMessageOutputList(font, 'comeHere', imageUrl, 0, petName, relation)
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, outputList, now, 'none')
return ordinaryMessageType(contextList, outputList, qrList)
#-*-coding: utf-8 -*-
import os
import sys
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
import tones
# TODO 경우의 수를 나눠서 어떤 경우에는 시간에 따라, 보통 상황, 날씨에 따라, 특정 상황에 따라 메시지 선택
# 인식되어 메시지를 보내는 경우
def get_detection_message(accountId):
kakaoUserKey = getKakaoUserKeyUsingAccountId(accountId)
petId = getPetIdUsingAccountId(accountId)
font = getFont(kakaoUserKey,petId)
relation = getRelation(kakaoUserKey,petId)
petName = getPetName(petId)
now = datetime.datetime.now()
# 상황에 따른 단독 메시지 가져오기
if isMorning(now):
message = tones.getSingleMessage(font, 'morning_detected', petName, relation)
elif isAfternoon(now):
message = tones.getSingleMessage(font, 'afternoon_detected', petName, relation)
elif isEvening(now):
message = tones.getSingleMessage(font, 'evening_detected', petName, relation)
else:
message = ''
msg = pyjosa.replace_josa(message)
return msg
# 날씨 기반의 선톡을 보내는 경우
def get_weather_message(accountId):
kakao_user_key = getKakaoUserKeyUsingAccountId(accountId)
pet_id = getPetIdUsingAccountId(accountId)
font = getFont(kakao_user_key, pet_id)
relation = getRelation(kakao_user_key, pet_id)
pet_name = getPetName(pet_id)
now = datetime.datetime.now()
morning_weather = get_today_weather()['morningWeather']
afternoon_weather = get_today_weather()['afternoonWeather']
if morning_weather == '맑음' and afternoon_weather == '맑음': # 오전 오후 모두 맑은날인 경우
message = tones.getSingleMessage(font, 'sunny_day_weather', pet_name, relation)
elif '비' not in morning_weather and '비' not in afternoon_weather: # 오전오후 모두 비가오지 않는 날인 경우
message = tones.getSingleMessage(font, 'not_rainy_day_weather', pet_name, relation)
elif '비' not in morning_weather and '비' in afternoon_weather: # 오전은 아닌데 오후에 비가오는 날인 경우
message = tones.getSingleMessage(font, 'rainy_afternoon_weather', pet_name, relation)
else:
message = ''
msg = pyjosa.replace_josa(message)
return msg
#-*-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 Config import intentBlockId
# 도움말 시작
def get_startHelp_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('[시스템] 무엇이 궁금하신가요?'))
# help button window
qrList = helpButtonWindow()
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[도움말]메인', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
def get_quitHelp_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_serviceIntroduction_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
card_list = serviceIntroductionCardList(petName)
outputList.append(cardArray(card_list))
outputList.append(simpleText('도기보기와 함께라면 밖에서도 우리집 ' + petName + '와 채팅할 수 있어요😊'))
outputList.append(simpleText(petName + '와 카톡할 준비 되셨나요?'))
# help button window
qrList = helpButtonWindow()
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[도움말]서비스 소개', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# QR코드 스캔 도움말
def get_helpQrScan_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('[시스템] 카메라 초점을 맞춰서 스캔해보시겠어요?'))
outputList.append(simpleText('그래도 스캔이 잘 되지 않는다면 연락주세요\n\n‍📧: petpeotalk@gmail.com'))
qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[도움말]QR코드스캔', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 사진추가 도움말
def get_helpAddImage_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
petId = getPetId(kakaoUserKey)
petName = getPetName(petId)
outputList.append(simpleText('물론이에요!'))
outputList.append(simpleText('귀여운 ' + petName + '사진은 언제든지 추가 가능합니다😍'))
qrList.append(blockQuickReply('사진추가하기📸', '사진추가하기📸️', '5d4251ca8192ac0001b8d96e'))
qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[도움말]사진추가', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
# 사용인원 도움말
def get_helpCapacity_message():
contextList = []
outputList = []
qrList = []
payload = request.get_json()
kakaoUserKey = getKakaoUserKeyFromPayload(payload)
outputList.append(simpleText('아쉽게도 아직은 공기계 한 대당 한 명만 이용하실 수 있습니다'))
outputList.append(simpleText('머지않아 온가족이 도기보기와 함께할 수 있어요!\n'
'기대해주실거죠?☺'))
qrList.append(blockQuickReply('돌아가기↩️', '돌아가기↩️', intentBlockId.help))
# 메시지 로그 저장 sender: bot, receiver: user
addMessageLogs('bot', kakaoUserKey, '[도움말]사용인원', datetime.datetime.now(), 'none')
return ordinaryMessageType(contextList, outputList, qrList)
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.