From 27c3997887d3fbaa4ff67ce5dfbaccc2454a498e Mon Sep 17 00:00:00 2001 From: Hex Date: Sun, 19 Mar 2023 12:31:28 +0800 Subject: [PATCH] update --- bot.js | 22 +++++++++++++++++++++- smzdm_checkin.js | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bot.js b/bot.js index 9d58c6f..7df0929 100644 --- a/bot.js +++ b/bot.js @@ -89,12 +89,32 @@ const requestApi = async (url, inputOptions = {}) => { return got(url, gotOptions).then((response) => { const data = options.parseJSON === false ? response.body : parseJSON(response.body); + if (options.debug) { + console.log('------------------------'); + console.log(url); + console.log('------------------------'); + console.log(JSON.stringify(gotOptions, null, 2)); + console.log('------------------------'); + console.log(options.parseJSON === false ? response.body : JSON.stringify(data, null, 2)); + console.log('------------------------'); + } + return { isSuccess: options.parseJSON === false ? true : (data.error_code == '0'), - response: options.parseJSON === false ? response.body : JSON.stringify(data), + response: options.parseJSON === false ? response.body : JSON.stringify(data, null, 2), data }; }).catch((error) => { + if (options.debug) { + console.log('------------------------'); + console.log(url); + console.log('------------------------'); + console.log(JSON.stringify(gotOptions, null, 2)); + console.log('------------------------'); + console.log(error); + console.log('------------------------'); + } + return { isSuccess: false, response: error, diff --git a/smzdm_checkin.js b/smzdm_checkin.js index 4f8d14f..f8f4a00 100644 --- a/smzdm_checkin.js +++ b/smzdm_checkin.js @@ -80,7 +80,8 @@ class SmzdmCheckinBot extends SmzdmBot { async allReward() { const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/checkin/all_reward', { method: 'post', - headers: this.getHeaders() + headers: this.getHeaders(), + debug: process.env.SMZDM_DEBUG }); if (isSuccess) {