Skip to content

Commit 52e6463

Browse files
authored
docs(up): upload to topic (#1104)
* docs: upload to topic * docs: upload to topic * docs: upload to topic * docs: fix duplicate filter blocks * docs: align path param * docs: fix file name var name * fix * fix
1 parent 9a4066e commit 52e6463

File tree

2 files changed

+128
-16
lines changed

2 files changed

+128
-16
lines changed

docs/content/en/guide/upload.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,70 @@ Upload to custom chat.
1919

2020
{{< include "snippets/chat.md" >}}
2121

22+
### Specific Chat
23+
24+
Upload to specific one chat:
25+
2226
{{< command >}}
2327
tdl up -p /path/to/file -c CHAT
2428
{{< /command >}}
2529

30+
Upload to specific topic in a forum chat:
31+
32+
{{< command >}}
33+
tdl up -p /path/to/file -c CHAT --topic TOPIC_ID
34+
{{< /command >}}
35+
36+
### Message Routing
37+
38+
Upload to different chats by message router which is based on [expression](/reference/expr).
39+
40+
{{< hint warning >}}
41+
The `--to` flag is conflicted with the `-c/--chat` and `--topic` flags. You can only use one of them.
42+
{{< /hint >}}
43+
44+
List all available fields:
45+
46+
{{< command >}}
47+
tdl up -p /path/to/file --to -
48+
{{< /command >}}
49+
50+
Upload to `CHAT1` if MIME contains `video`, otherwise upload to `Saved Messages`:
51+
52+
{{< hint info >}}
53+
You must return a **string** or **struct** as the target CHAT, and empty string means upload to `Saved Messages`.
54+
{{< /hint >}}
55+
56+
{{< command >}}
57+
tdl up -p /path/to/file \
58+
--to 'MIME contains "video" ? "CHAT1" : ""'
59+
{{< /command >}}
60+
61+
Upload to `CHAT1` if MIME contains `video`, otherwise upload to reply to message/topic `4` in `CHAT2`:
62+
63+
{{< command >}}
64+
tdl up -p /path/to/file \
65+
--to 'MIME contains "video" ? "CHAT1" : { Peer: "CHAT2", Thread: 4 }'
66+
{{< /command >}}
67+
68+
Pass a file name if the expression is complex:
69+
70+
{{< details "router.txt" >}}
71+
Write your expression like `switch`:
72+
73+
```javascript
74+
MIME contains "video" ? "CHAT1" :
75+
FileExt contains ".mp3" ? "CHAT2" :
76+
FileName contains "chat3" > 30 ? {Peer: "CHAT3", Thread: 101} :
77+
""
78+
```
79+
80+
{{< /details >}}
81+
82+
{{< command >}}
83+
tdl up -p /path/to/file --to router.txt
84+
{{< /command >}}
85+
2686
## Custom Parameters
2787

2888
Upload with 8 threads per task, 4 concurrent tasks:
@@ -38,17 +98,17 @@ Custom caption is based on [expression](/reference/expr).
3898
List all available fields:
3999

40100
{{< command >}}
41-
tdl up -p ./downloads --caption -
101+
tdl up -p /path/to/file --caption -
42102
{{< /command >}}
43103

44104
Custom simple caption:
45105
{{< command >}}
46-
tdl up -p ./downloads --caption 'File.Name + " - uploaded by tdl"'
106+
tdl up -p /path/to/file --caption 'FileName + " - uploaded by tdl"'
47107
{{< /command >}}
48108

49109
Write styled message with [HTML](https://core.telegram.org/bots/api#html-style):
50110
{{< command >}}
51-
tdl up -p ./downloads --caption \
111+
tdl up -p /path/to/file --caption \
52112
'FileName + `<b>Bold</b> <a href="https://example.com">Link</a>`'
53113
{{< /command >}}
54114

@@ -79,15 +139,7 @@ func main() {
79139
{{< /details >}}
80140

81141
{{< command >}}
82-
tdl up -p ./downloads --caption caption.txt
83-
{{< /command >}}
84-
85-
## Filter
86-
87-
Upload files except specified extensions:
88-
89-
{{< command >}}
90-
tdl up -p /path/to/file -p /path/to/dir -e .so -e .tmp
142+
tdl up -p /path/to/file --caption caption.txt
91143
{{< /command >}}
92144

93145
## Filters

docs/content/zh/guide/upload.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,70 @@ tdl up -p /path/to/file -p /path/to/dir
1919

2020
{{< include "snippets/chat.md" >}}
2121

22+
## 指定聊天
23+
24+
上传到指定的聊天:
25+
2226
{{< command >}}
2327
tdl up -p /path/to/file -c CHAT
2428
{{< /command >}}
2529

30+
上传到论坛型聊天的指定主题:
31+
32+
{{< command >}}
33+
tdl up -p /path/to/file -c CHAT --topic TOPIC_ID
34+
{{< /command >}}
35+
36+
## 消息路由
37+
38+
通过基于[表达式](/reference/expr)的消息路由,将文件上传到不同的聊天:
39+
40+
{{< hint warning >}}
41+
`--to` 标志与 `-c/--chat``--topic` 标志冲突,只能使用其中一个。
42+
{{< /hint >}}
43+
44+
列出所有可用字段:
45+
46+
{{< command >}}
47+
tdl up -p /path/to/file --to -
48+
{{< /command >}}
49+
50+
如果 MIME 包含 `video` 则上传到 `CHAT1`,否则上传到 `收藏夹`
51+
52+
{{< hint info >}}
53+
必须返回一个字符串或结构体作为目标聊天,空字符串表示上传到 `收藏夹`
54+
{{< /hint >}}
55+
56+
{{< command >}}
57+
tdl up -p /path/to/file \
58+
--to 'MIME contains "video" ? "CHAT1" : ""'
59+
{{< /command >}}
60+
61+
如果 MIME 包含 `video` 则上传到 `CHAT1`,否则回复 `CHAT2` 的消息/主题 `4`
62+
63+
{{< command >}}
64+
tdl up -p /path/to/file \
65+
--to 'MIME contains "video" ? "CHAT1" : { Peer: "CHAT2", Thread: 4 }'
66+
{{< /command >}}
67+
68+
如果表达式较复杂,可以传递文件名:
69+
70+
{{< details "router.txt" >}}
71+
像使用 `switch` 一样编写表达式:
72+
73+
```javascript
74+
MIME contains "video" ? "CHAT1" :
75+
FileExt contains ".mp3" ? "CHAT2" :
76+
FileName contains "chat3" > 30 ? {Peer: "CHAT3", Thread: 101} :
77+
""
78+
```
79+
80+
{{< /details >}}
81+
82+
{{< command >}}
83+
tdl up -p /path/to/file --to router.txt
84+
{{< /command >}}
85+
2686
## 自定义参数
2787

2888
使用每个任务8个线程、4个并发任务上传:
@@ -38,17 +98,17 @@ tdl up -p /path/to/file -t 8 -l 4
3898
列出所有可用字段:
3999

40100
{{< command >}}
41-
tdl up -p ./downloads --caption -
101+
tdl up -p /path/to/file --caption -
42102
{{< /command >}}
43103

44104
自定义简单的标题:
45105
{{< command >}}
46-
tdl up -p ./downloads --caption 'File.Name + " - uploaded by tdl"'
106+
tdl up -p ./path/to/file --caption 'FileName + " - uploaded by tdl"'
47107
{{< /command >}}
48108

49109
[HTML](https://core.telegram.org/bots/api#html-style)格式编写带有样式的消息:
50110
{{< command >}}
51-
tdl up -p ./downloads --caption \
111+
tdl up -p /path/to/file --caption \
52112
'FileName + `<b>Bold</b> <a href="https://example.com">Link</a>`'
53113
{{< /command >}}
54114

@@ -79,7 +139,7 @@ func main() {
79139
{{< /details >}}
80140

81141
{{< command >}}
82-
tdl up -p ./downloads --caption caption.txt
142+
tdl up -p /path/to/file --caption caption.txt
83143
{{< /command >}}
84144

85145
## 过滤器

0 commit comments

Comments
 (0)