Allow pics without caption

This commit is contained in:
Hamcha 2019-05-23 16:56:19 +02:00
parent b7d6ea332a
commit 025a5b96fd
Signed by: hamcha
GPG key ID: A40413D21021EAEE

View file

@ -69,12 +69,12 @@ func mastodon_message(broker *tg.Broker, update tg.APIMessage) {
update.Text = update.ReplyTo.Text update.Text = update.ReplyTo.Text
if update.ReplyTo.Photo != nil { if update.ReplyTo.Photo != nil {
update.Photo = update.ReplyTo.Photo update.Photo = update.ReplyTo.Photo
update.Caption = update.Text update.Caption = update.ReplyTo.Caption
} }
} }
// Check for media // Check for media
if update.Photo != nil && update.Caption != nil { if update.Photo != nil {
maxsz := 0 maxsz := 0
photo := tg.APIPhotoSize{} photo := tg.APIPhotoSize{}
for _, curphoto := range update.Photo { for _, curphoto := range update.Photo {
@ -83,7 +83,7 @@ func mastodon_message(broker *tg.Broker, update tg.APIMessage) {
photo = curphoto photo = curphoto
} }
} }
go broker.GetFile(photo.FileID, func(broker *tg.Broker, data tg.BrokerUpdate) { broker.GetFile(photo.FileID, func(broker *tg.Broker, data tg.BrokerUpdate) {
if data.Type == tg.BError { if data.Type == tg.BError {
log.Printf("[mastodon] Received error from broker: %s\n", *data.Error) log.Printf("[mastodon] Received error from broker: %s\n", *data.Error)
broker.SendTextMessage(update.Chat, "<b>ERRORE!</b> @hamcha controlla la console!", &tg.MessageOptions{ broker.SendTextMessage(update.Chat, "<b>ERRORE!</b> @hamcha controlla la console!", &tg.MessageOptions{