Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Chat_Bot
/
KaKao_ChatBot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
윤준현
2018-11-27 02:36:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5cceeb5fda6d8c4c4f529e7e7142596f375bfd4c
5cceeb5f
1 parent
6743b6ba
usesettime
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
127 deletions
app.js
content.js
app.js
View file @
5cceeb5
...
...
@@ -6,7 +6,6 @@ var bodyParser = require('body-parser');
var
singer
=
require
(
'./content'
)
var
app
=
express
();
// express 객체 저장
//body-parser 미들웨어 사용
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
...
...
@@ -33,48 +32,37 @@ app.post('/message', function(req,res){
console
.
log
(
'전달받은 메시지 : '
+
msg
);
var
send
=
{};
function
delay
(){
return
new
Promise
(
function
(
resolve
,
reject
){
switch
(
msg
)
{
case
'일본'
:
send
=
{
'message'
:
{
'text'
:
'등록된 가수 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'Reol'
,
'米津玄師'
,
'yanaginagi'
,
'ヨルシカ'
,
'ダズビ'
,
'Polkadot Stingray'
,
'Aimyong'
]
}
};
break
;
case
'한국'
:
send
=
{
'message'
:
{
'text'
:
'등록된 가수 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'볼빨간 사춘기'
,
'MOT'
,
'Gukkasten'
,
'ZICO'
,
'DEAN'
,
'IU'
,
'Heize'
]
}
};
break
;
default
:
singer
.
jpSinger
(
msg
).
then
(
function
(
result
)
{
send
=
result
;
})
if
(
send
==
''
)
send
=
singer
.
krSinger
(
msg
);
break
;
}
if
(
send
){
resolve
(
send
)
}
reject
(
new
Error
(
"Request is failed"
));
});
switch
(
msg
){
case
'일본'
:
send
=
{
'message'
:
{
'text'
:
'등록된 가수 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'Reol'
,
'米津玄師'
,
'yanaginagi'
,
'ヨルシカ'
,
'ダズビ'
,
'Polkadot Stingray'
,
'Aimyong'
]
}
};
break
;
case
'한국'
:
send
=
{
'message'
:
{
'text'
:
'등록된 가수 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'볼빨간 사춘기'
,
'MOT'
,
'Gukkasten'
,
'ZICO'
,
'DEAN'
,
'IU'
,
'Heize'
]
}
};
break
;
default
:
send
=
singer
.
jpSinger
(
msg
);
if
(
send
==
''
)
send
=
singer
.
krSinger
(
msg
);
break
;
}
delay
().
then
(
function
(
result
){
console
.
log
(
result
);
res
.
json
(
result
);
})
console
.
log
(
send
);
res
.
json
(
send
);
})
\ No newline at end of file
...
...
content.js
View file @
5cceeb5
...
...
@@ -2,97 +2,88 @@ var webcrawl = require('./crawling/Reol')
function
jpSinger
(
msg
,
discography
){
var
test
;
var
discography
;
var
send
=
{};
return
new
Promise
(
function
(
resolve
,
reject
){
function
delay
(
discography
)
{
switch
(
msg
)
{
case
'Reol'
:
send
=
{
'message'
:
{
'text'
:
'이름 : Reol(れをる) \n성별 : 여성 \n생년월일 : 1993년 11월 9일 \n혈액형 : AB형'
,
'photo'
:
{
'url'
:
'https://www.reol.jp/images/profile/reol_Aphoto_2.png'
,
'width'
:
1000
,
'height'
:
667
},
'message_button'
:
{
'label'
:
'공식 홈페이지'
,
'url'
:
"https://www.reol.jp/"
}
function
delay
(
discography
){
switch
(
msg
){
case
'Reol'
:
send
=
{
'message'
:
{
'text'
:
'이름 : Reol(れをる) \n성별 : 여성 \n생년월일 : 1993년 11월 9일 \n혈액형 : AB형'
,
'photo'
:
{
'url'
:
'https://www.reol.jp/images/profile/reol_Aphoto_2.png'
,
'width'
:
1000
,
'height'
:
667
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'Reol-Discography'
]
}
};
break
;
case
'Reol-Discography'
:
console
.
log
(
discography
);
send
=
{
'message'
:
{
'text'
:
'앨범 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'a'
]
'message_button'
:
{
'label'
:
'공식 홈페이지'
,
'url'
:
"https://www.reol.jp/"
}
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'Reol-Discography'
]
}
break
;
case
'米津玄師'
:
send
=
{
'message'
:
{
'text'
:
'이름 : 米津玄師(Yonezu Kenshi) \n 성별 : 남성 \n생년월일 : 1991년 3월 10일 \n혈액형 : O형'
,
'photo'
:
{
'url'
:
'http://reissuerecords.net/rr/wp-content/uploads/flamingo_photo2.jpg'
,
'width'
:
1000
,
'height'
:
667
},
'message_button'
:
{
'label'
:
'공식 홈페이지'
,
'url'
:
"http://reissuerecords.net/"
}
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'米津玄師-Discography'
]
}
};
break
;
case
'米津玄師-Discography'
:
send
=
{
'message'
:
{
'text'
:
'Album List'
};
break
;
case
'Reol-Discography'
:
console
.
log
(
discography
);
send
=
{
'message'
:
{
'text'
:
'앨범 목록입니다.'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'a'
]
}
}
break
;
case
'米津玄師'
:
send
=
{
'message'
:
{
'text'
:
'이름 : 米津玄師(Yonezu Kenshi) \n 성별 : 남성 \n생년월일 : 1991년 3월 10일 \n혈액형 : O형'
,
'photo'
:
{
'url'
:
'http://reissuerecords.net/rr/wp-content/uploads/flamingo_photo2.jpg'
,
'width'
:
1000
,
'height'
:
667
},
keyboard
:
{
'
type'
:
'buttons
'
,
'
buttons'
:
[
'Reol'
,
'米津玄師'
,
'yanaginagi'
,
'ヨルシカ'
,
'ダズビ'
,
'Polkadot Stingray'
,
'Aimyong'
]
'message_button'
:
{
'
label'
:
'공식 홈페이지
'
,
'
url'
:
"http://reissuerecords.net/"
}
};
break
;
default
:
break
;
}
return
send
;
}
webcrawl
.
crawl_Reol
(
'https://namu.wiki/w/%EB%A0%88%EC%98%A4%EB%A3%A8/%EC%9D%8C%EB%B0%98#toc'
).
then
(
function
(
Result
)
{
discography
=
Result
;
return
function
()
{
return
Result
;
}
}).
catch
(
function
(
err
)
{
console
.
error
(
err
);
}).
then
(
function
()
{
delay
(
discography
)
})
if
(
send
)
resolve
(
send
)
reject
(
new
Error
(
"Request is failed"
));
})
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'米津玄師-Discography'
]
}
};
break
;
case
'米津玄師-Discography'
:
send
=
{
'message'
:
{
'text'
:
'Album List'
},
keyboard
:
{
'type'
:
'buttons'
,
'buttons'
:
[
'Reol'
,
'米津玄師'
,
'yanaginagi'
,
'ヨルシカ'
,
'ダズビ'
,
'Polkadot Stingray'
,
'Aimyong'
]
}
};
break
;
default
:
break
;
}
}
webcrawl
.
crawl_Reol
(
'https://namu.wiki/w/%EB%A0%88%EC%98%A4%EB%A3%A8/%EC%9D%8C%EB%B0%98#toc'
).
then
(
function
(
Result
){
discography
=
Result
;
}).
catch
(
function
(
err
){
console
.
error
(
err
);
}).
then
(
function
(){
console
.
log
(
discography
);
delay
(
discography
);
});
return
send
;
}
function
krSinger
(
msg
){
...
...
Please
register
or
login
to post a comment