Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김민욱
/
Slack Jokebot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
1
Network
Create a new issue
Commits
Issue Boards
Authored by
김민욱
2019-06-05 16:37:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
15df7f3f273089ff7bd21cdfb34cda20d8e00397
15df7f3f
1 parent
c4b84c48
modify database code
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
18 deletions
Routers/route.js
joke_data/UJP8BFSNP.json
joke_data/user.json
package-lock.json
package.json
Routers/route.js
View file @
15df7f3
...
...
@@ -10,7 +10,7 @@ message_recieved = 0;
exports
.
startbot
=
()
=>
{
// Get authorization to use the slackbot
const
bot
=
new
SlackBot
({
token
:
"xoxb-651692943605-645515979745-
sqycGNiTIOZNxnly4k1BV1HO
"
,
token
:
"xoxb-651692943605-645515979745-
VInZkUepi88jyzhpps44uRyM
"
,
name
:
"jokebot"
});
...
...
@@ -142,7 +142,7 @@ function MakeJoke(message,user_channel){
var
user
=
temp
[
0
].
substring
(
2
,
temp
[
0
].
length
-
1
);
console
.
log
(
'유저 => '
+
user
);
var
path
=
'./joke_data/
'
+
user
+
'
.json'
;
var
path
=
'./joke_data/
user
.json'
;
console
.
log
(
path
);
fs
.
exists
(
path
,
function
(
exists
){
if
(
exists
){
...
...
@@ -154,8 +154,8 @@ function MakeJoke(message,user_channel){
else
{
obj
=
JSON
.
parse
(
data
);
var
length
=
obj
.
table
.
length
;
obj
.
table
.
push
({
id
:
length
+
1
,
type
:
'userjoke'
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]});
var
myobj
=
{
id
:
length
+
1
,
type
:
'userjoke'
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]};
obj
.
table
.
push
({
id
:
length
+
1
,
type
:
user
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]});
var
myobj
=
{
id
:
length
+
1
,
type
:
user
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]};
MongoClient
.
connect
(
url2
,
function
(
err
,
db
){
if
(
err
)
throw
err
;
var
dbo
=
db
.
db
(
"userdb"
);
...
...
@@ -181,8 +181,8 @@ function MakeJoke(message,user_channel){
}
else
{
console
.
log
(
"file not exists"
);
obj
.
table
.
push
({
id
:
1
,
type
:
'userjoke'
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]});
var
myobj
=
{
id
:
1
,
type
:
'userjoke'
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]};
obj
.
table
.
push
({
id
:
1
,
type
:
user
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]});
var
myobj
=
{
id
:
1
,
type
:
user
,
setup
:
msg
[
0
],
punchline
:
msg
[
1
]};
//Create database
MongoClient
.
connect
(
url2
,
{
useNewUrlParser
:
true
},
function
(
err
,
db
)
{
if
(
err
)
throw
err
;
...
...
@@ -387,7 +387,7 @@ redditJoke= (user_channel)=>{
user
.
then
(
function
(
total
){
title
=
total
.
title
;
bot
.
postMessageToChannel
(
user_channel
,
title
,
emoji
.
emojis
(
'smiliey'
));
console
.
log
(
"
질문 불려짐
"
);
console
.
log
(
"
quiz~
"
);
return
total
;
})
.
then
((
all
)
=>
{
...
...
@@ -395,7 +395,7 @@ redditJoke= (user_channel)=>{
//Use setTimeout function to delay the code execution, making sure the user reads the question first and then see the final funny joke
setTimeout
(
function
secondFunction
(){
bot
.
postMessageToChannel
(
user_channel
,
`
${
joke
}
:stuck_out_tongue_winking_eye::laughing:`
,
emoji
.
emojis
(
'laughing'
));
console
.
log
(
"
허무개그 전송~~~~~~!
"
);
console
.
log
(
"
reddit joke~~~
"
);
},
3000
);
})
client
.
close
();
...
...
joke_data/UJP8BFSNP.json
deleted
100644 → 0
View file @
c4b84c4
{
"table"
:[{
"id"
:
1
,
"type"
:
"userjoke"
,
"setup"
:
" one plus one equals?"
,
"punchline"
:
" window!!"
}]}
\ No newline at end of file
joke_data/user.json
View file @
15df7f3
{
"table"
:[{
"id"
:
1
,
"type"
:
"userjoke"
,
"setup"
:
" hello"
,
"punchline"
:
" ok"
}]}
\ No newline at end of file
{
"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
...
...
package-lock.json
View file @
15df7f3
...
...
@@ -264,18 +264,18 @@
}
},
"mongodb"
:
{
"version"
:
"3.2.
6
"
,
"resolved"
:
"https://registry.npmjs.org/mongodb/-/mongodb-3.2.
6
.tgz"
,
"integrity"
:
"sha512-
qnHc4tjEkHKemuzBq9R7ycYnhFE0Dlpt6+n6suoZp2DcDdqviQ+teloJU24fsOw/PLmr75yGk4mRx/YabjDQEQ
=="
,
"version"
:
"3.2.
7
"
,
"resolved"
:
"https://registry.npmjs.org/mongodb/-/mongodb-3.2.
7
.tgz"
,
"integrity"
:
"sha512-
2YdWrdf1PJgxcCrT1tWoL6nHuk6hCxhddAAaEh8QJL231ci4+P9FLyqopbTm2Z2sAU6mhCri+wd9r1hOcHdoMw
=="
,
"requires"
:
{
"mongodb-core"
:
"3.2.
6
"
,
"mongodb-core"
:
"3.2.
7
"
,
"safe-buffer"
:
"^5.1.2"
}
},
"mongodb-core"
:
{
"version"
:
"3.2.
6
"
,
"resolved"
:
"https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.
6
.tgz"
,
"integrity"
:
"sha512-
i+XRVjur9D0ywGF7cFebOUnALnbvMHajdNhhl3TQuopW6QDE655G8CpPeERbqSqfa3rOKEUo08lENDIiBIuAv
Q=="
,
"version"
:
"3.2.
7
"
,
"resolved"
:
"https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.
7
.tgz"
,
"integrity"
:
"sha512-
WypKdLxFNPOH/Jy6i9z47IjG2wIldA54iDZBmHMINcgKOUcWJh8og+Wix76oGd7EyYkHJKssQ2FAOw5Su/n4X
Q=="
,
"requires"
:
{
"bson"
:
"^1.1.1"
,
"require_optional"
:
"^1.0.1"
,
...
...
package.json
View file @
15df7f3
...
...
@@ -11,7 +11,7 @@
"dependencies"
:
{
"axios"
:
"^0.18.1"
,
"fs"
:
"0.0.1-security"
,
"mongodb"
:
"^3.2.
6
"
,
"mongodb"
:
"^3.2.
7
"
,
"slackbots"
:
"^1.2.0"
}
}
...
...
Please
register
or
login
to post a comment