This commit is contained in:
Hex
2023-03-19 12:31:28 +08:00
parent a7b80c2054
commit 27c3997887
2 changed files with 23 additions and 2 deletions

22
bot.js
View File

@@ -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,

View File

@@ -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) {