diff --git a/telegram.go b/telegram.go index 433b4ef3ccb40e5b324fc0760a216ebdfd7ff44a..53a9088dd629b0166046fac26241118491fb7b68 100644 --- a/telegram.go +++ b/telegram.go @@ -176,10 +176,15 @@ func respondTelegram(update tgbotapi.Update) { header, has := makeHeader(update.Message, false) - if update.Message.Photo != nil && len(*update.Message.Photo) > 0 { + if update.Message.Photo != nil && (len(*update.Message.Photo)/4) > 0 { fids := "" - files := make([]*discordgo.File, len(*update.Message.Photo)) - for i, info := range *update.Message.Photo { + files := make([]*discordgo.File, len(*update.Message.Photo)/4) + + p := *update.Message.Photo + for i := 0; i < len(files); i++ { + // FIXME: multiple images + info := p[((i+1)*4)-1] + var url string if u, err := botAPI.GetFileDirectURL(info.FileID); err != nil { msg := tgbotapi.NewMessage(update.Message.Chat.ID, "error getting URL") @@ -199,8 +204,8 @@ func respondTelegram(update tgbotapi.Update) { return } else { files[i] = &discordgo.File{ - Name: "sticker.webp", - ContentType: "image/webp", + Name: "image.jpg", + ContentType: "image/jpeg", Reader: resp.Body, } //goland:noinspection GoDeferInLoop