박찬수

팀 순위 답변기능 추가

Showing 1 changed file with 11 additions and 1 deletions
...@@ -12,6 +12,7 @@ const domain = "2018102191.osschatbot2022.tk" ...@@ -12,6 +12,7 @@ const domain = "2018102191.osschatbot2022.tk"
12 const sslport = 23023; 12 const sslport = 23023;
13 13
14 var data = require('./getid.js'); 14 var data = require('./getid.js');
15 +var soccerAPI = require('./appfunctions.js');
15 16
16 const bodyParser = require('body-parser'); 17 const bodyParser = require('body-parser');
17 18
...@@ -170,9 +171,14 @@ function SelectLeague(inputNum){ ...@@ -170,9 +171,14 @@ function SelectLeague(inputNum){
170 } 171 }
171 172
172 function SelectLeagueInfo(inputNum){ 173 function SelectLeagueInfo(inputNum){
173 - let returnMsg = "잘 못 고르습니다. 다시 골라주세요." 174 + let returnMsg = "잘 못 고르습니다. 다시 골라주세요."
174 switch(inputNum){ 175 switch(inputNum){
175 case 1: // 팀 순위 176 case 1: // 팀 순위
177 + soccerAPI.LeagueStanding(currentLeagueID, function(body){
178 + let standingJson = JSON.parse(body);
179 + returnMsg = MakeReplyMessage('팀 순위', '순위|팀명|경기|득점|승리|무승부|패배|득점|??',
180 + (standingJson.response[0].league.standings[0][i].rank + "|" + standingJson.response[0].league.standings[0][i].team.name + "|" + standingJson.response[0].league.standings[0][i].all.played + "|" + standingJson.response[0].league.standings[0][i].points + "|" + standingJson.response[0].league.standings[0][i].all.win + "|" + standingJson.response[0].league.standings[0][i].all.draw + "|" + standingJson.response[0].league.standings[0][i].all.lose + "|" + standingJson.response[0].league.standings[0][i].all.goals.for + "|" + standingJson.response[0].league.standings[0][i].all.goals.against));
181 + });
176 break; 182 break;
177 case 2: // 득점 순위 183 case 2: // 득점 순위
178 break; 184 break;
...@@ -186,6 +192,10 @@ function SelectLeagueInfo(inputNum){ ...@@ -186,6 +192,10 @@ function SelectLeagueInfo(inputNum){
186 return returnMsg; 192 return returnMsg;
187 } 193 }
188 194
195 +function MakeReplyMessage(title, keys, values){
196 + return title + '\n' + keys + '\n' + values;
197 +}
198 +
189 function SelectTeamInfo(inputNum){ 199 function SelectTeamInfo(inputNum){
190 return 'You Selected ' + inputNum.toString(); 200 return 'You Selected ' + inputNum.toString();
191 } 201 }
......