Telegram-Forwarder (UNIX-way)
For Ubuntu 18.04
$ sudo apt-get install build-essential gperf ccache zlib1g-dev libssl-dev libreadline-dev
Or use TDLib build instructions
Register an application to obtain an api_id and api_hash
BUDVA32_API_ID=1234567
BUDVA32_API_HASH=XXXXXXXX
BUDVA32_PHONENUMBER=78901234567
BUDVA32_PORT=4004
# escape markdown '\*\_\{\}\[\]\(\)\#\+\-\.\!'
ReplaceMyselfLinks: # for destinations
-2222:
DeleteExternal: true
ReplaceFragments: # for destinations
-2222:
"aaaa": "bbbb" # must be equal length
Sources:
-1234:
Sign:
Title: '*\#Source*' # for SendCopy (with markdown)
For: [-8888]
Link:
Title: "*Source*" # for SendCopy (with markdown)
For: [-4321]
Reports:
Template: "За *24 часа* отобрал: *%d* из *%d* 😎\n\\#ForwarderStats" # (with markdown)
For: [
-2222,
-4321,
-8888,
]
Forwards:
"id1":
From: -1111
To: [-2222]
"id2":
From: -1234
To: [-4321, -8888]
SendCopy: true
CopyOnce: true # wo edit-sync
Indelible: true # wo delete-sync
Exclude: 'Крамер|#УТРЕННИЙ_ОБЗОР'
Include: '#ARK|#Идеи_покупок|#ОТЧЕТЫ'
IncludeSubmatch:
- Regexp: '(^|[^A-Z])\$([A-Z]+)'
Group: 2
Match: ['F', 'GM', 'TSLA']
Other: -4444 # after include (copy only)
Check: -7777 # after exclude (forward only)
https://localhost:4004?limit=10
func getMessageLink(srcChatId, srcMessageId int) {
src, err := tdlibClient.GetMessage(&client.GetMessageRequest{
ChatId: int64(srcChatId),
MessageId: int64(srcMessageId),
})
if err != nil {
fmt.Print("GetMessage src ", err)
} else {
messageLink, err := tdlibClient.GetMessageLink(&client.GetMessageLinkRequest{
ChatId: src.ChatId,
MessageId: src.Id,
ForAlbum: src.MediaAlbumId != 0,
ForComment: false,
})
if err != nil {
fmt.Print("GetMessageLink ", err)
} else {
fmt.Print(messageLink.Link)
}
}
}
// How to use update?
for update := range listener.Updates {
if update.GetClass() == client.ClassUpdate {
if updateNewMessage, ok := update.(*client.UpdateNewMessage); ok {
//
}
}
}
// etc
// https://github.com/zelenin/go-tdlib/blob/ec36320d03ff5c891bb45be1c14317c195eeadb9/client/type.go#L1028-L1108
// How to use markdown?
formattedText, err := tdlibClient.ParseTextEntities(&client.ParseTextEntitiesRequest{
Text: "*bold* _italic_ `code`",
ParseMode: &client.TextParseModeMarkdown{
Version: 2,
},
})
if err != nil {
log.Print(err)
} else {
log.Printf("%#v", formattedText)
}
// How to add InlineKeyboardButton
row := make([]*client.InlineKeyboardButton, 0)
row = append(row, &client.InlineKeyboardButton{
Text: "1234",
Type: &client.InlineKeyboardButtonTypeUrl{
Url: "https://google.com",
},
})
rows := make([][]*client.InlineKeyboardButton, 0)
rows = append(rows, row)
_, err := tdlibClient.SendMessage(&client.SendMessageRequest{
ChatId: dstChatId,
InputMessageContent: &client.InputMessageText{
Text: formattedText,
DisableWebPagePreview: true,
ClearDraft: true,
},
ReplyMarkup: &client.ReplyMarkupInlineKeyboard{
Rows: rows,
},
})
- marperia/fwdbot
- wcsiu/telegram-client-demo + article
- Создание и развертывание ретранслятора Telegram каналов, используя Python и Heroku
Exclude #COIN
Include #TSLA
case #COIN
Check +
Other -
To -
case #TSLA
Check -
Other -
To +
case #ARK
Check -
Other +
To -
- Text
- Forward.SendCopy (or forward)
- and edit sync for double copy
- Forward.CopyOnce (edit sync)
- Forward.Indelible (delete sync)
- Filters Mode (see above)
- Forward.IncludeSubmatch
- ReplaceMyselfLinks + DeleteExternal
- ReplaceFragments (and not equal len)
- Sources.Link + Title
- Sources.Sign
- AutoAnswers
- MediaAlbum
- Forward.SendCopy (or forward)
- Forward.CopyOnce (edit sync)
- Forward.Indelible (delete sync)