Forward #
Forward messages with automatic fallback and message routing
One-liner to forward messages from https://t.me/telegram/193
to Saved Messages
:
tdl forward --from https://t.me/telegram/193
Custom Source #
Message Link Examples
https://t.me/telegram/193
https://t.me/c/1697797156/151
https://t.me/iFreeKnow/45662/55005
https://t.me/c/1492447836/251015/251021
https://t.me/opencfdchannel/4434?comment=360409
https://t.me/myhostloc/1485524?thread=1485523
...
(File a new issue if you find a new link format)
You can forward messages from links and exported JSON files:
tdl forward \
--from https://t.me/telegram/193 \
--from https://t.me/telegram/195 \
--from tdl-export.json \
--from tdl-export2.json
Custom Destination #
CHAT Examples
Specific Chat #
Forward to specific one chat:
tdl forward --from tdl-export.json --to CHAT
Message Routing #
Forward to different chats by message router which is based on expression.
List all available fields:
tdl forward --from tdl-export.json --to -
Forward to CHAT1
if message contains foo
, otherwise forward to Saved Messages
:
You must return a string or struct as the target CHAT, and empty string means forward to Saved Messages
.
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : ""'
Forward to CHAT1
if message contains foo
, otherwise forward to reply to message/topic 4
in CHAT2
:
tdl forward --from tdl-export.json \
--to 'Message.Message contains "foo" ? "CHAT1" : { Peer: "CHAT2", Thread: 4 }'
Pass a file name if the expression is complex:
router.txt
Write your expression like switch
:
Message.Message contains "foo" ? "CHAT1" :
From.ID == 123456 ? "CHAT2" :
Message.Views > 30 ? { Peer: "CHAT3", Thread: 101 } :
""
tdl forward --from tdl-export.json --to router.txt
Mode #
Forward messages with automatic fallback strategy.
Available modes:
direct
(default)clone
Direct #
Prefer to use official forward API.
If the chat or message is not allowed to use official forward API, it will be automatically downgraded to clone
mode.
tdl forward --from tdl-export.json --mode direct
Clone #
Forward messages by copying them, which doesn’t have forwarded header.
Some message content can’t be copied, such as poll, invoice, etc. They will be ignored.
tdl forward --from tdl-export.json --mode clone
Edit #
Edit the message before forwarding based on expression.
- 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.
You can reference relevant fields from the original message in the expression.
List all available fields:
tdl forward --from tdl-export.json --edit -
Append Test Forwarded Message
to the original message:
tdl forward --from tdl-export.json --edit 'Message.Message + " Test Forwarded Message"'
Write styled message with HTML:
tdl forward --from tdl-export.json --edit \
'Message.Message + `<b>Bold</b> <a href="https://example.com">Link</a>`'
Pass a file name if the expression is complex:
edit.txt
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
tdl forward --from tdl-export.json --edit edit.txt
Dry Run #
Print the progress without actually sending messages, which is useful for message routing debugging.
tdl forward --from tdl-export.json --dry-run
Silent #
Send messages without notification.
tdl forward --from tdl-export.json --silent
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.
tdl forward --from tdl-export.json --single
Descending Order #
Forward messages in descending order for each source.
tdl forward --from tdl-export.json --desc