Showing
1 changed file
with
38 additions
and
4 deletions
| ... | @@ -25,6 +25,10 @@ const getCharacterInfo = async function(nickname, characterCode) { | ... | @@ -25,6 +25,10 @@ const getCharacterInfo = async function(nickname, characterCode) { |
| 25 | throw new Error("private_character"); | 25 | throw new Error("private_character"); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | + if (resp.data.indexOf("메이플스토리 게임 점검 중에는 이용하실 수 없습니다.") >= 0) { | ||
| 29 | + throw new Error("game_checking"); | ||
| 30 | + } | ||
| 31 | + | ||
| 28 | const character = { | 32 | const character = { |
| 29 | nickname: nickname, | 33 | nickname: nickname, |
| 30 | characterCode: characterCode, | 34 | characterCode: characterCode, |
| ... | @@ -117,7 +121,12 @@ const getCharacterInfo = async function(nickname, characterCode) { | ... | @@ -117,7 +121,12 @@ const getCharacterInfo = async function(nickname, characterCode) { |
| 117 | }; | 121 | }; |
| 118 | } catch (error) { | 122 | } catch (error) { |
| 119 | console.log(error); | 123 | console.log(error); |
| 120 | - return false; | 124 | + if (error.message == "private_character") |
| 125 | + return -1; | ||
| 126 | + else if (error.message == "game_checking") | ||
| 127 | + return -2; | ||
| 128 | + else | ||
| 129 | + return -999; | ||
| 121 | } | 130 | } |
| 122 | } | 131 | } |
| 123 | 132 | ||
| ... | @@ -129,6 +138,10 @@ const analyzeEquipment = async function(nickname, characterCode, job) { | ... | @@ -129,6 +138,10 @@ const analyzeEquipment = async function(nickname, characterCode, job) { |
| 129 | throw new Error("private_character"); | 138 | throw new Error("private_character"); |
| 130 | } | 139 | } |
| 131 | 140 | ||
| 141 | + if (resp.data.indexOf("메이플스토리 게임 점검 중에는 이용하실 수 없습니다.") >= 0) { | ||
| 142 | + throw new Error("game_checking"); | ||
| 143 | + } | ||
| 144 | + | ||
| 132 | const { JSDOM } = require('jsdom'); | 145 | const { JSDOM } = require('jsdom'); |
| 133 | const dom = new JSDOM(resp.data); | 146 | const dom = new JSDOM(resp.data); |
| 134 | const $ = (require('jquery'))(dom.window); | 147 | const $ = (require('jquery'))(dom.window); |
| ... | @@ -218,7 +231,12 @@ const analyzeEquipment = async function(nickname, characterCode, job) { | ... | @@ -218,7 +231,12 @@ const analyzeEquipment = async function(nickname, characterCode, job) { |
| 218 | }; | 231 | }; |
| 219 | } catch (error) { | 232 | } catch (error) { |
| 220 | console.log(error); | 233 | console.log(error); |
| 221 | - return false; | 234 | + if (error.message == "private_character") |
| 235 | + return -1; | ||
| 236 | + else if (error.message == "game_checking") | ||
| 237 | + return -2; | ||
| 238 | + else | ||
| 239 | + return -999; | ||
| 222 | } | 240 | } |
| 223 | } | 241 | } |
| 224 | 242 | ||
| ... | @@ -378,15 +396,31 @@ module.exports = { | ... | @@ -378,15 +396,31 @@ module.exports = { |
| 378 | } | 396 | } |
| 379 | 397 | ||
| 380 | const characterInfo = await getCharacterInfo(nickname, characterCode); | 398 | const characterInfo = await getCharacterInfo(nickname, characterCode); |
| 381 | - if (!characterInfo) { | 399 | + if (characterInfo == -1) { |
| 400 | + // 접근 권한 설정 필요 | ||
| 382 | res.status(403).send(); | 401 | res.status(403).send(); |
| 383 | return; | 402 | return; |
| 403 | + } else if (characterInfo == -2) { | ||
| 404 | + // 점검중 | ||
| 405 | + res.status(503).send(); | ||
| 406 | + return; | ||
| 407 | + } else if (characterInfo < 0) { | ||
| 408 | + res.status(400).send(); | ||
| 409 | + return; | ||
| 384 | } | 410 | } |
| 385 | 411 | ||
| 386 | const analysisEquipment = await analyzeEquipment(nickname, characterCode, characterInfo.character.job); | 412 | const analysisEquipment = await analyzeEquipment(nickname, characterCode, characterInfo.character.job); |
| 387 | - if (!analysisEquipment) { | 413 | + if (analysisEquipment == -1) { |
| 414 | + // 접근 권한 설정 필요 | ||
| 388 | res.status(403).send(); | 415 | res.status(403).send(); |
| 389 | return; | 416 | return; |
| 417 | + } else if (analysisEquipment == -2) { | ||
| 418 | + // 점검중 | ||
| 419 | + res.status(503).send(); | ||
| 420 | + return; | ||
| 421 | + } else if (analysisEquipment < 0) { | ||
| 422 | + res.status(400).send(); | ||
| 423 | + return; | ||
| 390 | } | 424 | } |
| 391 | 425 | ||
| 392 | const stats = analyzeStats(characterInfo, analysisEquipment); | 426 | const stats = analyzeStats(characterInfo, analysisEquipment); | ... | ... |
-
Please register or login to post a comment