route.js
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Tell a Chuck Norris Joke
function chuckJoke(){
axios.get('http://api.icndb.com/jokes/random/')
.then(res =>{
const joke = res.data.value.joke;
const face = {
icon_emoji: ':laughing:'
};
bot.postMessageToChannel('everyone', `Chuck Norris: ${joke}`,face);
bot.postMessageToChannel('full-stack-web', `Yo mama: ${joke}`,face);
bot.postMessageToChannel('bot_test', `Yo mama: ${joke}`,face);
});
}
// Tell a yomama Joke
function yoMamaJoke(){
axios.get('http://api.yomomma.info/')
.then(res =>{
const joke = res.data.joke;
const face = {
icon_emoji: ':laughing:'
};
bot.postMessageToChannel('everyone', `Yo mama: ${joke}`,face);
bot.postMessageToChannel('full-stack-web', `Yo mama: ${joke}`,face);
bot.postMessageToChannel('bot_test', `Yo mama: ${joke}`,face);
});
}
//Tell random joke
function randomJoke(){
const rand = Math.floor(Math.random() * 2) +1;
if(rand ===1){
chuckJoke();
}
else if(rand === 2){
yoMamaJoke();
}
}
function runHelp(){
const face = {
icon_emoji: ':question:'
};
bot.postMessageToChannel('everyone', "Type @joker and write a joke that you would like\n ex- @joker random",face);
bot.postMessageToChannel('full-stack-web', "Type @joker and write a joke that you would like\n ex- @joker random",face);
}
module.exports = route;