Skip to content

Commit 46a8993

Browse files
committed
refactor(reverse-proxy): rebase on main + address review feedback
* move TELEGRAM_API_ROOT / TELEGRAM_PROXY_SECRET in .env.example to sit next to TELEGRAM_PROXY_URL (per @grinev review) * document both env vars in README.md (table + new "Reverse Proxy" subsection with nginx example) (per @grinev review) * drop package.json `overrides.remark` block — telegram-markdown-v2 is gone from main, ERR_REQUIRE_ESM no longer reachable, override is dead * rebase config.ts / index.ts / file-download.ts / voice.ts on current main; reverse-proxy logic itself unchanged
1 parent 02557ef commit 46a8993

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

.env.example

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,26 @@ TELEGRAM_ALLOWED_USER_ID=
1212
# TELEGRAM_PROXY_URL=http://proxy.example.com:8080
1313
# TELEGRAM_PROXY_URL=
1414

15+
# Telegram Reverse-Proxy mode (optional, alternative to TELEGRAM_PROXY_URL)
16+
# For corporate networks that block api.telegram.org but allow your own server.
17+
# Point TELEGRAM_API_ROOT at an HTTPS endpoint that reverse-proxies to
18+
# https://api.telegram.org (e.g. nginx). Applied to Bot API calls AND file
19+
# downloads. TELEGRAM_PROXY_SECRET (optional) is sent as the X-Proxy-Secret
20+
# header so the reverse proxy can authorize callers. See README for an example
21+
# nginx config.
22+
# TELEGRAM_API_ROOT=https://tg-proxy.yourdomain.com
23+
# TELEGRAM_PROXY_SECRET=some-long-random-string
24+
1525
# OpenCode API URL (optional, default: http://localhost:4096)
1626
# OPENCODE_API_URL=http://localhost:4096
1727

28+
# Automatically restart a local OpenCode server when health-checks fail (default: false)
29+
# Only works when OPENCODE_API_URL points to localhost / 127.0.0.1 / ::1 / 0.0.0.0.
30+
# OPENCODE_AUTO_RESTART_ENABLED=false
31+
32+
# OpenCode health monitor interval in seconds when auto-restart is enabled (default: 300)
33+
# OPENCODE_MONITOR_INTERVAL_SEC=300
34+
1835
# OpenCode Server Authentication (optional)
1936
# OPENCODE_SERVER_USERNAME=opencode
2037
# OPENCODE_SERVER_PASSWORD=
@@ -76,6 +93,11 @@ OPENCODE_MODEL_ID=big-pickle
7693
# Hide tool file edit documents sent as .txt attachments (default: false)
7794
# HIDE_TOOL_FILE_MESSAGES=false
7895

96+
# Track background sessions in the currently selected project/worktree (default: true)
97+
# Sends short notifications when detached or non-current sessions in the current directory reply,
98+
# ask questions, or request permissions. Other projects/worktrees are not tracked.
99+
# TRACK_BACKGROUND_SESSIONS=true
100+
79101
# Assistant message formatting mode (default: markdown)
80102
# markdown = convert assistant replies to Telegram MarkdownV2
81103
# raw = show assistant replies as plain text
@@ -105,15 +127,22 @@ OPENCODE_MODEL_ID=big-pickle
105127

106128
# Text-to-Speech credentials (optional)
107129
# TTS reply behavior is controlled globally with /tts and persisted in settings.json.
108-
# Set both TTS_API_URL and TTS_API_KEY to enable audio replies.
130+
# Provider: "openai" (default) or "google".
131+
#
132+
# --- OpenAI-compatible (default) ---
133+
# Set TTS_API_URL and TTS_API_KEY to any OpenAI-compatible TTS endpoint.
109134
# TTS_API_URL=
110135
# TTS_API_KEY=
111136
# TTS_MODEL=gpt-4o-mini-tts
112137
# TTS_VOICE=alloy
113-
114-
# Reverse-proxy mode (alternative to TELEGRAM_PROXY_URL for corp networks that
115-
# block api.telegram.org but allow your own server). Point these at an nginx
116-
# that reverse-proxies to https://api.telegram.org and requires a shared secret
117-
# header. See docs for an example config.
118-
# TELEGRAM_API_ROOT=https://tg-proxy.yourdomain.com
119-
# TELEGRAM_PROXY_SECRET=some-long-random-string
138+
#
139+
# --- Google Cloud TTS ---
140+
# 1. Create a project at https://console.cloud.google.com
141+
# 2. Enable "Cloud Text-to-Speech API"
142+
# 3. Create a Service Account (IAM & Admin > Service Accounts)
143+
# with role "Cloud Text-to-Speech API User"
144+
# 4. Download the JSON key file
145+
# Free tier: 1M characters/month (WaveNet/Neural2), 4M/month (Standard voices)
146+
# TTS_PROVIDER=google
147+
# TTS_VOICE=en-US-Studio-O
148+
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grinev/opencode-telegram-bot",
3-
"version": "0.17.0",
3+
"version": "0.20.1",
44
"description": "Telegram bot client for OpenCode to run and monitor coding tasks from chat.",
55
"type": "module",
66
"main": "./dist/index.js",
@@ -51,6 +51,7 @@
5151
},
5252
"homepage": "https://github.com/grinev/opencode-telegram-bot#readme",
5353
"dependencies": {
54+
"@google-cloud/text-to-speech": "^6.4.0",
5455
"@grammyjs/menu": "^1.3.1",
5556
"@opencode-ai/sdk": "^1.1.21",
5657
"better-sqlite3": "^12.6.2",
@@ -61,7 +62,6 @@
6162
"remark-gfm": "^4.0.1",
6263
"remark-parse": "^11.0.0",
6364
"socks-proxy-agent": "^8.0.5",
64-
"telegram-markdown-v2": "^0.0.4",
6565
"unified": "^11.0.5"
6666
},
6767
"devDependencies": {
@@ -76,8 +76,5 @@
7676
"tsx": "^4.21.0",
7777
"typescript": "^5.9.3",
7878
"vitest": "^3.2.4"
79-
},
80-
"overrides": {
81-
"remark": "14.0.3"
8279
}
8380
}

0 commit comments

Comments
 (0)