Showing
5 changed files
with
17 additions
and
18 deletions
... | @@ -10,7 +10,7 @@ message_recieved = 0; | ... | @@ -10,7 +10,7 @@ message_recieved = 0; |
10 | exports.startbot = ()=>{ | 10 | exports.startbot = ()=>{ |
11 | // Get authorization to use the slackbot | 11 | // Get authorization to use the slackbot |
12 | const bot = new SlackBot({ | 12 | const bot = new SlackBot({ |
13 | - token : "xoxb-651692943605-645515979745-sqycGNiTIOZNxnly4k1BV1HO", | 13 | + token : "xoxb-651692943605-645515979745-VInZkUepi88jyzhpps44uRyM", |
14 | name : "jokebot" | 14 | name : "jokebot" |
15 | }); | 15 | }); |
16 | 16 | ||
... | @@ -142,7 +142,7 @@ function MakeJoke(message,user_channel){ | ... | @@ -142,7 +142,7 @@ function MakeJoke(message,user_channel){ |
142 | var user=temp[0].substring(2,temp[0].length-1); | 142 | var user=temp[0].substring(2,temp[0].length-1); |
143 | console.log('유저 => '+user); | 143 | console.log('유저 => '+user); |
144 | 144 | ||
145 | - var path='./joke_data/'+user+'.json'; | 145 | + var path='./joke_data/user.json'; |
146 | console.log(path); | 146 | console.log(path); |
147 | fs.exists(path,function(exists){ | 147 | fs.exists(path,function(exists){ |
148 | if(exists){ | 148 | if(exists){ |
... | @@ -154,8 +154,8 @@ function MakeJoke(message,user_channel){ | ... | @@ -154,8 +154,8 @@ function MakeJoke(message,user_channel){ |
154 | else{ | 154 | else{ |
155 | obj=JSON.parse(data); | 155 | obj=JSON.parse(data); |
156 | var length=obj.table.length; | 156 | var length=obj.table.length; |
157 | - obj.table.push({id : length+1, type : 'userjoke', setup : msg[0], punchline : msg[1]}); | 157 | + obj.table.push({id : length+1, type : user, setup : msg[0], punchline : msg[1]}); |
158 | - var myobj = {id : length+1, type : 'userjoke', setup : msg[0], punchline : msg[1]}; | 158 | + var myobj = {id : length+1, type : user, setup : msg[0], punchline : msg[1]}; |
159 | MongoClient.connect(url2,function(err,db){ | 159 | MongoClient.connect(url2,function(err,db){ |
160 | if(err) throw err; | 160 | if(err) throw err; |
161 | var dbo = db.db("userdb"); | 161 | var dbo = db.db("userdb"); |
... | @@ -181,8 +181,8 @@ function MakeJoke(message,user_channel){ | ... | @@ -181,8 +181,8 @@ function MakeJoke(message,user_channel){ |
181 | } | 181 | } |
182 | else{ | 182 | else{ |
183 | console.log("file not exists"); | 183 | console.log("file not exists"); |
184 | - obj.table.push({id : 1, type : 'userjoke', setup : msg[0], punchline : msg[1]}); | 184 | + obj.table.push({id : 1, type : user, setup : msg[0], punchline : msg[1]}); |
185 | - var myobj = {id : 1, type : 'userjoke', setup : msg[0], punchline : msg[1]}; | 185 | + var myobj = {id : 1, type : user, setup : msg[0], punchline : msg[1]}; |
186 | //Create database | 186 | //Create database |
187 | MongoClient.connect(url2, { useNewUrlParser: true }, function(err, db) { | 187 | MongoClient.connect(url2, { useNewUrlParser: true }, function(err, db) { |
188 | if (err) throw err; | 188 | if (err) throw err; |
... | @@ -387,7 +387,7 @@ redditJoke= (user_channel)=>{ | ... | @@ -387,7 +387,7 @@ redditJoke= (user_channel)=>{ |
387 | user.then(function(total){ | 387 | user.then(function(total){ |
388 | title = total.title; | 388 | title = total.title; |
389 | bot.postMessageToChannel(user_channel, title, emoji.emojis('smiliey')); | 389 | bot.postMessageToChannel(user_channel, title, emoji.emojis('smiliey')); |
390 | - console.log("질문 불려짐"); | 390 | + console.log("quiz~"); |
391 | return total; | 391 | return total; |
392 | }) | 392 | }) |
393 | .then((all)=>{ | 393 | .then((all)=>{ |
... | @@ -395,7 +395,7 @@ redditJoke= (user_channel)=>{ | ... | @@ -395,7 +395,7 @@ redditJoke= (user_channel)=>{ |
395 | //Use setTimeout function to delay the code execution, making sure the user reads the question first and then see the final funny joke | 395 | //Use setTimeout function to delay the code execution, making sure the user reads the question first and then see the final funny joke |
396 | setTimeout(function secondFunction(){ | 396 | setTimeout(function secondFunction(){ |
397 | bot.postMessageToChannel(user_channel,`${joke}:stuck_out_tongue_winking_eye::laughing:`,emoji.emojis('laughing')); | 397 | bot.postMessageToChannel(user_channel,`${joke}:stuck_out_tongue_winking_eye::laughing:`,emoji.emojis('laughing')); |
398 | - console.log("허무개그 전송~~~~~~!"); | 398 | + console.log("reddit joke~~~"); |
399 | },3000); | 399 | },3000); |
400 | }) | 400 | }) |
401 | client.close(); | 401 | client.close(); | ... | ... |
joke_data/UJP8BFSNP.json
deleted
100644 → 0
1 | -{"table":[{"id":1,"type":"userjoke","setup":" one plus one equals?","punchline":" window!!"}]} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{"table":[{"id":1,"type":"userjoke","setup":" hello","punchline":" ok"}]} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +{"table":[{"id":1,"type":"UJZF5UTMX","setup":" ok","punchline":" okkk"},{"id":2,"type":"UJZF5UTMX","setup":" man","punchline":" woman"},{"id":3,"type":"UJZF5UTMX","setup":" kim ","punchline":" minuk"}]} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -264,18 +264,18 @@ | ... | @@ -264,18 +264,18 @@ |
264 | } | 264 | } |
265 | }, | 265 | }, |
266 | "mongodb": { | 266 | "mongodb": { |
267 | - "version": "3.2.6", | 267 | + "version": "3.2.7", |
268 | - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.6.tgz", | 268 | + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.7.tgz", |
269 | - "integrity": "sha512-qnHc4tjEkHKemuzBq9R7ycYnhFE0Dlpt6+n6suoZp2DcDdqviQ+teloJU24fsOw/PLmr75yGk4mRx/YabjDQEQ==", | 269 | + "integrity": "sha512-2YdWrdf1PJgxcCrT1tWoL6nHuk6hCxhddAAaEh8QJL231ci4+P9FLyqopbTm2Z2sAU6mhCri+wd9r1hOcHdoMw==", |
270 | "requires": { | 270 | "requires": { |
271 | - "mongodb-core": "3.2.6", | 271 | + "mongodb-core": "3.2.7", |
272 | "safe-buffer": "^5.1.2" | 272 | "safe-buffer": "^5.1.2" |
273 | } | 273 | } |
274 | }, | 274 | }, |
275 | "mongodb-core": { | 275 | "mongodb-core": { |
276 | - "version": "3.2.6", | 276 | + "version": "3.2.7", |
277 | - "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.6.tgz", | 277 | + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.7.tgz", |
278 | - "integrity": "sha512-i+XRVjur9D0ywGF7cFebOUnALnbvMHajdNhhl3TQuopW6QDE655G8CpPeERbqSqfa3rOKEUo08lENDIiBIuAvQ==", | 278 | + "integrity": "sha512-WypKdLxFNPOH/Jy6i9z47IjG2wIldA54iDZBmHMINcgKOUcWJh8og+Wix76oGd7EyYkHJKssQ2FAOw5Su/n4XQ==", |
279 | "requires": { | 279 | "requires": { |
280 | "bson": "^1.1.1", | 280 | "bson": "^1.1.1", |
281 | "require_optional": "^1.0.1", | 281 | "require_optional": "^1.0.1", | ... | ... |
... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
11 | "dependencies": { | 11 | "dependencies": { |
12 | "axios": "^0.18.1", | 12 | "axios": "^0.18.1", |
13 | "fs": "0.0.1-security", | 13 | "fs": "0.0.1-security", |
14 | - "mongodb": "^3.2.6", | 14 | + "mongodb": "^3.2.7", |
15 | "slackbots": "^1.2.0" | 15 | "slackbots": "^1.2.0" |
16 | } | 16 | } |
17 | } | 17 | } | ... | ... |
-
Please register or login to post a comment