mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-25 18:33:48 +00:00
Add priorities and titles
This commit is contained in:
parent
5a27d3f38c
commit
b540641175
1 changed files with 8 additions and 9 deletions
17
src/lib.rs
17
src/lib.rs
|
@ -58,18 +58,15 @@ async fn run_scrape(env: Env) -> Result<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are any updates/new items, send a message to the Slack webhook.
|
// If there are any updates/new items, send a message to the Slack webhook.
|
||||||
let message = formatdoc! {
|
let changes = result.join("\n\n");
|
||||||
|
let slack_message = formatdoc! {
|
||||||
"*Changes detected in the shop:*
|
"*Changes detected in the shop:*
|
||||||
|
|
||||||
{changes}",
|
{changes}"
|
||||||
changes = result.join("\n\n"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let message_for_slack = message.to_owned();
|
|
||||||
let message_for_ntfy = message.to_owned();
|
|
||||||
|
|
||||||
// slack webhook
|
// slack webhook
|
||||||
let body = &json!({ "text": message_for_slack });
|
let body = &json!({ "text": slack_message });
|
||||||
client
|
client
|
||||||
.post(&slack_webhook_url)
|
.post(&slack_webhook_url)
|
||||||
.body(body.to_string())
|
.body(body.to_string())
|
||||||
|
@ -80,7 +77,9 @@ async fn run_scrape(env: Env) -> Result<String> {
|
||||||
// ntfy webhook
|
// ntfy webhook
|
||||||
client
|
client
|
||||||
.post(ntfy_url)
|
.post(ntfy_url)
|
||||||
.body(message_for_ntfy)
|
.header("X-Title", "Changes detected in Arcade Shop")
|
||||||
|
.header("X-Priority", "high")
|
||||||
|
.body(changes)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -88,7 +87,7 @@ async fn run_scrape(env: Env) -> Result<String> {
|
||||||
// Now, let's persist the items to the KV store.
|
// Now, let's persist the items to the KV store.
|
||||||
kv.put("items", &available_items)?.execute().await?;
|
kv.put("items", &available_items)?.execute().await?;
|
||||||
|
|
||||||
Ok(message)
|
Ok(slack_message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff_old_new_items(old_items: &ShopItems, new_items: &ShopItems) -> Vec<String> {
|
fn diff_old_new_items(old_items: &ShopItems, new_items: &ShopItems) -> Vec<String> {
|
||||||
|
|
Loading…
Reference in a new issue