📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -33,7 +33,7 @@ macOS ships bash and curl out of the box; only `jq` typically needs installing.
|
||||
### 2. Run setup
|
||||
|
||||
```bash
|
||||
scripts/telegram.sh setup
|
||||
bash scripts/telegram.sh setup
|
||||
```
|
||||
|
||||
This walks you through pasting the token, validates it via `getMe`, and asks you to send a message to your new bot so it can discover your chat ID. Config is written to `~/.config/telegram/config` (mode 600), and a confirmation message is sent to confirm everything works.
|
||||
@@ -41,7 +41,7 @@ This walks you through pasting the token, validates it via `getMe`, and asks you
|
||||
### 3. Add more bots (optional)
|
||||
|
||||
```bash
|
||||
scripts/telegram.sh setup --bot alerts
|
||||
bash scripts/telegram.sh setup --bot alerts
|
||||
```
|
||||
|
||||
Repeat with a different `--bot NAME` for each additional bot. Named bots share the default chat ID unless you configure a different target for them.
|
||||
@@ -52,7 +52,7 @@ To send to a group or channel instead of your personal chat:
|
||||
|
||||
1. Add your bot to the group/channel
|
||||
2. Send any message in that group/channel
|
||||
3. Run `scripts/telegram.sh read --all` to see the chat ID printed alongside the message
|
||||
3. Run `bash scripts/telegram.sh read --all` to see the chat ID printed alongside the message
|
||||
4. Add `TARGET_<NAME>=<chat_id>` to `~/.config/telegram/config`, then use `--to <name>`
|
||||
|
||||
## Usage Examples
|
||||
@@ -61,43 +61,43 @@ To send to a group or channel instead of your personal chat:
|
||||
|
||||
```bash
|
||||
# Basic alert
|
||||
scripts/telegram.sh send "Deploy finished ✅"
|
||||
bash scripts/telegram.sh send "Deploy finished ✅"
|
||||
|
||||
# No notification sound
|
||||
scripts/telegram.sh send "low priority update" --silent
|
||||
bash scripts/telegram.sh send "low priority update" --silent
|
||||
|
||||
# MarkdownV2 formatting (falls back to plain text if rejected)
|
||||
scripts/telegram.sh send "*bold* alert" --format md
|
||||
bash scripts/telegram.sh send "*bold* alert" --format md
|
||||
|
||||
# HTML formatting
|
||||
scripts/telegram.sh send "<b>bold</b> alert" --format html
|
||||
bash scripts/telegram.sh send "<b>bold</b> alert" --format html
|
||||
|
||||
# Named target and named bot
|
||||
scripts/telegram.sh send "hi" --to alerts --bot work
|
||||
bash scripts/telegram.sh send "hi" --to alerts --bot work
|
||||
```
|
||||
|
||||
### Send Files
|
||||
|
||||
```bash
|
||||
# Send a document
|
||||
scripts/telegram.sh file report.pdf "Q3 report"
|
||||
bash scripts/telegram.sh file report.pdf "Q3 report"
|
||||
|
||||
# Images are auto-detected and sent as photos
|
||||
scripts/telegram.sh file screenshot.png "Build output"
|
||||
bash scripts/telegram.sh file screenshot.png "Build output"
|
||||
|
||||
# To a named target, silently
|
||||
scripts/telegram.sh file backup.zip --to alerts --silent
|
||||
bash scripts/telegram.sh file backup.zip --to alerts --silent
|
||||
```
|
||||
|
||||
### Ask and Wait for an Answer
|
||||
|
||||
```bash
|
||||
# Default Yes/No options, 5-minute timeout
|
||||
ANSWER=$(scripts/telegram.sh ask "Deploy to prod?" --options "Yes,No" --timeout 300)
|
||||
ANSWER=$(bash scripts/telegram.sh ask "Deploy to prod?" --options "Yes,No" --timeout 300)
|
||||
echo "$ANSWER"
|
||||
|
||||
# Custom options
|
||||
scripts/telegram.sh ask "Which environment?" --options "Staging,Prod,Cancel"
|
||||
bash scripts/telegram.sh ask "Which environment?" --options "Staging,Prod,Cancel"
|
||||
```
|
||||
|
||||
Exit code `0` means answered (the answer is printed to stdout); exit code `2` means the timeout was reached with no reply.
|
||||
@@ -106,13 +106,13 @@ Exit code `0` means answered (the answer is printed to stdout); exit code `2` me
|
||||
|
||||
```bash
|
||||
# New messages since the last read (advances the offset)
|
||||
scripts/telegram.sh read
|
||||
bash scripts/telegram.sh read
|
||||
|
||||
# Limit the number of messages
|
||||
scripts/telegram.sh read --limit 5
|
||||
bash scripts/telegram.sh read --limit 5
|
||||
|
||||
# Ignore the saved offset and show everything available
|
||||
scripts/telegram.sh read --all
|
||||
bash scripts/telegram.sh read --all
|
||||
```
|
||||
|
||||
Note: `ask` and `read` share the same per-bot cursor, so an `ask` consumes incoming messages that a later `read` would otherwise show.
|
||||
@@ -136,11 +136,15 @@ TELEGRAM_BOT_TOKEN=123:ABC... # default bot token
|
||||
TELEGRAM_CHAT_ID=987654321 # default chat/target
|
||||
BOT_ALERTS_TOKEN=456:DEF... # named bot: --bot alerts (add via: setup --bot alerts)
|
||||
TARGET_FAMILY=-100987... # named target: --to family (any chat/group/channel id)
|
||||
TELEGRAM_APPROVER_IDS=123456789 # default group approver user IDs (comma-separated)
|
||||
APPROVERS_FAMILY=123456789,987654321 # approvers for --to family (overrides default)
|
||||
```
|
||||
|
||||
- `TELEGRAM_BOT_TOKEN` / `TELEGRAM_CHAT_ID` — default bot token and default send target.
|
||||
- `BOT_<NAME>_TOKEN` — a named bot's token, selected with `--bot <name>` (uppercased key, e.g. `--bot alerts` → `BOT_ALERTS_TOKEN`).
|
||||
- `TARGET_<NAME>=<chat_id>` — a named send target, selected with `--to <name>` (uppercased key, e.g. `--to family` → `TARGET_FAMILY`). A numeric `--to` value is used directly as a chat ID without a lookup.
|
||||
- `TELEGRAM_APPROVER_IDS` — Telegram user IDs allowed to answer `ask` in a group target.
|
||||
- `APPROVERS_<NAME>` — target-specific group approvers (for example, `APPROVERS_FAMILY`); overrides the global allowlist for that named target.
|
||||
- `TELEGRAM_CONFIG_DIR` — overrides the config directory (default `~/.config/telegram`).
|
||||
|
||||
## Claude Code hooks (settings.json)
|
||||
@@ -151,9 +155,9 @@ Ping your phone when Claude needs input, and when it finishes:
|
||||
{
|
||||
"hooks": {
|
||||
"Notification": [{"hooks": [{"type": "command",
|
||||
"command": "~/.claude/skills/telegram/scripts/telegram.sh send \"🔔 Claude needs input in $(basename \\\"$PWD\\\")\""}]}],
|
||||
"command": "bash ~/.claude/skills/telegram/scripts/telegram.sh send \"🔔 Claude needs input in $(basename \\\"$PWD\\\")\""}]}],
|
||||
"Stop": [{"hooks": [{"type": "command",
|
||||
"command": "~/.claude/skills/telegram/scripts/telegram.sh send \"✅ Claude finished in $(basename \\\"$PWD\\\")\" --silent"}]}]
|
||||
"command": "bash ~/.claude/skills/telegram/scripts/telegram.sh send \"✅ Claude finished in $(basename \\\"$PWD\\\")\" --silent"}]}]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -161,7 +165,7 @@ Ping your phone when Claude needs input, and when it finishes:
|
||||
Approval gate in any script/automation:
|
||||
|
||||
```bash
|
||||
if [ "$(scripts/telegram.sh ask 'Deploy to prod?' --options 'Yes,No')" = "Yes" ]; then
|
||||
if [ "$(bash scripts/telegram.sh ask 'Deploy to prod?' --options 'Yes,No')" = "Yes" ]; then
|
||||
./deploy.sh
|
||||
fi
|
||||
```
|
||||
@@ -169,8 +173,11 @@ fi
|
||||
## Security Notes
|
||||
|
||||
- The bot token grants full control of the bot — anyone with it can send/receive as your bot. Treat it like a password.
|
||||
- Token-bearing API URLs are passed to curl through stdin, not exposed in curl process arguments.
|
||||
- `~/.config/telegram/config` is created with mode 600 (owner read/write only).
|
||||
- Replies and answers to `ask` are only honored from configured chat IDs — messages from strangers who find a public bot are ignored.
|
||||
- Private-chat answers are accepted only when the sender user ID equals the chat ID. Group
|
||||
targets require an explicit `TELEGRAM_APPROVER_IDS` or target-specific `APPROVERS_<NAME>`
|
||||
allowlist, and `ask` accepts button taps and text only from those user IDs.
|
||||
- By default, bots in group chats only see messages that mention them or are replies to them. To read all group messages, either make the bot an admin or disable privacy mode for it via @BotFather (`/setprivacy`).
|
||||
|
||||
## License
|
||||
|
||||
Reference in New Issue
Block a user