docs: add v1.2.0 new features documentation (#808)

- Add TG_ALLOW_USER_LANG variable to worker-vars.md (zh/en)
- Add SUBDOMAIN_FORWARD_ADDRESS_LIST with sourcePatterns docs (zh/en)
- Add /lang command and language switching docs to telegram.md (zh/en)
- Add TG_ALLOW_USER_LANG example to wrangler.toml.template

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Dream Hunter
2026-01-11 19:47:30 +08:00
committed by GitHub
parent 36f8c4b3de
commit 276093f113
5 changed files with 104 additions and 8 deletions

View File

@@ -36,6 +36,25 @@ pnpm wrangler secret put TELEGRAM_BOT_TOKEN
![telegram](/feature/telegram.png)
## Language Switching
> [!NOTE]
> This feature is available since v1.2.0
Telegram Bot supports Chinese and English switching. Users can set their language preference via the `/lang` command.
### Enable Language Switching
You need to configure `TG_ALLOW_USER_LANG = true` in worker variables to enable this feature.
### Usage
- `/lang zh` - Switch to Chinese
- `/lang en` - Switch to English
- `/lang` - View current language setting
Language preferences are saved to KV, and each user can set their preference independently.
## Mini App
Can be deployed via command line or UI interface

View File

@@ -105,10 +105,11 @@
## Telegram Bot Related Variables
| Variable Name | Type | Description | Example |
| ---------------- | ------ | --------------------------------------------------------------------------- | ------- |
| `TG_MAX_ADDRESS` | Number | Maximum number of mailboxes that can be bound to telegram bot | `5` |
| `TG_BOT_INFO` | Text | Optional, telegram BOT_INFO, predefined BOT_INFO can reduce webhook latency | `{}` |
| Variable Name | Type | Description | Example |
| -------------------- | --------- | --------------------------------------------------------------------------- | ------- |
| `TG_MAX_ADDRESS` | Number | Maximum number of mailboxes that can be bound to telegram bot | `5` |
| `TG_BOT_INFO` | Text | Optional, telegram BOT_INFO, predefined BOT_INFO can reduce webhook latency | `{}` |
| `TG_ALLOW_USER_LANG` | Text/JSON | Allow users to switch language via `/lang` command, default `false` | `true` |
> [!NOTE]
> Telegram functionality requires email parsing, free tier CPU is limited, may cause large email parsing timeout
@@ -117,6 +118,33 @@
>
> Refer to [Configure worker to use wasm for email parsing](/en/guide/feature/mail_parser_wasm_worker)
## Email Forwarding Related Variables
| Variable Name | Type | Description | Example |
| --------------------------------- | ---- | ---------------------------------------------------------------------------------------- | --------- |
| `SUBDOMAIN_FORWARD_ADDRESS_LIST` | JSON | Subdomain/rule forwarding configuration, supports filtering by domain and source regex | See below |
> [!NOTE] SUBDOMAIN_FORWARD_ADDRESS_LIST Configuration
>
> v1.2.0 added `sourcePatterns` and `sourceMatchMode` fields for filtering by sender address regex:
>
> - `domains`: Target domain list, matches all domains if empty
> - `forward`: Forward destination address
> - `sourcePatterns`: Source address regex list (optional)
> - `sourceMatchMode`: Match mode, `any` (match any, default) or `all` (match all)
>
> Regex pattern max length is 200 characters to prevent ReDoS attacks
>
> ```toml
> SUBDOMAIN_FORWARD_ADDRESS_LIST = """
> [
> {"domains":[""],"forward":"xxx1@xxx.com"},
> {"domains":["subdomain-1.domain.com","subdomain-2.domain.com"],"forward":"xxx2@xxx.com"},
> {"domains":["example.com"],"forward":"admin@xxx.com","sourcePatterns":[".*@github.com",".*@gitlab.com"],"sourceMatchMode":"any"}
> ]
> """
> ```
## Other Variables
| Variable Name | Type | Description | Example |

View File

@@ -36,6 +36,25 @@ pnpm wrangler secret put TELEGRAM_BOT_TOKEN
![telegram](/feature/telegram.png)
## 语言切换功能
> [!NOTE]
> 此功能从 v1.2.0 版本开始支持
Telegram Bot 支持中英文切换,用户可以通过 `/lang` 命令设置语言偏好。
### 启用语言切换
需要在 worker 变量中配置 `TG_ALLOW_USER_LANG = true` 才能启用此功能。
### 使用方法
- `/lang zh` - 切换为中文
- `/lang en` - 切换为英文
- `/lang` - 查看当前语言设置
语言偏好会保存到 KV 中,每个用户可以独立设置。
## Mini App
可以通过命令行部署,或者 UI 界面部署

View File

@@ -105,10 +105,11 @@
## Telegram Bot 相关变量
| 变量名 | 类型 | 说明 | 示例 |
| ---------------- | ---- | ---------------------------------------------------------------------- | ---- |
| `TG_MAX_ADDRESS` | 数字 | telegram bot 最多绑定邮箱数量 | `5` |
| `TG_BOT_INFO` | 文本 | 可不配置telegram BOT_INFO预定义的 BOT_INFO 可以降低 webhook 的延迟 | `{}` |
| 变量名 | 类型 | 说明 | 示例 |
| ------------------- | --------- | ---------------------------------------------------------------------- | ----- |
| `TG_MAX_ADDRESS` | 数字 | telegram bot 最多绑定邮箱数量 | `5` |
| `TG_BOT_INFO` | 文本 | 可不配置telegram BOT_INFO预定义的 BOT_INFO 可以降低 webhook 的延迟 | `{}` |
| `TG_ALLOW_USER_LANG`| 文本/JSON | 是否允许用户通过 `/lang` 命令切换语言,默认 `false` | `true`|
> [!NOTE]
> Telegram 功能需要解析邮件,免费版 CPU 有限,可能会导致大邮件解析超时
@@ -117,6 +118,33 @@
>
> 参考 [配置 worker 使用 wasm 解析邮件](/zh/guide/feature/mail_parser_wasm_worker)
## 邮件转发相关变量
| 变量名 | 类型 | 说明 | 示例 |
| --------------------------------- | ---- | ---------------------------------------------------------------------------------------------------------- | ------ |
| `SUBDOMAIN_FORWARD_ADDRESS_LIST` | JSON | 子域名/规则转发配置,支持按域名和来源地址正则过滤转发 | 见下方 |
> [!NOTE] SUBDOMAIN_FORWARD_ADDRESS_LIST 配置说明
>
> v1.2.0 新增 `sourcePatterns` 和 `sourceMatchMode` 字段,支持按发件人地址正则过滤转发:
>
> - `domains`: 目标域名列表,为空则匹配所有域名
> - `forward`: 转发目标地址
> - `sourcePatterns`: 来源地址正则表达式列表(可选)
> - `sourceMatchMode`: 匹配模式,`any`(任一匹配,默认) 或 `all`(全部匹配)
>
> 正则表达式最大长度 200 字符,防止 ReDoS 攻击
>
> ```toml
> SUBDOMAIN_FORWARD_ADDRESS_LIST = """
> [
> {"domains":[""],"forward":"xxx1@xxx.com"},
> {"domains":["subdomain-1.domain.com","subdomain-2.domain.com"],"forward":"xxx2@xxx.com"},
> {"domains":["example.com"],"forward":"admin@xxx.com","sourcePatterns":[".*@github.com",".*@gitlab.com"],"sourceMatchMode":"any"}
> ]
> """
> ```
## 其他变量
| 变量名 | 类型 | 说明 | 示例 |

View File

@@ -87,6 +87,8 @@ ENABLE_AUTO_REPLY = false
# TG_MAX_ADDRESS = 5
# telegram bot info, predefined bot info can reduce latency of the webhook
# TG_BOT_INFO = "{}"
# allow user to switch language via /lang command
# TG_ALLOW_USER_LANG = true
# global forward address list, if set, all emails will be forwarded to these addresses
# FORWARD_ADDRESS_LIST = ["xxx@xxx.com"]
# subdomain forward address list, if set, subdomain emails will be forwarded to these addresses