-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_status.sh.example
More file actions
37 lines (30 loc) · 1.19 KB
/
send_status.sh.example
File metadata and controls
37 lines (30 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Renders vpsmon dashboard and sends it via Telegram Bot API.
# Copy this file to send_status.sh and fill in your credentials.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VPSMON="$SCRIPT_DIR/zig-out/bin/vpsmon"
OUTPUT="/tmp/vpsmon_$(date +%s).png"
# ── Configure these ──────────────────────────────────────
BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN"
CHAT_ID="YOUR_TELEGRAM_CHAT_ID"
# ─────────────────────────────────────────────────────────
# 1. Get ASCII output, escape for pango
TEXT=$("$VPSMON" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
# 2. Render to PNG (hacker green on black)
PANGO="<span font='DejaVu Sans Mono 14' foreground='#00FF41'>${TEXT}</span>"
convert \
-background black \
-density 96 \
pango:"$PANGO" \
-bordercolor black \
-border 24x16 \
"$OUTPUT"
# 3. Send via Telegram Bot API
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
-F "chat_id=${CHAT_ID}" \
-F "photo=@${OUTPUT}" \
-o /dev/null
# 4. Cleanup
rm -f "$OUTPUT"
echo "OK"