박찬수

번호 고르기 기능 추가

Showing 1 changed file with 36 additions and 9 deletions
......@@ -15,6 +15,9 @@ var data = require('./getid.js');
const bodyParser = require('body-parser');
var isLeagueInfo = false;
var step = 0;
var currentLeagueID = 0;
var currentTeamID = 0;
......@@ -22,6 +25,7 @@ data.SetData();
var app = express();
app.use(bodyParser.json());
app.post('/hook', function (req, res) {
var eventObj = req.body.events[0];
......@@ -102,17 +106,28 @@ function GetPlayerInfo(playerID, season, eventObj){
function SelectAPI(eventObj, commingMsg){
if(tryParse.int(commingMsg) != null){ // 리그 선택
SelectLeague(tryParse.int(commingMsg));
Reply(eventObj, SelectLeagueInfo);
if(step == 0){
isLeagueInfo = true;
SelectLeague(tryParse.int(commingMsg));
Reply(eventObj, SelectLeagueInfoMessage());
}
else if(step == 1 && isLeagueInfo){
Reply(eventObj, SelectLeagueInfo(tryParse.int(commingMsg)));
}
else if(step == 1 && !isLeagueInfo){
Reply(eventObj, SelectTeamInfo(tryParse.int(commingMsg)));
}
}
else{ // 팀명 입력
papago.TranslateKRtoEN(commingMsg, function(transedMsg){
//Reply(eventObj, transedMsg);
currentTeamID = data.SearchTeam(transedMsg);
Reply(eventObj, SelectTeamInfo());
if(step == 0){
currentTeamID = data.SearchTeam(transedMsg);
Reply(eventObj, SelectTeamInfoMessage());
}
});
}
;
step++;
}
function SelectLeague(inputNum){
......@@ -156,12 +171,24 @@ function SelectLeague(inputNum){
return leagueID;
}
function SelectLeagueInfo(){
let msg = '1. 팀 순위 \n 2. 득점 순위 \n 3. 도움 순위';
function SelectLeagueInfo(inputNum){
return 'You Selected ' + inputNum.toString();
}
function SelectTeamInfo(inputNum){
return 'You Selected ' + inputNum.toString();
}
function DefaultSelectMessage(){
return '환영합니다.';
}
function SelectLeagueInfoMessage(){
let msg = '1. 팀 순위 \n2. 득점 순위 \n3. 도움 순위 \n4. 처음으로';
return msg;
}
function SelectTeamInfo(){
let msg = '1. 경기 일정 \n 2. 소속 선수 \n 3. 순위';
function SelectTeamInfoMessage(){
let msg = '1. 경기 일정 \n2. 소속 선수 \n3. 순위 \n4. 처음으로';
return msg;
}
\ No newline at end of file
......