mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-25 18:33:48 +00:00
Add authenticated ntfy
This commit is contained in:
parent
34e3ab948b
commit
ed62cc90de
3 changed files with 6 additions and 2 deletions
|
@ -5,10 +5,11 @@
|
||||||
## Environment variables
|
## Environment variables
|
||||||
### Secrets
|
### Secrets
|
||||||
- `SLACK_WEBHOOK_URL` - Slack webhook to call on updates
|
- `SLACK_WEBHOOK_URL` - Slack webhook to call on updates
|
||||||
- `NTFY_URL` - URL for ntfy
|
- `NTFY_AUTH_TOKEN` - Auth token for ntfy
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
- `ARCADE_SHOP_URL` - Shop URL to fetch
|
- `ARCADE_SHOP_URL` - Shop URL to fetch
|
||||||
|
- `NTFY_URL` - URL for ntfy
|
||||||
|
|
||||||
## Tech Stack
|
## Tech Stack
|
||||||
- **Cloudflare Workers** for running the monitor on the edge.
|
- **Cloudflare Workers** for running the monitor on the edge.
|
||||||
|
|
|
@ -36,7 +36,8 @@ pub async fn scheduled(event: ScheduledEvent, env: Env, _ctx: ScheduleContext) {
|
||||||
async fn run_scrape(env: Env) -> Result<String> {
|
async fn run_scrape(env: Env) -> Result<String> {
|
||||||
let shop_url = Url::parse(&env.var("ARCADE_SHOP_URL")?.to_string())?;
|
let shop_url = Url::parse(&env.var("ARCADE_SHOP_URL")?.to_string())?;
|
||||||
let slack_webhook_url = env.secret("SLACK_WEBHOOK_URL")?.to_string();
|
let slack_webhook_url = env.secret("SLACK_WEBHOOK_URL")?.to_string();
|
||||||
let ntfy_url = env.secret("NTFY_URL")?.to_string();
|
let ntfy_url = env.var("NTFY_URL")?.to_string();
|
||||||
|
let ntfy_auth_token = env.secret("NTFY_AUTH_TOKEN")?.to_string();
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
|
|
||||||
let kv = env.kv("SHOP_ITEMS")?;
|
let kv = env.kv("SHOP_ITEMS")?;
|
||||||
|
@ -77,6 +78,7 @@ async fn run_scrape(env: Env) -> Result<String> {
|
||||||
// ntfy webhook
|
// ntfy webhook
|
||||||
client
|
client
|
||||||
.post(ntfy_url)
|
.post(ntfy_url)
|
||||||
|
.bearer_auth(ntfy_auth_token)
|
||||||
.header("X-Title", "Changes detected in Arcade Shop")
|
.header("X-Title", "Changes detected in Arcade Shop")
|
||||||
.header("X-Priority", "high")
|
.header("X-Priority", "high")
|
||||||
.body(changes)
|
.body(changes)
|
||||||
|
|
|
@ -12,6 +12,7 @@ crons = ["*/20 * * * *"] # Run every twenty minutes
|
||||||
mode = "smart"
|
mode = "smart"
|
||||||
|
|
||||||
[vars]
|
[vars]
|
||||||
|
NTFY_URL = "https://ntfy.hackclub.app/arcade-monitor"
|
||||||
ARCADE_SHOP_URL = "https://hackclub.com/arcade/shop/"
|
ARCADE_SHOP_URL = "https://hackclub.com/arcade/shop/"
|
||||||
|
|
||||||
[[kv_namespaces]]
|
[[kv_namespaces]]
|
||||||
|
|
Loading…
Reference in a new issue