claude-telegram-mirror 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,30 +9,14 @@ Bidirectional communication between Claude Code CLI and Telegram. Control your C
9
9
 
10
10
  ## Installation
11
11
 
12
- ### Option 1: npm (Recommended)
13
-
14
12
  ```bash
15
13
  npm install -g claude-telegram-mirror
16
14
  ctm setup # Interactive setup wizard
17
15
  ```
18
16
 
19
- ### Option 2: curl installer
20
-
21
- ```bash
22
- curl -fsSL https://raw.githubusercontent.com/robertelee78/claude-telegram-mirror/master/scripts/install.sh | bash
23
- ```
24
-
25
- Or download and review first:
26
-
27
- ```bash
28
- curl -fsSL https://raw.githubusercontent.com/robertelee78/claude-telegram-mirror/master/scripts/install.sh -o install.sh
29
- less install.sh # Review the script
30
- bash install.sh
31
- ```
32
-
33
- The interactive installer will guide you through:
34
- 1. Checking prerequisites (node, npm, git, tmux, jq, nc)
35
- 2. Creating a Telegram bot via @BotFather
17
+ The setup wizard guides you through:
18
+ 1. Creating a Telegram bot via @BotFather
19
+ 2. Disabling privacy mode (critical for group messages)
36
20
  3. Setting up a supergroup with Topics
37
21
  4. Verifying bot permissions
38
22
  5. Installing hooks and the system service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-telegram-mirror",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Bidirectional Telegram integration for Claude Code CLI - monitor and control your Claude Code sessions from Telegram",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,122 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Claude Code Wrapper with Telegram Mirror
