김연준

Building callback function to ensure code execution order

Showing 1 changed file with 17 additions and 7 deletions
...@@ -7,7 +7,7 @@ const MongoClient = require('mongodb').MongoClient; ...@@ -7,7 +7,7 @@ const MongoClient = require('mongodb').MongoClient;
7 const url = 'mongodb://localhost:27017/'; 7 const url = 'mongodb://localhost:27017/';
8 8
9 const bot = new SlackBot({ 9 const bot = new SlackBot({
10 - token : "xoxb-582582124755-587875604934-EWnGacmzNvfVQk2XvhteoIzw", 10 + token : "xoxb-582582124755-587875604934-mceAxq9E58uHT4WRkqSbcibU",
11 name : "Joker" 11 name : "Joker"
12 }); 12 });
13 13
...@@ -80,13 +80,23 @@ randomJoke= ()=>{ ...@@ -80,13 +80,23 @@ randomJoke= ()=>{
80 const face = { 80 const face = {
81 icon_emoji: ':laughing:' 81 icon_emoji: ':laughing:'
82 }; 82 };
83 + function firstFunction(channel){
84 + bot.postMessageToChannel(channel, joke, face);
85 + console.log("허무개그 전송~~~~!");
86 + }
83 87
84 - bot.postMessageToChannel('everyone', joke, face); 88 + function secondFunction(channel, callback){
85 - bot.postMessageToChannel('full-stack-web', joke, face); 89 + bot.postMessageToChannel(channel, question, face);
86 - bot.postMessageToChannel('bot_test', joke, face); 90 + console.log("질문 불려짐")
87 - bot.postMessageToChannel('everyone', question, face); 91 + firstFunction(channel);
88 - bot.postMessageToChannel('full-stack-web', question, joke, face); 92 + }
89 - bot.postMessageToChannel('bot_test', question, face); 93 + secondFunction('everyone',firstFunction);
94 + // bot.postMessageToChannel('everyone', question, face);
95 + // bot.postMessageToChannel('full-stack-web', question, joke, face);
96 + // bot.postMessageToChannel('bot_test', question, face);
97 + // bot.postMessageToChannel('everyone', joke, face);
98 + // bot.postMessageToChannel('full-stack-web', joke, face);
99 + // bot.postMessageToChannel('bot_test', joke, face);
90 }) 100 })
91 client.close(); 101 client.close();
92 }) 102 })
......