최한솔

parameter change & code modify

...@@ -23,27 +23,26 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp ...@@ -23,27 +23,26 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp
23 23
24 //기상시간 입력 및 추천 cycle 반환 24 //기상시간 입력 및 추천 cycle 반환
25 function mytime1(agent) { 25 function mytime1(agent) {
26 - const hour = agent.parameters.hours; 26 + const hour = agent.parameters['number-integer'];
27 - const min = agent.parameters.minutes; 27 + const min = agent.parameters['number-integer1'];
28 - const gothour = hour.length > 0; 28 + const gothour = String(hour).length > 0;
29 - const gotmin = min.length > 0; 29 + const gotmin = String(min).length > 0;
30 - var myhour1,myhour2,myhour3,myhour4; 30 + const sethour = 0<=hour && hour<=24;
31 - var mymin1,mymin2,mymin3,mymin4; 31 + const setmin = 0<=min && min<=59;
32 + var myhour1,myhour2, myhour3,myhour4,mymin1,mymin2,mymin3,mymin4;
32 33
33 - if(Number(min)-30>0){ 34 + if(min-30>0){
34 - const rehour1 = Number(hour)-9; 35 + myhour1 = Number(hour)-9;
35 - const remin1 = Number(min); 36 + mymin1 = Number(min);
36 37
37 - const rehour2 = Number(hour)-7; 38 + myhour2 = Number(hour)-7;
38 - const remin2 = Number(min)-30; 39 + mymin2 = Number(min)-30;
39 40
40 - const rehour3 = Number(hour)-6; 41 + myhour3 = Number(hour)-6;
41 - const remin3 = Number(min); 42 + mymin3 = Number(min);
42 43
43 - const rehour4 = Number(hour)-4; 44 + myhour4 = Number(hour)-4;
44 - const remin4 = Number(min)-30; 45 + mymin4 = Number(min)-30;
45 -
46 - myhour1=rehour1; myhour2=rehour2; myhour3=rehour3; myhour4=rehour4;
47 46
48 //시간이 -값이 될때 값 설정 47 //시간이 -값이 될때 값 설정
49 if(myhour1<0){myhour1=24+myhour1;} 48 if(myhour1<0){myhour1=24+myhour1;}
...@@ -57,19 +56,17 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp ...@@ -57,19 +56,17 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp
57 if(mymin4<0){mymin1=60+mymin4;} 56 if(mymin4<0){mymin1=60+mymin4;}
58 57
59 }else if(Number(min)-30<0){ 58 }else if(Number(min)-30<0){
60 - const rehour1 = Number(hour)-9; 59 + myhour1 = Number(hour)-9;
61 - const remin1 = Number(min); 60 + mymin1 = Number(min);
62 -
63 - const rehour2 = Number(hour)-8;
64 - const remin2 = Number(min)+30;
65 61
66 - const rehour3 = Number(hour)-6; 62 + myhour2 = Number(hour)-8;
67 - const remin3 = Number(min); 63 + mymin2 = Number(min)+30;
68 64
69 - const rehour4 = Number(hour)-5; 65 + myhour3 = Number(hour)-6;
70 - const remin4 = Number(min)+30; 66 + mymin3 = Number(min);
71 67
72 - myhour1=rehour1; myhour2=rehour2; myhour3=rehour3; myhour4=rehour4; 68 + myhour4 = Number(hour)-5;
69 + mymin4 = Number(min)+30;
73 70
74 //시간이 -값이 될때 값 설정 71 //시간이 -값이 될때 값 설정
75 if(myhour1<0){myhour1=24+myhour1;} 72 if(myhour1<0){myhour1=24+myhour1;}
...@@ -81,96 +78,86 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp ...@@ -81,96 +78,86 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp
81 if(mymin2<0){mymin1=60+mymin2;} 78 if(mymin2<0){mymin1=60+mymin2;}
82 if(mymin3<0){mymin1=60+mymin3;} 79 if(mymin3<0){mymin1=60+mymin3;}
83 if(mymin4<0){mymin1=60+mymin4;} 80 if(mymin4<0){mymin1=60+mymin4;}
84 -
85 } 81 }
86 82
87 - if(gothour && gotmin) { 83 + if(gothour && gotmin && sethour && setmin) {
88 agent.add(`좋습니다. 당신의 기상시간은 ${hour}${min}분 입니다.`); 84 agent.add(`좋습니다. 당신의 기상시간은 ${hour}${min}분 입니다.`);
89 agent.add(`한 번의 수면 cycle은 1시간 30분 (90분)입니다.\n 당신의 기상시간을 참고한 결과 총 4개의 권장 취침 시간(cycle)이 있습니다.\n 1. ${myhour1}${myhour1}분(6cycle) \n 2. ${myhour2}${myhour2}분(5cycle) \n 3. ${myhour3}${myhour3}분(4cycle) \n 4. ${myhour4}${myhour4}(3cycle)분 \n 원하는 시간에 주무시길 추천드립니다.`); 85 agent.add(`한 번의 수면 cycle은 1시간 30분 (90분)입니다.\n 당신의 기상시간을 참고한 결과 총 4개의 권장 취침 시간(cycle)이 있습니다.\n 1. ${myhour1}${myhour1}분(6cycle) \n 2. ${myhour2}${myhour2}분(5cycle) \n 3. ${myhour3}${myhour3}분(4cycle) \n 4. ${myhour4}${myhour4}(3cycle)분 \n 원하는 시간에 주무시길 추천드립니다.`);
90 - 86 + agent.add(`꿀잠 주무시길 바랄게요:)`);
91 -
92 - } else if (gothour && !gotmin) {
93 - agent.add('기상시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
94 - } else if (gothour && !gothour) {
95 - agent.add('기상시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
96 } else { 87 } else {
97 agent.add('기상시간을 입력해 주세요( 예시 - 6:26 21:40 ) '); 88 agent.add('기상시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
98 } 89 }
99 } 90 }
100 91
101 function mytime2(agent) { 92 function mytime2(agent) {
102 - const hour = agent.parameters.hours; 93 + const hour = agent.parameters['number-integer'];
103 - const min = agent.parameters.minutes; 94 + const min = agent.parameters['number-integer1'];
104 - const gothour = hour.length > 0; 95 + const gothour = String(hour).length > 0;
105 - const gotmin = min.length > 0; 96 + const gotmin = String(min).length > 0;
106 - var myhour1,myhour2,myhour3,myhour4; 97 + const sethour = 0<=hour && hour<=24;
107 - var mymin1,mymin2,mymin3,mymin4; 98 + const setmin = 0<=min && min<=59;
108 - 99 + var myhour1,myhour2, myhour3,myhour4,mymin1,mymin2,mymin3,mymin4;
109 - if(Number(min)+30<60){
110 - const rehour1 = Number(hour)+1;
111 - const remin1 = Number(min)+30;
112 100
113 - const rehour2 = Number(hour)+6; 101 + if(min+30<60){
114 - const remin2 = Number(min); 102 + myhour1 = Number(hour)+1;
103 + mymin1 = Number(min)+30;
115 104
116 - const rehour3 = Number(hour)+7; 105 + myhour2 = Number(hour)+6;
117 - const remin3 = Number(min)+30; 106 + mymin2 = Number(min);
118 107
119 - const rehour4 = Number(hour)+9; 108 + myhour3 = Number(hour)+7;
120 - const remin4 = Number(min); 109 + mymin3 = Number(min)+30;
121 110
122 - myhour1=rehour1; myhour2=rehour2; myhour3=rehour3; myhour4=rehour4; 111 + myhour4 = Number(hour)+9;
112 + mymin4 = Number(min);
123 113
124 //시간이 -값이 될때 값 설정 114 //시간이 -값이 될때 값 설정
125 - if(myhour1<0){myhour1=24+myhour1;} 115 + if(myhour1>24){myhour1=myhour1-24;}
126 - if(myhour2<0){myhour2=24+myhour2;} 116 + if(myhour2>24){myhour2=myhour2-24;}
127 - if(myhour3<0){myhour3=24+myhour3;} 117 + if(myhour3>24){myhour3=myhour3-24;}
128 - if(myhour4<0){myhour4=24+myhour4;} 118 + if(myhour4>24){myhour4=myhour4-24;}
129 119
130 - if(mymin1<0){mymin1=60+mymin1;} 120 + if(mymin1>60){mymin1=mymin1-60;}
131 - if(mymin2<0){mymin1=60+mymin2;} 121 + if(mymin2>60){mymin1=mymin2-60;}
132 - if(mymin3<0){mymin1=60+mymin3;} 122 + if(mymin3>60){mymin1=mymin3-60;}
133 - if(mymin4<0){mymin1=60+mymin4;} 123 + if(mymin4>60){mymin1=mymin4-60;}
134 124
135 - }else if(Number(min)+30>60){ 125 + }else if(min+30>60){
136 - const rehour1 = Number(hour)+2; 126 + myhour1 = Number(hour)+2;
137 - const remin1 = Number(min)-30; 127 + mymin1 = Number(min)-30;
138 128
139 - const rehour2 = Number(hour)+6; 129 + myhour2 = Number(hour)+6;
140 - const remin2 = Number(min); 130 + mymin2 = Number(min);
141 131
142 - const rehour3 = Number(hour)+8; 132 + myhour3 = Number(hour)+8;
143 - const remin3 = Number(min)-30; 133 + mymin3 = Number(min)-30;
144 134
145 - const rehour4 = Number(hour)+9; 135 + myhour4 = Number(hour)+9;
146 - const remin4 = Number(min); 136 + mymin4 = Number(min);
147 -
148 - myhour1=rehour1; myhour2=rehour2; myhour3=rehour3; myhour4=rehour4;
149 137
150 //시간이 -값이 될때 값 설정 138 //시간이 -값이 될때 값 설정
151 - if(myhour1<0){myhour1=24+myhour1;} 139 + //시간이 -값이 될때 값 설정
152 - if(myhour2<0){myhour2=24+myhour2;} 140 + if(myhour1>24){myhour1=myhour1-24;}
153 - if(myhour3<0){myhour3=24+myhour3;} 141 + if(myhour2>24){myhour2=myhour2-24;}
154 - if(myhour4<0){myhour4=24+myhour4;} 142 + if(myhour3>24){myhour3=myhour3-24;}
155 - 143 + if(myhour4>24){myhour4=myhour4-24;}
156 - if(mymin1<0){mymin1=60+mymin1;} 144 +
157 - if(mymin2<0){mymin1=60+mymin2;} 145 + if(mymin1>60){mymin1=mymin1-60;}
158 - if(mymin3<0){mymin1=60+mymin3;} 146 + if(mymin2>60){mymin1=mymin2-60;}
159 - if(mymin4<0){mymin1=60+mymin4;} 147 + if(mymin3>60){mymin1=mymin3-60;}
148 + if(mymin4>60){mymin1=mymin4-60;}
160 } 149 }
161 150
162 - if(gothour && gotmin) { 151 + if(gothour && gotmin && sethour && setmin) {
163 agent.add(`좋습니다. 당신의 취침시간은 ${hour}${min}분 입니다.`); 152 agent.add(`좋습니다. 당신의 취침시간은 ${hour}${min}분 입니다.`);
164 agent.add(`한 번의 수면 cycle은 1시간 30분 (90분)입니다.\n 당신의 취침시간을 참고한 결과 총 4개의 권장 기상시간(cycle)이 있습니다.\n 1. ${myhour1}${myhour1}분(6cycle) \n 2. ${myhour2}${myhour2}분(5cycle) \n 3. ${myhour3}${myhour3}분(4cycle) \n 4. ${myhour4}${myhour4}(3cycle)분 \n 원하는 시간에 기상 하시길 추천드립니다.`); 153 agent.add(`한 번의 수면 cycle은 1시간 30분 (90분)입니다.\n 당신의 취침시간을 참고한 결과 총 4개의 권장 기상시간(cycle)이 있습니다.\n 1. ${myhour1}${myhour1}분(6cycle) \n 2. ${myhour2}${myhour2}분(5cycle) \n 3. ${myhour3}${myhour3}분(4cycle) \n 4. ${myhour4}${myhour4}(3cycle)분 \n 원하는 시간에 기상 하시길 추천드립니다.`);
165 - 154 + agent.add(`꿀잠 주무시길 바랄게요:)`);
166 - } else if (gothour && !gotmin) {
167 - agent.add('취침시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
168 - } else if (gothour && !gothour) {
169 - agent.add('취침시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
170 } else { 155 } else {
171 - agent.add('취침시간을 입력해 주세요( 예시 - 6:26 21:40 ) '); 156 + agent.add('기상시간을 입력해 주세요( 예시 - 6:26 21:40 ) ');
172 } 157 }
173 } 158 }
159 +
160 +
174 let intentMap = new Map(); 161 let intentMap = new Map();
175 intentMap.set('Default Welcome Intent', welcome); 162 intentMap.set('Default Welcome Intent', welcome);
176 intentMap.set('Default Fallback Intent', fallback); 163 intentMap.set('Default Fallback Intent', fallback);
......