mirror of
https://github.com/hex-ci/smzdm_script.git
synced 2026-02-02 18:48:52 +08:00
update
This commit is contained in:
22
bot.js
22
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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user