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
co-authored by Claude Opus 4.5
parent 36f8c4b3de
commit 276093f113
5 changed files with 104 additions and 8 deletions
@@ -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
+32 -4
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 |