fix file uploads for telegram topics
This commit is contained in:
@@ -464,7 +464,7 @@ func (b *Btelegram) handleEdit(msg *config.Message, chatid int64) (string, error
|
||||
}
|
||||
|
||||
// handleUploadFile handles native upload of files
|
||||
func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, parentID int) (string, error) {
|
||||
func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, threadid int, parentID int) (string, error) {
|
||||
var media []interface{}
|
||||
for _, f := range msg.Extra["file"] {
|
||||
fi := f.(config.FileInfo)
|
||||
@@ -514,7 +514,7 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, parentID
|
||||
}
|
||||
}
|
||||
|
||||
return b.sendMediaFiles(msg, chatid, parentID, media)
|
||||
return b.sendMediaFiles(msg, chatid, threadid, parentID, media)
|
||||
}
|
||||
|
||||
func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string {
|
||||
|
||||
@@ -159,7 +159,7 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {
|
||||
}
|
||||
// check if we have files to upload (from slack, telegram or mattermost)
|
||||
if len(msg.Extra["file"]) > 0 {
|
||||
return b.handleUploadFile(&msg, chatid, parentID)
|
||||
return b.handleUploadFile(&msg, chatid, topicid, parentID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,13 +204,14 @@ func (b *Btelegram) sendMessage(chatid int64, topicid int, username, text string
|
||||
}
|
||||
|
||||
// sendMediaFiles native upload media files via media group
|
||||
func (b *Btelegram) sendMediaFiles(msg *config.Message, chatid int64, parentID int, media []interface{}) (string, error) {
|
||||
func (b *Btelegram) sendMediaFiles(msg *config.Message, chatid int64, threadid int, parentID int, media []interface{}) (string, error) {
|
||||
if len(media) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
mg := tgbotapi.MediaGroupConfig{
|
||||
BaseChat: tgbotapi.BaseChat{
|
||||
ChatID: chatid,
|
||||
MessageThreadID: threadid,
|
||||
ChannelUsername: msg.Username,
|
||||
ReplyToMessageID: parentID,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user