# 🦞 OpenClaw Watchdog — Krilly's Fork

**Original:** [jlgrimes/openclaw-watchdog](https://github.com/jlgrimes/openclaw-watchdog)  
**Modified by:** Krilly the Crab 🦀

## What's Different?

This fork adds **Telegram** and **Gotify** notifications alongside (or instead of) Discord.

| Feature | Original | This Fork |
|---------|----------|-----------|
| Discord alerts | ✅ | ✅ (optional) |
| Telegram alerts | ❌ | ✅ |
| Gotify alerts | ❌ | ✅ |
| Multi-channel | ❌ | ✅ (simultaneous) |

## Quick Install

```bash
git clone https://github.com/jlgrimes/openclaw-watchdog.git
cd openclaw-watchdog
chmod +x setup.sh watchdog.sh
./setup.sh
```

The installer will ask for:
- Telegram Bot Token
- Gotify Token
- Gotify URL (defaults to your setup)

## Configuration

Edit `~/.openclaw/watchdog.env`:

```bash
# Required for Telegram
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT=1793951355

# Required for Gotify
GOTIFY_URL=http://runtipi.kangaroo-eel.ts.net:8129
GOTIFY_TOKEN=your_gotify_token_here

# Optional: Legacy Discord
DISCORD_CHANNEL_ID=
DISCORD_BOT_TOKEN=
```

All three can work simultaneously — get alerts wherever you want!

## How It Works

Same great watchdog behavior from the original:

1. **Health checks** every 30s (configurable)
2. **Stage 1:** Simple restart on first failure
3. **Stage 2:** Config rollback + restart on second failure
4. **Stage 3:** SOS alert after 3+ failures
5. **Recovery:** Notification when gateway comes back

But now alerts go to **Telegram** and **Gotify** too!

## Managing the Service

```bash
sudo systemctl status openclaw-watchdog   # Check status
sudo systemctl restart openclaw-watchdog  # Restart
sudo systemctl stop openclaw-watchdog     # Stop
tail -f ~/.openclaw/watchdog.log          # View logs
```

## Test Notifications

```bash
export TELEGRAM_BOT_TOKEN="your_token"
export TELEGRAM_CHAT="1793951355"
export GOTIFY_TOKEN="your_token"

# Source the functions and test
source ~/.openclaw/watchdog.sh
telegram_send "🦀 Test message from Krilly!"
gotify_send "Test" "🦀 Test message from Krilly!" 5
```

## Credits

- **Original:** Jared Grimes and Claw 🦞
- **Fork modifications:** Krilly the Crab for Anthony Martin
- **License:** MIT

---

*Part of the Krilly Automation Stack* 🦀
