Showing
1 changed file
with
34 additions
and
7 deletions
| ... | @@ -15,6 +15,9 @@ var data = require('./getid.js'); | ... | @@ -15,6 +15,9 @@ var data = require('./getid.js'); |
| 15 | 15 | ||
| 16 | const bodyParser = require('body-parser'); | 16 | const bodyParser = require('body-parser'); |
| 17 | 17 | ||
| 18 | +var isLeagueInfo = false; | ||
| 19 | +var step = 0; | ||
| 20 | + | ||
| 18 | var currentLeagueID = 0; | 21 | var currentLeagueID = 0; |
| 19 | var currentTeamID = 0; | 22 | var currentTeamID = 0; |
| 20 | 23 | ||
| ... | @@ -22,6 +25,7 @@ data.SetData(); | ... | @@ -22,6 +25,7 @@ data.SetData(); |
| 22 | 25 | ||
| 23 | var app = express(); | 26 | var app = express(); |
| 24 | app.use(bodyParser.json()); | 27 | app.use(bodyParser.json()); |
| 28 | + | ||
| 25 | app.post('/hook', function (req, res) { | 29 | app.post('/hook', function (req, res) { |
| 26 | 30 | ||
| 27 | var eventObj = req.body.events[0]; | 31 | var eventObj = req.body.events[0]; |
| ... | @@ -102,17 +106,28 @@ function GetPlayerInfo(playerID, season, eventObj){ | ... | @@ -102,17 +106,28 @@ function GetPlayerInfo(playerID, season, eventObj){ |
| 102 | 106 | ||
| 103 | function SelectAPI(eventObj, commingMsg){ | 107 | function SelectAPI(eventObj, commingMsg){ |
| 104 | if(tryParse.int(commingMsg) != null){ // 리그 선택 | 108 | if(tryParse.int(commingMsg) != null){ // 리그 선택 |
| 109 | + if(step == 0){ | ||
| 110 | + isLeagueInfo = true; | ||
| 105 | SelectLeague(tryParse.int(commingMsg)); | 111 | SelectLeague(tryParse.int(commingMsg)); |
| 106 | - Reply(eventObj, SelectLeagueInfo); | 112 | + Reply(eventObj, SelectLeagueInfoMessage()); |
| 113 | + } | ||
| 114 | + else if(step == 1 && isLeagueInfo){ | ||
| 115 | + Reply(eventObj, SelectLeagueInfo(tryParse.int(commingMsg))); | ||
| 116 | + } | ||
| 117 | + else if(step == 1 && !isLeagueInfo){ | ||
| 118 | + Reply(eventObj, SelectTeamInfo(tryParse.int(commingMsg))); | ||
| 119 | + } | ||
| 107 | } | 120 | } |
| 108 | else{ // 팀명 입력 | 121 | else{ // 팀명 입력 |
| 109 | papago.TranslateKRtoEN(commingMsg, function(transedMsg){ | 122 | papago.TranslateKRtoEN(commingMsg, function(transedMsg){ |
| 110 | //Reply(eventObj, transedMsg); | 123 | //Reply(eventObj, transedMsg); |
| 124 | + if(step == 0){ | ||
| 111 | currentTeamID = data.SearchTeam(transedMsg); | 125 | currentTeamID = data.SearchTeam(transedMsg); |
| 112 | - Reply(eventObj, SelectTeamInfo()); | 126 | + Reply(eventObj, SelectTeamInfoMessage()); |
| 127 | + } | ||
| 113 | }); | 128 | }); |
| 114 | } | 129 | } |
| 115 | - ; | 130 | + step++; |
| 116 | } | 131 | } |
| 117 | 132 | ||
| 118 | function SelectLeague(inputNum){ | 133 | function SelectLeague(inputNum){ |
| ... | @@ -156,12 +171,24 @@ function SelectLeague(inputNum){ | ... | @@ -156,12 +171,24 @@ function SelectLeague(inputNum){ |
| 156 | return leagueID; | 171 | return leagueID; |
| 157 | } | 172 | } |
| 158 | 173 | ||
| 159 | -function SelectLeagueInfo(){ | 174 | +function SelectLeagueInfo(inputNum){ |
| 160 | - let msg = '1. 팀 순위 \n 2. 득점 순위 \n 3. 도움 순위'; | 175 | + return 'You Selected ' + inputNum.toString(); |
| 176 | +} | ||
| 177 | + | ||
| 178 | +function SelectTeamInfo(inputNum){ | ||
| 179 | + return 'You Selected ' + inputNum.toString(); | ||
| 180 | +} | ||
| 181 | + | ||
| 182 | +function DefaultSelectMessage(){ | ||
| 183 | + return '환영합니다.'; | ||
| 184 | +} | ||
| 185 | + | ||
| 186 | +function SelectLeagueInfoMessage(){ | ||
| 187 | + let msg = '1. 팀 순위 \n2. 득점 순위 \n3. 도움 순위 \n4. 처음으로'; | ||
| 161 | return msg; | 188 | return msg; |
| 162 | } | 189 | } |
| 163 | 190 | ||
| 164 | -function SelectTeamInfo(){ | 191 | +function SelectTeamInfoMessage(){ |
| 165 | - let msg = '1. 경기 일정 \n 2. 소속 선수 \n 3. 순위'; | 192 | + let msg = '1. 경기 일정 \n2. 소속 선수 \n3. 순위 \n4. 처음으로'; |
| 166 | return msg; | 193 | return msg; |
| 167 | } | 194 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment