Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김연준
/
TeamProject
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
김연준
2019-05-24 14:38:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b4f7680f064708aaca748eb9f43f34172aabce9
5b4f7680
1 parent
e74d0761
Adding REAME.md for project description
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
README.md
Routers/route.js
README.md
0 → 100644
View file @
5b4f768
<h1>
Building a Slackbot
</h1><br>
<h2>
A slackbot that reacts to user's chat
</h2><br>
Routers/route.js
View file @
5b4f768
// 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
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment