Showing
1 changed file
with
66 additions
and
18 deletions
... | @@ -14,9 +14,8 @@ exports.startbot = ()=>{ | ... | @@ -14,9 +14,8 @@ exports.startbot = ()=>{ |
14 | // Start the slackbot | 14 | // Start the slackbot |
15 | bot.on('start', () =>{ | 15 | bot.on('start', () =>{ |
16 | const face = { | 16 | const face = { |
17 | - icon_emoji: ':laughing:' | 17 | + icon_emoji: ':bowtie:' |
18 | }; | 18 | }; |
19 | - | ||
20 | bot.postMessageToChannel('everyone', 'Have some fun with @Joker!\nFor commands write @joker help' | 19 | bot.postMessageToChannel('everyone', 'Have some fun with @Joker!\nFor commands write @joker help' |
21 | , face); | 20 | , face); |
22 | }); | 21 | }); |
... | @@ -28,31 +27,71 @@ bot.on('message', (data) => { | ... | @@ -28,31 +27,71 @@ bot.on('message', (data) => { |
28 | if(data.type !== 'message'){ | 27 | if(data.type !== 'message'){ |
29 | return; | 28 | return; |
30 | } | 29 | } |
30 | + | ||
31 | console.log(data); | 31 | console.log(data); |
32 | - handleMessage(data.text); | 32 | + handleMessage(data.text, data.channel, data.user); |
33 | }); | 33 | }); |
34 | 34 | ||
35 | 35 | ||
36 | // Responding to Data | 36 | // Responding to Data |
37 | -function handleMessage(message){ | 37 | +function handleMessage(message, channel, user){ |
38 | + console.log(message); | ||
39 | + console.log(channel); | ||
40 | + console.log(user); | ||
38 | 41 | ||
39 | - if(message.includes(' knockknock')){ | 42 | + if(message === `${user} hi`) |
40 | - knockknockJoke(); | 43 | + bot.postMessageToChannel('everyone', "Tell you what??? :nomouth:", embarrased); |
41 | - } | 44 | + if(message.includes(' tell me')){ |
42 | - else if(message.includes(' general')){ | 45 | + if(message.includes(' knock')){ |
43 | - generalJoke(); | 46 | + knockknockJoke(); |
44 | - } | 47 | + } |
48 | + else if(message.includes(' general')){ | ||
49 | + generalJoke(); | ||
50 | + } | ||
45 | 51 | ||
46 | - else if(message.includes(' random')){ | 52 | + else if(message.includes(' random')){ |
47 | - console.log(message); | 53 | + console.log(message); |
48 | - randomJoke(); | 54 | + randomJoke(); |
49 | - } | 55 | + } |
50 | 56 | ||
51 | - else if(message.includes(' programming')){ | 57 | + else if(message.includes(' programming')){ |
52 | - programmingJoke(); | 58 | + programmingJoke(); |
59 | + } | ||
60 | + else if(message.includes(' me ')){ | ||
61 | + bot.postMessageToChannel('everyone', "Tell you what??? :nomouth:", embarrased); | ||
62 | + } | ||
63 | + else{ | ||
64 | + const embarrased = { | ||
65 | + icon_emoji: ':flushed:' | ||
66 | + }; | ||
67 | + comment = "Sorry I dont' have that kind of joke.....:droplet::droplet::droplet:\nPlease use @joker --help to know what I can do!"; | ||
68 | + bot.postMessageToChannel('everyone', comment, embarrased); | ||
69 | + | ||
70 | + } | ||
71 | + | ||
53 | } | 72 | } |
54 | else if(message.includes(' help')){ | 73 | else if(message.includes(' help')){ |
74 | + | ||
75 | + } | ||
76 | + else if(message.includes(' what jokes' || ' What jokes' || ' which jokes')){ | ||
77 | + jokeTypes = ["general", 'programming', 'knock-knock']; | ||
78 | + const face = { | ||
79 | + icon_emoji: ':thumbsup:' | ||
80 | + }; | ||
81 | + bot.postMessageToChannel("everyone", `I have ${jokeTypes[0]}, ${jokeTypes[1]}, ${jokeTypes[2]} jokes!! :thumbsup: :thumbsup:`, face); | ||
82 | + return; | ||
55 | } | 83 | } |
84 | + // else{ | ||
85 | + // const embarrased = { | ||
86 | + // icon_emoji: ':flushed:' | ||
87 | + // }; | ||
88 | + // const sweat = { | ||
89 | + // icon_emoji: ':droplet:' | ||
90 | + // }; | ||
91 | + // comment = "Sorry I'm not smart enough to understand this.....\nPlease use @joker help to know what I can do!"; | ||
92 | + // bot.postMessageToChannel('everyone', comment, embarrased); | ||
93 | + | ||
94 | + // } | ||
56 | } | 95 | } |
57 | randomJoke= ()=>{ | 96 | randomJoke= ()=>{ |
58 | MongoClient.connect('mongodb://localhost:27017', function (err, client){ | 97 | MongoClient.connect('mongodb://localhost:27017', function (err, client){ |
... | @@ -96,7 +135,7 @@ randomJoke= ()=>{ | ... | @@ -96,7 +135,7 @@ randomJoke= ()=>{ |
96 | icon_emoji: ':laughing:' | 135 | icon_emoji: ':laughing:' |
97 | }; | 136 | }; |
98 | function secondFunction(channel){ | 137 | function secondFunction(channel){ |
99 | - bot.postMessageToChannel(channel, joke, face); | 138 | + setTimeout(bot.postMessageToChannel(channel, joke, face, 7000)); |
100 | console.log( "허무개그 전송~~~~!") | 139 | console.log( "허무개그 전송~~~~!") |
101 | } | 140 | } |
102 | secondFunction('everyone'); | 141 | secondFunction('everyone'); |
... | @@ -256,6 +295,15 @@ knockknockJoke= ()=>{ | ... | @@ -256,6 +295,15 @@ knockknockJoke= ()=>{ |
256 | client.close(); | 295 | client.close(); |
257 | }) | 296 | }) |
258 | } | 297 | } |
298 | +runHelp = () =>{ | ||
299 | + function runhelp(){ | ||
300 | + const face = { | ||
301 | + icon_emoji: ':question:' | ||
302 | + }; | ||
303 | + comment = "Thanks for using Joker bot!:ghost::ghost:laugh:\nBot info: type '@joker --help'\nBot functions: @joker tell me [something] " | ||
304 | + bot.postMessageToChannel('everyone', "Type @joker and write a joke that you would like\n ex- @joker random",face); | ||
305 | + } | ||
306 | +} | ||
259 | } | 307 | } |
260 | 308 | ||
261 | 309 | ||
... | @@ -302,4 +350,4 @@ knockknockJoke= ()=>{ | ... | @@ -302,4 +350,4 @@ knockknockJoke= ()=>{ |
302 | 350 | ||
303 | // bot.postMessageToChannel('everyone', "Type @joker and write a joke that you would like\n ex- @joker random",face); | 351 | // bot.postMessageToChannel('everyone', "Type @joker and write a joke that you would like\n ex- @joker random",face); |
304 | // bot.postMessageToChannel('full-stack-web', "Type @joker and write a joke that you would like\n ex- @joker random",face); | 352 | // bot.postMessageToChannel('full-stack-web', "Type @joker and write a joke that you would like\n ex- @joker random",face); |
305 | - // }; | 353 | + // } | ... | ... |
-
Please register or login to post a comment