4
- # Wraps existing claude command to enable Telegram mirroring
5
- #
6
- # Usage:
7
- # claude-wrapper <original-claude-args>
8
- #
9
- # Or create aliases:
10
- # alias dsp='TELEGRAM_MIRROR=true claude-wrapper --dangerously-skip-permissions'
11
- # alias dsp-c='TELEGRAM_MIRROR=true claude-wrapper --dangerously-skip-permissions -c'
12
- #
13
-
14
- set -e
15
-
16
- # Get the directory of this script
17
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
- PACKAGE_DIR="$(dirname "$SCRIPT_DIR")"
19
-
20
- # Check if Telegram mirror is enabled
21
- TELEGRAM_ENABLED="${TELEGRAM_MIRROR:-false}"
22
-
23
- # Bridge daemon socket path
24
- SOCKET_PATH="${TELEGRAM_BRIDGE_SOCKET:-/tmp/claude-telegram-bridge.sock}"
25
-
26
- # Start bridge daemon if needed
27
- start_bridge() {
28
- if [[ ! -S "$SOCKET_PATH" ]]; then
29
- echo "🔌 Starting Telegram bridge daemon..."
30
-
31
- # Start in background
32
- if command -v node &> /dev/null && [[ -f "$PACKAGE_DIR/dist/cli.js" ]]; then
33
- node "$PACKAGE_DIR/dist/cli.js" start &
34
- BRIDGE_PID=$!
35
-
36
- # Wait for socket to be created (max 5 seconds)
37
- for i in {1..50}; do
38
- if [[ -S "$SOCKET_PATH" ]]; then
39
- echo "✅ Bridge daemon started"
40
- break
41
- fi
42
- sleep 0.1
43
- done
44
-
45
- if [[ ! -S "$SOCKET_PATH" ]]; then
46
- echo "⚠️ Bridge daemon failed to start, continuing without Telegram mirror"
47
- TELEGRAM_ENABLED="false"
48
- fi
49
- else
50
- echo "⚠️ claude-telegram-mirror not installed properly"
51
- TELEGRAM_ENABLED="false"
52
- fi
53
- fi
54
- }
55
-
56
- # Notify session start
57
- notify_start() {
58
- if [[ -S "$SOCKET_PATH" ]]; then
59
- local session_id="cli-$(date +%s)-$$"
60
- local project_dir="$(pwd)"
61
-
62
- echo "{\"type\":\"session_start\",\"sessionId\":\"$session_id\",\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"content\":\"Session started\",\"metadata\":{\"projectDir\":\"$project_dir\"}}" | \
63
- nc -U -q0 "$SOCKET_PATH" 2>/dev/null || true
64
-
65
- export TELEGRAM_SESSION_ID="$session_id"
66
- fi
67
- }
68
-
69
- # Notify session end
70
- notify_end() {
71
- if [[ -S "$SOCKET_PATH" && -n "$TELEGRAM_SESSION_ID" ]]; then
72
- echo "{\"type\":\"session_end\",\"sessionId\":\"$TELEGRAM_SESSION_ID\",\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"content\":\"Session ended\"}" | \
73
- nc -U -q0 "$SOCKET_PATH" 2>/dev/null || true
74
- fi
75
- }
76
-
77
- # Cleanup on exit
78
- cleanup() {
79
- notify_end
80
-
81
- # Kill bridge daemon if we started it
82
- if [[ -n "$BRIDGE_PID" ]]; then
83
- kill "$BRIDGE_PID" 2>/dev/null || true
84
- fi
85
- }
86
-
87
- # Main execution
88
- main() {
89
- # Find the real claude command
90
- CLAUDE_CMD=$(which claude 2>/dev/null || echo "")
91
-
92
- if [[ -z "$CLAUDE_CMD" ]]; then
93
- echo "❌ Claude CLI not found"
94
- exit 1
95
- fi
96
-
97
- # Check if this is being called as a wrapper (avoid recursion)
98
- if [[ "$CLAUDE_WRAPPER_ACTIVE" == "true" ]]; then
99
- exec "$CLAUDE_CMD" "$@"
100
- fi
101
-
102
- export CLAUDE_WRAPPER_ACTIVE="true"
103
-
104
- if [[ "$TELEGRAM_ENABLED" == "true" || "$TELEGRAM_ENABLED" == "1" ]]; then
105
- # Start bridge if needed
106
- start_bridge
107
-
108
- # Setup cleanup trap
109
- trap cleanup EXIT
110
-
111
- # Notify session start
112
- notify_start
113
-
114
- echo "📱 Telegram mirror active"
115
- echo ""
116
- fi
117
-
118
- # Execute claude with all arguments
119
- exec "$CLAUDE_CMD" "$@"
120
- }
121
-
122
- main "$@"
package/scripts/doctor.sh DELETED
@@ -1,433 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Claude Telegram Mirror - Diagnostic Script
4
- #
5
- # Usage:
6
- # ./scripts/doctor.sh
7
- # ctm doctor (if installed)
8
- #
9
- # Checks system health and helps troubleshoot issues.
10
- #
11
-
12
- # Colors (respect NO_COLOR)
13
- if [[ -z "$NO_COLOR" ]]; then
14
- GREEN='\033[0;32m'
15
- RED='\033[0;31m'
16
- YELLOW='\033[1;33m'
17
- BLUE='\033[0;34m'
18
- BOLD='\033[1m'
19
- NC='\033[0m'
20
- else
21
- GREEN=''
22
- RED=''
23
- YELLOW=''
24
- BLUE=''
25
- BOLD=''
26
- NC=''
27
- fi
28
-
29
- # Output helpers
30
- ok() { echo -e " ${GREEN}✓${NC} $1"; }
31
- fail() { echo -e " ${RED}✗${NC} $1"; ERRORS=$((ERRORS + 1)); }
32
- warn() { echo -e " ${YELLOW}⚠${NC} $1"; WARNINGS=$((WARNINGS + 1)); }
33
- info() { echo -e " ${BLUE}ℹ${NC} $1"; }
34
-
35
- # Counters
36
- ERRORS=0
37
- WARNINGS=0
38
-
39
- # Configuration paths
40
- CONFIG_DIR="$HOME/.config/claude-telegram-mirror"
41
- ENV_FILE="$HOME/.telegram-env"
42
- INSTALL_DIR="${TELEGRAM_MIRROR_INSTALL_DIR:-$HOME/.local/share/claude-telegram-mirror}"
43
- SOCKET_PATH="$CONFIG_DIR/bridge.sock"
44
- DB_PATH="$CONFIG_DIR/sessions.db"
45
- LOG_FILE="$CONFIG_DIR/hook-debug.log"
46
-
47
- # ============================================
48
- # HEADER
49
- # ============================================
50
-
51
- echo ""
52
- echo -e "${BOLD}Claude Telegram Mirror - Diagnostic Report${NC}"
53
- echo "==========================================="
54
- echo "Generated: $(date)"
55
- echo "Platform: $(uname -s) $(uname -m)"
56
- echo "User: $USER"
57
- echo ""
58
-
59
- # ============================================
60
- # 1. PREREQUISITES
61
- # ============================================
62
-
63
- echo -e "${BOLD}Prerequisites:${NC}"
64
-
65
- check_cmd() {
66
- local cmd="$1"
67
- local min_version="${2:-}"
68
-
69
- if command -v "$cmd" &>/dev/null; then
70
- local ver=$("$cmd" --version 2>&1 | head -1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1)
71
- ok "$cmd ($ver)"
72
- return 0
73
- else
74
- fail "$cmd: NOT FOUND"
75
- return 1
76
- fi
77
- }
78
-
79
- check_cmd node
80
- check_cmd npm
81
- check_cmd git
82
- check_cmd tmux
83
- check_cmd jq
84
- check_cmd nc
85
- check_cmd curl
86
-
87
- # Node version check
88
- NODE_VER=$(node -v 2>/dev/null | cut -d'v' -f2 | cut -d'.' -f1)
89
- if [[ -n "$NODE_VER" && "$NODE_VER" -lt 18 ]]; then
90
- warn "Node.js 18+ required (found v$NODE_VER)"
91
- fi
92
-
93
- echo ""
94
-
95
- # ============================================
96
- # 2. CONFIGURATION
97
- # ============================================
98
-
99
- echo -e "${BOLD}Configuration:${NC}"
100
-
101
- if [[ -f "$ENV_FILE" ]]; then
102
- ok "~/.telegram-env exists"
103
- source "$ENV_FILE"
104
-
105
- if [[ -n "$TELEGRAM_BOT_TOKEN" ]]; then
106
- # Show first 10 chars only (security)
107
- ok "TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:0:10}..."
108
- else
109
- fail "TELEGRAM_BOT_TOKEN: NOT SET"
110
- fi
111
-
112
- if [[ -n "$TELEGRAM_CHAT_ID" ]]; then
113
- ok "TELEGRAM_CHAT_ID: $TELEGRAM_CHAT_ID"
114
- if [[ ! "$TELEGRAM_CHAT_ID" =~ ^-100 ]]; then
115
- warn "Chat ID should start with -100 for supergroups"
116
- fi
117
- else
118
- fail "TELEGRAM_CHAT_ID: NOT SET"
119
- fi
120
-
121
- info "TELEGRAM_MIRROR: ${TELEGRAM_MIRROR:-false}"
122
- else
123
- fail "~/.telegram-env: NOT FOUND"
124
- info "Run installer or create manually"
125
- fi
126
-
127
- echo ""
128
-
129
- # ============================================
130
- # 3. INSTALLATION
131
- # ============================================
132
-
133
- echo -e "${BOLD}Installation:${NC}"
134
-
135
- # Check common install locations
136
- FOUND_INSTALL=""
137
- for check_dir in "$INSTALL_DIR" "/opt/claude-mobile/packages/claude-telegram-mirror" "$HOME/.local/share/claude-telegram-mirror"; do
138
- if [[ -d "$check_dir" && -f "$check_dir/package.json" ]]; then
139
- FOUND_INSTALL="$check_dir"
140
- break
141
- fi
142
- done
143
-
144
- if [[ -n "$FOUND_INSTALL" ]]; then
145
- ok "Install dir: $FOUND_INSTALL"
146
- INSTALL_DIR="$FOUND_INSTALL"
147
-
148
- if [[ -f "$INSTALL_DIR/dist/cli.js" ]]; then
149
- ok "CLI built (dist/cli.js)"
150
- else
151
- fail "CLI not built - run: npm run build"
152
- fi
153
-
154
- if [[ -f "$INSTALL_DIR/package.json" ]]; then
155
- ver=$(jq -r '.version' "$INSTALL_DIR/package.json" 2>/dev/null || echo "unknown")
156
- info "Version: $ver"
157
- fi
158
-
159
- # Check if node_modules exists
160
- if [[ -d "$INSTALL_DIR/node_modules" ]]; then
161
- ok "Dependencies installed"
162
- else
163
- fail "Dependencies missing - run: npm install"
164
- fi
165
- else
166
- fail "Not installed (checked $INSTALL_DIR)"
167
- fi
168
-
169
- # Check ctm symlink
170
- if command -v ctm &>/dev/null; then
171
- ok "ctm command available"
172
- else
173
- warn "ctm command not in PATH"
174
- info "Add ~/.local/bin to PATH or use: node $INSTALL_DIR/dist/cli.js"
175
- fi
176
-
177
- echo ""
178
-
179
- # ============================================
180
- # 4. HOOKS
181
- # ============================================
182
-
183
- echo -e "${BOLD}Hooks:${NC}"
184
-
185
- SETTINGS="$HOME/.claude/settings.json"
186
-
187
- if [[ -f "$SETTINGS" ]]; then
188
- ok "~/.claude/settings.json exists"
189
-
190
- if grep -q "telegram-hook" "$SETTINGS"; then
191
- ok "Telegram hooks configured"
192
-
193
- # Extract and check hook script path
194
- HOOK_PATH=$(grep -o '/[^"]*telegram-hook[^"]*' "$SETTINGS" | head -1)
195
- if [[ -n "$HOOK_PATH" ]]; then
196
- if [[ -f "$HOOK_PATH" ]]; then
197
- ok "Hook script exists: $HOOK_PATH"
198
- if [[ -x "$HOOK_PATH" ]]; then
199
- ok "Hook script is executable"
200
- else
201
- fail "Hook script not executable"
202
- info "Fix: chmod +x $HOOK_PATH"
203
- fi
204
- else
205
- fail "Hook script missing: $HOOK_PATH"
206
- fi
207
- fi
208
-
209
- # Check which hooks are registered
210
- for hook in PreToolUse PostToolUse Notification Stop UserPromptSubmit PreCompact; do
211
- if grep -q "\"$hook\"" "$SETTINGS"; then
212
- ok "$hook hook registered"
213
- fi
214
- done
215
- else
216
- fail "Telegram hooks not configured"
217
- info "Run: ctm install-hooks"
218
- fi
219
- else
220
- warn "No ~/.claude/settings.json found"
221
- info "Claude Code creates this on first run"
222
- fi
223
-
224
- # Check for project-level hooks that might override
225
- if [[ -n "$PWD" && -f "$PWD/.claude/settings.json" ]]; then
226
- warn "Project-level settings found in $PWD/.claude/"
227
- if grep -q "telegram-hook" "$PWD/.claude/settings.json"; then
228
- ok "Project hooks include telegram-hook"
229
- else
230
- warn "Project hooks do NOT include telegram-hook!"
231
- info "Run: ctm install-hooks --project (from project directory)"
232
- fi
233
- fi
234
-
235
- echo ""
236
-
237
- # ============================================
238
- # 5. SERVICE STATUS
239
- # ============================================
240
-
241
- echo -e "${BOLD}Service:${NC}"
242
-
243
- if [[ "$(uname -s)" == "Linux" ]]; then
244
- if systemctl --user is-active claude-telegram-mirror &>/dev/null; then
245
- ok "systemd service: RUNNING"
246
-
247
- # Get PID
248
- pid=$(systemctl --user show claude-telegram-mirror --property=MainPID --value 2>/dev/null)
249
- if [[ -n "$pid" && "$pid" != "0" ]]; then
250
- info "PID: $pid"
251
- fi
252
- elif systemctl --user is-enabled claude-telegram-mirror &>/dev/null; then
253
- warn "systemd service: ENABLED but NOT RUNNING"
254
- info "Start with: systemctl --user start claude-telegram-mirror"
255
- else
256
- info "systemd service: NOT INSTALLED"
257
- info "Install with: ctm service install"
258
- fi
259
-
260
- # Check linger (required for user services to run after logout)
261
- if loginctl show-user "$USER" 2>/dev/null | grep -q "Linger=yes"; then
262
- ok "loginctl linger: ENABLED"
263
- else
264
- warn "loginctl linger: DISABLED"
265
- info "Service won't run when logged out"
266
- info "Enable with: loginctl enable-linger $USER"
267
- fi
268
-
269
- elif [[ "$(uname -s)" == "Darwin" ]]; then
270
- if launchctl list 2>/dev/null | grep -q "claude-telegram-mirror"; then
271
- ok "launchd agent: LOADED"
272
- else
273
- info "launchd agent: NOT LOADED"
274
- info "Install with: ctm service install"
275
- fi
276
-
277
- # Check for log files
278
- if ls ~/Library/Logs/claude-telegram-mirror.*.log &>/dev/null; then
279
- ok "Log files exist in ~/Library/Logs/"
280
- fi
281
- fi
282
-
283
- echo ""
284
-
285
- # ============================================
286
- # 6. RUNTIME STATUS
287
- # ============================================
288
-
289
- echo -e "${BOLD}Runtime:${NC}"
290
-
291
- # Check socket
292
- if [[ -S "$SOCKET_PATH" ]]; then
293
- ok "Bridge socket: EXISTS"
294
- info "Daemon is running"
295
- else
296
- info "Bridge socket: NOT PRESENT"
297
- info "Daemon is not running (start with: ctm start)"
298
- fi
299
-
300
- # Check PID file
301
- PID_FILE="$CONFIG_DIR/daemon.pid"
302
- if [[ -f "$PID_FILE" ]]; then
303
- daemon_pid=$(cat "$PID_FILE")
304
- if kill -0 "$daemon_pid" 2>/dev/null; then
305
- ok "Daemon process: RUNNING (PID $daemon_pid)"
306
- else
307
- warn "Stale PID file (process $daemon_pid not running)"
308
- fi
309
- fi
310
-
311
- # Check sessions database
312
- if [[ -f "$DB_PATH" ]]; then
313
- if command -v sqlite3 &>/dev/null; then
314
- active_sessions=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM sessions WHERE status='active'" 2>/dev/null || echo "?")
315
- total_sessions=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM sessions" 2>/dev/null || echo "?")
316
- ok "Sessions DB: $active_sessions active / $total_sessions total"
317
- else
318
- ok "Sessions DB: EXISTS"
319
- info "(install sqlite3 for details)"
320
- fi
321
- else
322
- info "Sessions DB: NOT CREATED YET"
323
- fi
324
-
325
- # Check tmux sessions
326
- if command -v tmux &>/dev/null; then
327
- tmux_sessions=$(tmux list-sessions 2>/dev/null | wc -l)
328
- if [[ $tmux_sessions -gt 0 ]]; then
329
- ok "tmux sessions: $tmux_sessions active"
330
- else
331
- info "tmux sessions: NONE"
332
- fi
333
- fi
334
-
335
- echo ""
336
-
337
- # ============================================
338
- # 7. TELEGRAM API CONNECTIVITY
339
- # ============================================
340
-
341
- echo -e "${BOLD}Telegram API:${NC}"
342
-
343
- if [[ -n "$TELEGRAM_BOT_TOKEN" ]]; then
344
- RESP=$(curl -s --max-time 5 "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getMe")
345
-
346
- if echo "$RESP" | jq -e '.ok == true' &>/dev/null; then
347
- BOT_USER=$(echo "$RESP" | jq -r '.result.username')
348
- ok "Bot connected: @$BOT_USER"
349
-
350
- # Test posting permission (if chat ID is set)
351
- if [[ -n "$TELEGRAM_CHAT_ID" ]]; then
352
- # Just check if we can get chat info (doesn't spam the chat)
353
- CHAT_RESP=$(curl -s --max-time 5 "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getChat?chat_id=${TELEGRAM_CHAT_ID}")
354
-
355
- if echo "$CHAT_RESP" | jq -e '.ok == true' &>/dev/null; then
356
- CHAT_TITLE=$(echo "$CHAT_RESP" | jq -r '.result.title // "Private chat"')
357
- ok "Chat accessible: $CHAT_TITLE"
358
- else
359
- CHAT_ERR=$(echo "$CHAT_RESP" | jq -r '.description // "Unknown error"')
360
- fail "Chat error: $CHAT_ERR"
361
- info "Make sure bot is added to the group"
362
- fi
363
- fi
364
- else
365
- ERR=$(echo "$RESP" | jq -r '.description // "Connection failed"')
366
- fail "API Error: $ERR"
367
-
368
- if [[ "$ERR" == *"Unauthorized"* ]]; then
369
- info "Token may be invalid - check TELEGRAM_BOT_TOKEN"
370
- fi
371
- fi
372
- else
373
- warn "Cannot test (no token configured)"
374
- fi
375
-
376
- echo ""
377
-
378
- # ============================================
379
- # 8. RECENT LOGS
380
- # ============================================
381
-
382
- echo -e "${BOLD}Recent Logs:${NC}"
383
-
384
- if [[ -f "$LOG_FILE" ]]; then
385
- log_size=$(wc -l < "$LOG_FILE" 2>/dev/null || echo 0)
386
- info "Hook debug log: $log_size lines"
387
- echo " (last 5 entries):"
388
- tail -5 "$LOG_FILE" 2>/dev/null | sed 's/^/ /'
389
- else
390
- info "No hook debug log"
391
- info "Enable with: export TELEGRAM_HOOK_DEBUG=1"
392
- fi
393
-
394
- echo ""
395
-
396
- # Service logs
397
- if [[ "$(uname -s)" == "Linux" ]]; then
398
- if systemctl --user is-active claude-telegram-mirror &>/dev/null; then
399
- echo " (last 5 journal entries):"
400
- journalctl --user -u claude-telegram-mirror -n 5 --no-pager 2>/dev/null | sed 's/^/ /'
401
- echo ""
402
- fi
403
- elif [[ "$(uname -s)" == "Darwin" ]]; then
404
- latest_log=$(ls -t ~/Library/Logs/claude-telegram-mirror.*.log 2>/dev/null | head -1)
405
- if [[ -n "$latest_log" ]]; then
406
- echo " (last 5 lines from $latest_log):"
407
- tail -5 "$latest_log" 2>/dev/null | sed 's/^/ /'
408
- echo ""
409
- fi
410
- fi
411
-
412
- # ============================================
413
- # 9. SUMMARY
414
- # ============================================
415
-
416
- echo "==========================================="
417
-
418
- if [[ $ERRORS -eq 0 && $WARNINGS -eq 0 ]]; then
419
- echo -e "${GREEN}All checks passed!${NC}"
420
- elif [[ $ERRORS -eq 0 ]]; then
421
- echo -e "${YELLOW}$WARNINGS warning(s), no errors${NC}"
422
- else
423
- echo -e "${RED}$ERRORS error(s), $WARNINGS warning(s)${NC}"
424
- fi
425
-
426
- echo ""
427
- echo "Commands:"
428
- echo " ctm status # Daemon status"
429
- echo " ctm service status # Service status"
430
- echo " ctm config --test # Test Telegram connection"
431
- echo ""
432
-
433
- exit $ERRORS
@@ -1,39 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Global Claude Code Hooks Runner
4
- #
5
- # This script runs all global hooks and should be called from project-level settings.
6
- # It reads stdin (hook JSON) and passes it to each global hook.
7
- #
8
- # Usage in project .claude/settings.json:
9
- # "hooks": {
10
- # "UserPromptSubmit": [
11
- # { "type": "command", "command": "~/.claude/global-hooks.sh" }
12
- # ]
13
- # }
14
- #
15
-
16
- set -e
17
-
18
- # Get script directory
19
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
-
21
- # Read stdin once and store it
22
- INPUT=$(cat)
23
-
24
- # Global hooks to run (add more as needed)
25
- GLOBAL_HOOKS=(
26
- "/opt/claude-telegram-mirror/scripts/telegram-hook.sh"
27
- # Add more global hooks here:
28
- # "/path/to/another-hook.sh"
29
- )
30
-
31
- # Run each global hook, passing the same input
32
- for hook in "${GLOBAL_HOOKS[@]}"; do
33
- if [[ -x "$hook" ]]; then
34
- echo "$INPUT" | "$hook" 2>/dev/null || true
35
- fi
36
- done
37
-
38
- # Pass through the original input for downstream processing
39
- echo "$INPUT"