forked from ChrisChrome/weather-bot
Maybe a fix to ntfy being silly
This commit is contained in:
parent
585c075072
commit
e30af0143d
22
index.js
22
index.js
|
@ -349,6 +349,28 @@ xmpp.on("stanza", (stanza) => {
|
||||||
}
|
}
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} NTFY sent for ${config.ntfy.prefix}${fromChannel} with status ${res.status}`);
|
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} NTFY sent for ${config.ntfy.prefix}${fromChannel} with status ${res.status}`);
|
||||||
|
if (res.status === 429) {// Rate limited, wait 5 seconds then try again
|
||||||
|
setTimeout(() => {
|
||||||
|
ntfyBody = {
|
||||||
|
"topic": `${config.ntfy.prefix}${fromChannel}`,
|
||||||
|
"message": bodyData.string,
|
||||||
|
"tags": [`Timestamp: ${product_id.timestamp}`, `Station: ${product_id.station}`, `WMO: ${product_id.wmo}`, `PIL: ${product_id.pil}`, `Channel: ${fromChannel}`],
|
||||||
|
"priority": evt.priority,
|
||||||
|
"actions": [{ "action": "view", "label": "Product", "url": bodyData.url }, { "action": "view", "label": "Product Text", "url": `https://mesonet.agron.iastate.edu/api/1/nwstext/${product_id_raw}` }]
|
||||||
|
}
|
||||||
|
if (stanza.getChild("x").attrs.twitter_media) {
|
||||||
|
ntfyBody.attach = stanza.getChild("x").attrs.twitter_media;
|
||||||
|
}
|
||||||
|
fetch(config.ntfy.server, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(ntfyBody),
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${config.ntfy.token}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|
Loading…
Reference in a new issue