graceful failure when failing to send telegram->dc messages

This commit is contained in:
mappu 2018-06-04 16:43:49 +12:00
parent e2836b6388
commit d785388d88

View File

@ -451,7 +451,11 @@ func (this *NTFServer) HandleGroupMessage(update telegram.Update) error {
this.Coalesce(hubNick, update.Message.Text)
// Submit to NMDC
conn.SayPublic(update.Message.Text)
err := conn.SayPublic(update.Message.Text)
if err != nil {
log.Printf("Failed to deliver message '%s': %s", update.Message.Text, err.Error())
this.GroupChatSayHTML(fmt.Sprintf("<i>Couldn't sync message '%s' because: %s</i>", html.EscapeString(update.Message.Text), html.EscapeString(err.Error())))
}
}
// TODO probably a file/image upload???
@ -532,7 +536,11 @@ func (this *NTFServer) HandleDirectMessage(update telegram.Update) error {
return respond(fmt.Sprintf("Can't PM offline user '%s'", parts[1]))
}
conn.SayPrivate(parts[1], parts[2])
err := conn.SayPrivate(parts[1], parts[2])
if err != nil {
log.Printf("Sending PM %s -> %s failed because: %s", hubNick, parts[1], err.Error())
return respond(fmt.Sprintf("Sending PM failed because: %s", err.Error()))
}
} else if strings.HasPrefix(msg, "/join ") {
requestedHubNick := msg[6:]