|
| 1 | +# Contributing to Watch Tower |
| 2 | + |
| 3 | +Thanks for your interest! Watch Tower is intentionally small and pluggable. |
| 4 | + |
| 5 | +## Dev setup |
| 6 | + |
| 7 | +```bash |
| 8 | +git clone https://github.com/MMTE/watch-tower.git |
| 9 | +cd watch-tower |
| 10 | +npm install |
| 11 | +cp .env.example .env # fill only the channels you want to test |
| 12 | +npm start # REST API + Telegram bot |
| 13 | +npm run mcp # MCP server over stdio |
| 14 | +npm test # smoke test (no network required) |
| 15 | +``` |
| 16 | + |
| 17 | +Node ≥ 20 is required (uses global `fetch` / `FormData`). |
| 18 | + |
| 19 | +## Adding a new channel |
| 20 | + |
| 21 | +A channel is a CommonJS module under [`src/channels/`](src/channels) that exports: |
| 22 | + |
| 23 | +```js |
| 24 | +module.exports = { |
| 25 | + name: 'mychannel', // lowercase, unique |
| 26 | + enabled: Boolean(/* env */), // computed at load time |
| 27 | + async sendMessage(text, { title, level, parse_mode } = {}) { /* ... */ }, |
| 28 | + async sendFile(filePath, { caption, filename, title, level } = {}) { /* ... */ }, |
| 29 | +}; |
| 30 | +``` |
| 31 | + |
| 32 | +Then register it in the `ALL` array in [`src/channels/index.js`](src/channels/index.js) and add its env vars to [`.env.example`](.env.example) and the channel table in [`README.md`](README.md). |
| 33 | + |
| 34 | +Guidelines: |
| 35 | + |
| 36 | +- Map the four severity levels (`info`, `warn`, `error`, `critical`) to your channel's native priority if it has one. |
| 37 | +- If your channel can't natively attach files, fall back to a textual message (see [`gotify.js`](src/channels/gotify.js)). |
| 38 | +- Throw on hard failures so the dispatcher can report them per-channel; don't swallow errors silently. |
| 39 | + |
| 40 | +## Style |
| 41 | + |
| 42 | +- Plain CommonJS, no build step. |
| 43 | +- Match the surrounding style; no linter is configured. |
| 44 | +- Keep changes small and focused. New runtime dependencies need a clear reason. |
| 45 | + |
| 46 | +## Pull requests |
| 47 | + |
| 48 | +1. Fork and branch from `main`. |
| 49 | +2. Run `npm test` before pushing. |
| 50 | +3. Update [`README.md`](README.md) and [`CHANGELOG.md`](CHANGELOG.md) when behavior changes. |
| 51 | +4. Describe what you changed and why in the PR body. |
| 52 | + |
| 53 | +## Reporting bugs |
| 54 | + |
| 55 | +Open an issue with reproduction steps, the channels involved, Node version, and any redacted error output. Please redact tokens and chat IDs. |
0 commit comments