Skip to content

Commit

Permalink
docs(hugo): add --edit --single --desc docs (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Feb 15, 2024
1 parent 56e4812 commit 0e1ce1d
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 2 deletions.
75 changes: 74 additions & 1 deletion docs/content/en/guide/forward.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Pass a file name if the expression is complex:

{{< details "router.txt" >}}
Write your expression like `switch`:
```
```javascript
Message.Message contains "foo" ? "CHAT1" :
From.ID == 123456 ? "CHAT2" :
Message.Views > 30 ? { Peer: "CHAT3", Thread: 101 } :
Expand Down Expand Up @@ -111,6 +111,61 @@ Some message content can't be copied, such as poll, invoice, etc. They will be i
tdl forward --from tdl-export.json --mode clone
{{< /command >}}

## Edit

Edit the message before forwarding based on [expression](/reference/expr).

{{< hint info >}}
- You must pass the first message of grouped photos to edit the caption.
- You can pass any message of grouped documents to edit the corresponding comment.
{{< /hint >}}

You can reference relevant fields from the original message in the expression.

List all available fields:
{{< command >}}
tdl forward --from tdl-export.json --edit -
{{< /command >}}

Append `Test Forwarded Message` to the original message:
{{< command >}}
tdl forward --from tdl-export.json --edit 'Message.Message + " Test Forwarded Message"'
{{< /command >}}

Write styled message with [HTML](https://core.telegram.org/bots/api#html-style):
{{< command >}}
tdl forward --from tdl-export.json --edit \
'Message.Message + `<b>Bold</b> <a href="https://example.com">Link</a>`'
{{< /command >}}

Pass a file name if the expression is complex:

{{< details "edit.txt" >}}
```javascript
repeat(Message.Message, 2) + `
<a href="https://www.google.com">Google</a>
<a href="https://www.bing.com">Bing</a>
<b>bold</b>
<i>italic</i>
<code>code</code>
<tg-spoiler>spoiler</tg-spoiler>
<pre><code class="language-go">
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
</code></pre>
` + From.VisibleName
```
{{< /details >}}

{{< command >}}
tdl forward --from tdl-export.json --edit edit.txt
{{< /command >}}

## Dry Run

Print the progress without actually sending messages, which is useful for message routing debugging.
Expand All @@ -126,3 +181,21 @@ Send messages without notification.
{{< command >}}
tdl forward --from tdl-export.json --silent
{{< /command >}}

## No Grouped Detection

By default, tdl will detect grouped messages and forward them as an album.

You can disable this behavior by `--single` to forward it as a single message.

{{< command >}}
tdl forward --from tdl-export.json --single
{{< /command >}}

## Descending Order

Forward messages in descending order for each source.

{{< command >}}
tdl forward --from tdl-export.json --desc
{{< /command >}}
74 changes: 73 additions & 1 deletion docs/content/zh/guide/forward.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tdl forward --from tdl-export.json \
{{< details "router.txt" >}}
你可以像写 `switch` 一样编写表达式:

```
```javascript
Message.Message contains "foo" ? "CHAT1" :
From.ID == 123456 ? "CHAT2" :
Message.Views > 30 ? { Peer: "CHAT3", Thread: 101 } :
Expand Down Expand Up @@ -113,6 +113,61 @@ tdl forward --from tdl-export.json --mode direct
tdl forward --from tdl-export.json --mode clone
{{< /command >}}

## 编辑

使用[表达式引擎](/reference/expr)编辑转发前的消息。

{{< hint info >}}
- 你必须传递合并照片的第一条消息才能编辑标题。
- 你可以传递任何合并文档的消息以编辑相应的评论。
{{< /hint >}}

你可以在表达式中引用原始消息的相关字段。

列出所有可用字段:
{{< command >}}
tdl forward --from tdl-export.json --edit -
{{< /command >}}

在原始消息后附加 `测试转发消息`
{{< command >}}
tdl forward --from tdl-export.json --edit 'Message.Message + " 测试转发消息"'
{{< /command >}}

[HTML](https://core.telegram.org/bots/api#html-style)格式编写带有样式的消息:
{{< command >}}
tdl forward --from tdl-export.json --edit \
'Message.Message + `<b>粗体</b> <a href="https://example.com">链接</a>`'
{{< /command >}}

如果表达式较复杂,可以传递文件名:

{{< details "edit.txt" >}}
```javascript
repeat(Message.Message, 2) + `
<a href="https://www.google.com">谷歌</a>
<a href="https://www.bing.com">必应</a>
<b>粗体</b>
<i>斜体</i>
<code>代码</code>
<tg-spoiler>剧透</tg-spoiler>
<pre><code class="language-go">
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
</code></pre>
` + From.VisibleName
```
{{< /details >}}

{{< command >}}
tdl forward --from tdl-export.json --edit edit.txt
{{< /command >}}

## 试运行

只打印进度而不实际发送消息,可以用于调试消息路由的效果。
Expand All @@ -129,3 +184,20 @@ tdl forward --from tdl-export.json --dry-run
tdl forward --from tdl-export.json --silent
{{< /command >}}

## 取消分组检测

默认情况下,tdl 将自动探测到分组消息并将它们转发为合并的消息。

你可以通过 `--single` 禁用此行为,将其作为单个消息转发。

{{< command >}}
tdl forward --from tdl-export.json --single
{{< /command >}}

## 反序

对每个来源的消息进行反序转发。

{{< command >}}
tdl forward --from tdl-export.json --desc
{{< /command >}}

0 comments on commit 0e1ce1d

Please sign in to comment.