오원석

all.code.correct

...@@ -199,19 +199,11 @@ randomJoke= (user_channel)=>{ ...@@ -199,19 +199,11 @@ randomJoke= (user_channel)=>{
199 //After finding one joke, use promise to run codes synchronously 199 //After finding one joke, use promise to run codes synchronously
200 user.then(function(total){ 200 user.then(function(total){
201 question = total.setup; 201 question = total.setup;
202 + joke=total.punchline;
203 + ques_and_joke=question+'\n'+joke+':stuck_out_tongue_winking_eye::laughing:';
202 //Ask the question first by extracting 'setup' section from api format 204 //Ask the question first by extracting 'setup' section from api format
203 - bot.postMessageToChannel(user_channel, question, emoji.emojis('laughing')); 205 + bot.postMessageToChannel(user_channel, ques_and_joke, emoji.emojis('laughing'));
204 - console.log('질문 불려짐'); 206 + console.log('Random joke~~~');
205 - return total;
206 - })
207 - .then((all)=>{
208 - joke = all.punchline;
209 - //Use setTimeout function to delay the code execution, making sure the user reads the question first and then see the final funny joke
210 - setTimeout(function secondFunction(){
211 - bot.postMessageToChannel(user_channel, `${joke}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
212 - console.log( "허무개그 전송~~~~!")
213 - }, 3000);
214 -
215 }) 207 })
216 //close mongodb 208 //close mongodb
217 client.close(); 209 client.close();
...@@ -228,11 +220,11 @@ UserMakeJoke= (user_channel)=>{ ...@@ -228,11 +220,11 @@ UserMakeJoke= (user_channel)=>{
228 for(var i=0;i<jsondata.table.length;i++){ 220 for(var i=0;i<jsondata.table.length;i++){
229 if(jsondata.table[i].id==random){ 221 if(jsondata.table[i].id==random){
230 user=jsondata.table[i]; 222 user=jsondata.table[i];
231 - console.log(user);
232 question=user.setup; 223 question=user.setup;
233 joke=user.punchline; 224 joke=user.punchline;
234 result=question+'\n'+joke; 225 result=question+'\n'+joke;
235 bot.postMessageToChannel(user_channel,result, emoji.emojis('laughing')); 226 bot.postMessageToChannel(user_channel,result, emoji.emojis('laughing'));
227 + console.log("User joke~~~");
236 break; 228 break;
237 } 229 }
238 } 230 }
...@@ -251,19 +243,9 @@ generalJoke= (user_channel)=>{ ...@@ -251,19 +243,9 @@ generalJoke= (user_channel)=>{
251 user.then(function(total){ 243 user.then(function(total){
252 question = total.setup; 244 question = total.setup;
253 joke = total.punchline; 245 joke = total.punchline;
254 - ques_and_joke = [question, joke]; 246 + ques_and_joke=question+'\n'+joke+':stuck_out_tongue_winking_eye::laughing:';
255 - return ques_and_joke; 247 + bot.postMessageToChannel(user_channel,ques_and_joke,emoji.emojis('laughing'));
256 - }) 248 + console.log("General Joke~~~~");
257 - .then((joke_info)=>{
258 - bot.postMessageToChannel(user_channel, joke_info[0], emoji.emojis('laughing'));
259 - console.log("일반 질문 불려짐");
260 - return joke_info;
261 - })
262 - .then((info)=>{
263 - setTimeout(function secondFunction(){
264 - bot.postMessageToChannel(user_channel, `${info[1]}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
265 - console.log( "허무개그 전송~~~~!")
266 - }, 3000);
267 }) 249 })
268 client.close(); 250 client.close();
269 }) 251 })
...@@ -281,19 +263,9 @@ programmingJoke= (user_channel)=>{ ...@@ -281,19 +263,9 @@ programmingJoke= (user_channel)=>{
281 user.then(function(total){ 263 user.then(function(total){
282 question = total.setup; 264 question = total.setup;
283 joke = total.punchline; 265 joke = total.punchline;
284 - ques_and_joke = [question, joke]; 266 + ques_and_joke = question+'\n'+joke+':stuck_out_tongue_winking_eye::laughing:';
285 - return ques_and_joke; 267 + bot.postMessageToChannel(user_channel,ques_and_joke,emoji.emojis('laughing'));
286 - }) 268 + console.log("Programming Joke~~~");
287 - .then((joke_info)=>{
288 - bot.postMessageToChannel(user_channel, joke_info[0], emoji.emojis('laughing'));
289 - console.log("프로그래밍 질문 불려짐");
290 - return joke_info;
291 - })
292 - .then((info)=>{
293 - setTimeout(function secondFunction(){
294 - bot.postMessageToChannel(user_channel, `${info[1]}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
295 - console.log( "허무개그 전송~~~~!")
296 - }, 3000);
297 }) 269 })
298 client.close(); 270 client.close();
299 }) 271 })
...@@ -314,15 +286,10 @@ Funnystory= (user_channel)=>{ ...@@ -314,15 +286,10 @@ Funnystory= (user_channel)=>{
314 //if the random picked api type is not general execute the function from the start to get another format for general type 286 //if the random picked api type is not general execute the function from the start to get another format for general type
315 user.then(function(total){ 287 user.then(function(total){
316 category = total.category 288 category = total.category
289 + story=total.body;
290 + category_story=category+'\n'+story+':stuck_out_tongue_winking_eye::laughing:';
317 bot.postMessageToChannel(user_channel, category, emoji.emojis('smiliey')); 291 bot.postMessageToChannel(user_channel, category, emoji.emojis('smiliey'));
318 - console.log("이야기 카테고리") 292 + console.log("Funny story~~~");
319 - return total;
320 - })
321 - .then((all)=>{
322 - story = all.body;
323 - bot.postMessageToChannel(user_channel, `${story}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
324 - console.log("이야기 시작!");
325 -
326 }) 293 })
327 client.close(); 294 client.close();
328 }) 295 })
...@@ -341,15 +308,10 @@ redditJoke= (user_channel)=>{ ...@@ -341,15 +308,10 @@ redditJoke= (user_channel)=>{
341 //if the random picked api type is not general execute the function from the start to get another format for general type 308 //if the random picked api type is not general execute the function from the start to get another format for general type
342 user.then(function(total){ 309 user.then(function(total){
343 title = total.title; 310 title = total.title;
344 - bot.postMessageToChannel(user_channel, title, emoji.emojis('smiliey')); 311 + joke=total.body;
345 - console.log("문답형 JOKE") 312 + title_joke=title+'\n'+joke+':stuck_out_tongue_winking_eye::laughing:';
346 - return total; 313 + bot.postMessageToChannel(user_channel, title_joke, emoji.emojis('smiliey'));
347 - }) 314 + console.log("reddit Joke~~~");
348 - .then((all)=>{
349 - joke = all.body;
350 - bot.postMessageToChannel(user_channel, `${joke}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
351 - console.log("정답은~~");
352 -
353 }) 315 })
354 client.close(); 316 client.close();
355 }) 317 })
...@@ -366,20 +328,9 @@ knockknockJoke= (user_channel)=>{ ...@@ -366,20 +328,9 @@ knockknockJoke= (user_channel)=>{
366 user.then(function(total){ 328 user.then(function(total){
367 question = total.setup; 329 question = total.setup;
368 joke = total.punchline; 330 joke = total.punchline;
369 - ques_and_joke = [question, joke]; 331 + ques_and_joke = question+'\n'+joke+':stuck_out_tongue_winking_eye::laughing:';
370 - return ques_and_joke; 332 + bot.postMessageToChannel(user_channel, ques_and_joke, emoji.emojis('laughing'));
371 - }) 333 + console.log("Knock-Knock joke~~~");
372 - .then((joke_info)=>{
373 - bot.postMessageToChannel(user_channel, joke_info[0], emoji.emojis('laughing'));
374 - console.log("똑똑 질문 불려짐");
375 -
376 - return joke_info;
377 - })
378 - .then((info)=>{
379 - setTimeout(function secondFunction(){
380 - bot.postMessageToChannel(user_channel, `${info[1]}:stuck_out_tongue_winking_eye::laughing:`, emoji.emojis('laughing'))
381 - console.log( "허무개그 전송~~~~!")
382 - }, 3000);
383 }) 334 })
384 client.close(); 335 client.close();
385 }) 336 })
......