Try to reduce cognitive complexity of code

This commit is contained in:
Alexander Korelskiy
2022-03-30 11:51:42 +03:00
parent aab4464b89
commit eaf4af1a1e
2 changed files with 4 additions and 5 deletions

View File

@@ -490,11 +490,7 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, parentID
}
}
if len(media) > 0 {
return b.sendMediaFiles(msg, chatid, parentID, media)
}
return "", nil
return b.sendMediaFiles(msg, chatid, parentID, media)
}
func (b *Btelegram) handleQuote(message, quoteNick, quoteMessage string) string {

View File

@@ -172,6 +172,9 @@ func (b *Btelegram) sendMessage(chatid int64, username, text string, parentID in
// sendMediaFiles native upload media files via media group
func (b *Btelegram) sendMediaFiles(msg *config.Message, chatid int64, parentID int, media []interface{}) (string, error) {
if len(media) == 0 {
return "", nil
}
mg := tgbotapi.MediaGroupConfig{ChatID: chatid, ChannelUsername: msg.Username, Media: media, ReplyToMessageID: parentID}
messages, err := b.c.SendMediaGroup(mg)
if err != nil {