Skip to content

Commit

Permalink
docs(hugo): forward to message/topic
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Jan 31, 2024
1 parent f4d1fd0 commit 928c3b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions docs/content/en/guide/forward.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,29 @@ tdl forward --from tdl-export.json --to -
Forward to `CHAT1` if message contains `foo`, otherwise forward to `Saved Messages`:

{{< hint info >}}
You must return a string as the target CHAT, and empty string means forward to `Saved Messages`.
You must return a **string** or **struct** as the target CHAT, and empty string means forward to `Saved Messages`.
{{< /hint >}}

{{< command >}}
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : ""'
{{< /command >}}

Forward to `CHAT1` if message contains `foo`, otherwise forward to reply to message/topic `4` in `CHAT2`:

{{< command >}}
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : { Peer: "CHAT2", Thread: 4 }'
{{< /command >}}

Pass a file name if the expression is complex:

{{< details "router.txt" >}}
Write your expression like `switch`:
```
Message.Message contains "foo" ? "CHAT1" :
From.ID == 123456 ? "CHAT2" :
Message.Views > 30 ? "CHAT3" :
Message.Views > 30 ? { Peer: "CHAT3", Thread: 101 } :
""
```
{{< /details >}}
Expand Down
11 changes: 9 additions & 2 deletions docs/content/zh/guide/forward.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@ tdl forward --from tdl-export.json --to -
如果消息包含 `foo`,则转发到 `CHAT1`,否则转发到 `收藏夹`

{{< hint info >}}
表达式必须返回一个字符串作为目标 CHAT,空字符串表示转发到 `收藏夹`
表达式必须返回一个**字符串**或者**结构体**作为目标 CHAT,空字符串表示转发到 `收藏夹`
{{< /hint >}}

{{< command >}}
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : ""'
{{< /command >}}

转发含有 `foo` 的消息到 `CHAT1`,否则转发到 `CHAT2` 中 ID 为 4 的消息/主题:

{{< command >}}
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : { Peer: "CHAT2", Thread: 4 }'
{{< /command >}}

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

{{< details "router.txt" >}}
Expand All @@ -68,7 +75,7 @@ tdl forward --from tdl-export.json \
```
Message.Message contains "foo" ? "CHAT1" :
From.ID == 123456 ? "CHAT2" :
Message.Views > 30 ? "CHAT3" :
Message.Views > 30 ? { Peer: "CHAT3", Thread: 101 } :
""
```

Expand Down

0 comments on commit 928c3b3

Please sign in to comment.