增加重试机制&小修改

This commit is contained in:
Hex
2023-05-06 23:36:37 +08:00
parent 1d54295c6f
commit 1bfe62a621
2 changed files with 15 additions and 2 deletions

15
bot.js
View File

@@ -76,7 +76,20 @@ const requestApi = async (url, inputOptions = {}) => {
const gotOptions = { const gotOptions = {
method: options.method.toUpperCase(), method: options.method.toUpperCase(),
headers: options.headers headers: options.headers,
retry: {
limit: 2,
methods: [
'GET',
'POST'
],
statusCodes: [
],
errorCodes: [
'ECONNRESET',
'EAI_AGAIN'
]
}
}; };
if (options.method === 'get') { if (options.method === 'get') {

View File

@@ -93,7 +93,7 @@ class SmzdmCheckinBot extends SmzdmBot {
msg2 = `${data.data.normal_reward.gift.title}: ${data.data.normal_reward.gift.content_str}`; msg2 = `${data.data.normal_reward.gift.title}: ${data.data.normal_reward.gift.content_str}`;
} }
else { else {
msg2 = `${data.data.normal_reward.gift.content_str}: ${data.data.normal_reward.gift.sub_content}`; msg2 = `${data.data.normal_reward.gift.sub_content}`;
} }
$.log(`${msg1}\n${msg2}\n`); $.log(`${msg1}\n${msg2}\n`);