reportar errores cuando falla enviar un mensaje
This commit is contained in:
parent
702519ddc7
commit
ca70ad20e9
1 changed files with 8 additions and 1 deletions
9
main.go
9
main.go
|
@ -44,6 +44,13 @@ func (fu FileURL) SendData() string {
|
|||
func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) {
|
||||
var explicit bool
|
||||
|
||||
send := func(c tgbotapi.Chattable) {
|
||||
_, err := bot.Send(c)
|
||||
if err != nil {
|
||||
log.Println("No pude enviar un mensaje porque", err)
|
||||
}
|
||||
}
|
||||
|
||||
msg := update.Message
|
||||
if strings.HasPrefix(msg.Text, "/dl") || msg.Chat.IsPrivate() {
|
||||
explicit = true
|
||||
|
@ -108,7 +115,7 @@ func (config Config) handleMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update)
|
|||
}
|
||||
|
||||
if érror == common.HadError {
|
||||
bot.Send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
|
||||
send(respondWithMany(update.Message, "Hubo un error al descargar ", url.String(), "."))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue