Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박찬수
/
enjoy_soccer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박찬수
2022-06-09 05:04:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
94aa9ed41b7f56da349e120a4cb5f5a466ad0e97
94aa9ed4
1 parent
616ad907
all commit
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
18 deletions
getid.js
reply.js
transmessage.js
getid.js
View file @
94aa9ed
...
...
@@ -2,6 +2,7 @@ const soccerAPI = '526fc70a2e8b315e9a960ac4b4764191';
const
hostUrl
=
'v3.football.api-sports.io'
;
var
request
=
require
(
'request'
);
var
papago
=
require
(
'./transmessage.js'
);
var
sampleLeagueNum
=
'39'
;
var
sampleSeasonNum
=
'2021'
;
...
...
@@ -130,3 +131,12 @@ exports.SearchTeam = function(teamName){
return
GetTeamIDByName
(
teamName
);
}
function
SayHello
(
basic
,
trans
){
console
.
log
(
basic
+
trans
);
}
function
BasicHello
(
basic
,
trans
){
papago
.
TranslateKRtoEN
(
basic
,
function
(
transedMsg
){
SayHello
(
basic
,
transedMsg
);
});
}
\ No newline at end of file
...
...
reply.js
View file @
94aa9ed
...
...
@@ -32,7 +32,7 @@ app.post('/hook', function (req, res) {
console
.
log
(
'[request message]'
,
eventObj
.
message
);
console
.
log
(
"Receive Message : "
,
eventObj
.
message
.
text
);
SelectAPI
(
eventObj
,
message
.
text
);
SelectAPI
(
eventObj
,
eventObj
.
message
.
text
);
res
.
sendStatus
(
200
);
});
...
...
@@ -97,14 +97,16 @@ function GetPlayerInfo(playerID, season, eventObj){
}
function
SelectAPI
(
reply
Msg
){
if
(
tryParse
.
int
(
reply
Msg
)
!=
null
){
// 리그 선택
SelectLeague
(
tryParse
.
int
(
reply
Msg
));
function
SelectAPI
(
eventObj
,
comming
Msg
){
if
(
tryParse
.
int
(
comming
Msg
)
!=
null
){
// 리그 선택
SelectLeague
(
tryParse
.
int
(
comming
Msg
));
}
else
{
// 팀명 입력
console
.
log
(
papago
.
TranslateKRtoEN
(
replyMsg
));
papago
.
TranslateKRtoEN
(
commingMsg
,
function
(
transedMsg
){
Reply
(
eventObj
,
transedMsg
);
});
}
Reply
(
papago
.
TranslateKRtoEN
(
replyMsg
))
;
;
}
function
SelectLeague
(
inputNum
){
...
...
transmessage.js
View file @
94aa9ed
...
...
@@ -11,8 +11,8 @@ const HTTPS = require('https');
const
domain
=
"2018102191.osschatbot2022.tk"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
var
sampleReplyMsg
=
"players, seasons, standings, league, Son, Neymar"
;
const
{
post
}
=
require
(
'request'
);
const
req
=
require
(
'express/lib/request'
)
;
function
transMsg
(
replyMsg
){
var
language
=
"ko"
;
...
...
@@ -37,14 +37,13 @@ function transMsg(replyMsg){
return
replyMsg
;
}
var
replyMsg
=
"선수, 시즌, 순위, 리그, 손흥민, 네이마르, 1등"
function
transMsg_toEn
(
replyMsg
){
function
transMsg_toEn
(
replyMsg
,
callbackFunc
){
var
language
=
"en"
;
request
.
post
(
{
url
:
PAPAGO_URL
,
method
:
post
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
'X-Naver-Client-Id'
:
`
${
PAPAGO_ID
}
`
,
...
...
@@ -52,20 +51,20 @@ function transMsg_toEn(replyMsg){
},
body
:
'source=ko&target='
+
language
+
'&text='
+
replyMsg
,
json
:
true
},(
error
,
response
,
body
)
=>
{
},
(
error
,
response
,
body
)
=>
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
let
transMessage
=
body
.
message
.
result
.
translatedText
;
console
.
log
(
transMessage
);
return
transMessage
;
console
.
log
(
transMessage
);
callbackFunc
(
transMessage
)
;
}
});
return
replyMsg
;
}
exports
.
TranslateKRtoEN
=
function
(
transMsg
){
return
transMsg_toEn
(
transMsg
);
exports
.
TranslateKRtoEN
=
function
(
transMsg
,
callbackFunc
){
transMsg_toEn
(
transMsg
,
callbackFunc
);
}
exports
.
TranslateENtoKR
=
function
(
transMsg
){
return
transMsg
(
transMsg
);
}
\ No newline at end of file
}
...
...
Please
register
or
login
to post a comment