오윤석

리부트 캐릭터 가져오지 못하는 오류 수정

1 axios = require('axios'); 1 axios = require('axios');
2 2
3 -const crwalCharacterCode = async function(nickname) { 3 +const crwalCharacterCode = async function(nickname, isReboot = false) {
4 try { 4 try {
5 - const resp = await axios.get("https://maplestory.nexon.com/Ranking/World/Total?c=" + encodeURI(nickname)); 5 + const resp = await axios.get("https://maplestory.nexon.com/Ranking/World/Total?c=" + encodeURI(nickname) + "&w=" + (isReboot ? "0" : "254"));
6 6
7 const regex = new RegExp(`<dt><a href=\\"\\/Common\\/Character\\/Detail\\/[^\\?]+?\\?p=(.+?)\\"\\s+target=.+?\\/>${nickname}<\\/a><\\/dt>`); 7 const regex = new RegExp(`<dt><a href=\\"\\/Common\\/Character\\/Detail\\/[^\\?]+?\\?p=(.+?)\\"\\s+target=.+?\\/>${nickname}<\\/a><\\/dt>`);
8 const regexResult = regex.exec(resp.data); 8 const regexResult = regex.exec(resp.data);
9 9
10 - if (!regexResult) 10 + if (!regexResult) {
11 - return -2; 11 + if (isReboot)
12 + return -2;
13 + else
14 + return await crwalCharacterCode(nickname, true);
15 + }
12 16
13 return regexResult[1]; 17 return regexResult[1];
14 } catch (error) { 18 } catch (error) {
......