김연준

Fixing looping problem- Still not fixed 100%

...@@ -203,17 +203,17 @@ programmingJoke= ()=>{ ...@@ -203,17 +203,17 @@ programmingJoke= ()=>{
203 }) 203 })
204 client.close(); 204 client.close();
205 }) 205 })
206 - } 206 + };
207 207
208 knockknockJoke= ()=>{ 208 knockknockJoke= ()=>{
209 - MongoClient.connect(url, function (err, client){ 209 + MongoClient.connect(url, function (err, client){
210 if (err) throw err; 210 if (err) throw err;
211 var db = client.db('jokeapi'); 211 var db = client.db('jokeapi');
212 212
213 - json_max = 376; 213 + json_max = 61;
214 function getRandomInt() { 214 function getRandomInt() {
215 min = Math.ceil(1); 215 min = Math.ceil(1);
216 - max = Math.floor(376); 216 + max = Math.floor(json_max);
217 return Math.floor(Math.random() * (max - min + 1)) + min; 217 return Math.floor(Math.random() * (max - min + 1)) + min;
218 } 218 }
219 random = getRandomInt(); 219 random = getRandomInt();
...@@ -232,7 +232,7 @@ knockknockJoke= ()=>{ ...@@ -232,7 +232,7 @@ knockknockJoke= ()=>{
232 } 232 }
233 else if(total.type != "knock-knock"){ 233 else if(total.type != "knock-knock"){
234 client.close(); 234 client.close();
235 - programmingJoke(); 235 + knockknockJoke();
236 } 236 }
237 237
238 // bot.postMessageToChannel('everyone', question, face); 238 // bot.postMessageToChannel('everyone', question, face);
...@@ -245,14 +245,13 @@ knockknockJoke= ()=>{ ...@@ -245,14 +245,13 @@ knockknockJoke= ()=>{
245 .then((joke_info)=>{ 245 .then((joke_info)=>{
246 function askQuestion(){ 246 function askQuestion(){
247 bot.postMessageToChannel(joke_info[3], joke_info[0], joke_info[2]); 247 bot.postMessageToChannel(joke_info[3], joke_info[0], joke_info[2]);
248 - console.log("프로그래밍 질문 불려짐"); 248 + console.log("똑똑 질문 불려짐");
249 } 249 }
250 askQuestion(); 250 askQuestion();
251 return joke_info; 251 return joke_info;
252 }) 252 })
253 .then((info)=>{ 253 .then((info)=>{
254 bot.postMessageToChannel(info[3], info[1], info[2]); 254 bot.postMessageToChannel(info[3], info[1], info[2]);
255 - return;
256 }) 255 })
257 client.close(); 256 client.close();
258 }) 257 })
......