Browse Source

Better error logging

master
Gregory Rudolph 4 years ago
parent
commit
610ea960f1
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 3
      commands.go
  2. 3
      main.go

3
commands.go

@ -388,10 +388,13 @@ func handleError(err error, m chat1.MsgSummary, msg string) {
return return
} }
if strings.HasPrefix(err.Error(), "408") { if strings.HasPrefix(err.Error(), "408") {
if !m.Content.Attachment.Uploaded {
k.SendMessageByConvID(m.ConvID, "Unable to wake vehicle within the timeframe. Trying to run the command again.") k.SendMessageByConvID(m.ConvID, "Unable to wake vehicle within the timeframe. Trying to run the command again.")
m.Content.Attachment.Uploaded = true
handleChat(m) handleChat(m)
return return
} }
}
if strings.HasPrefix(err.Error(), "400") { if strings.HasPrefix(err.Error(), "400") {
k.SendMessageByConvID(m.ConvID, "Tesla returned an error. The command you tried to use may need an update. Please contact @rudi9719 with tracking ID %+v and the bad command.", tracker) k.SendMessageByConvID(m.ConvID, "Tesla returned an error. The command you tried to use may need an update. Please contact @rudi9719 with tracking ID %+v and the bad command.", tracker)
return return

3
main.go

@ -44,6 +44,9 @@ func main() {
func handleChat(m chat1.MsgSummary) { func handleChat(m chat1.MsgSummary) {
defer log.PanicSafe() defer log.PanicSafe()
if m.Content.TypeName != "text" {
return
}
parts := strings.Split(m.Content.Text.Body, " ") parts := strings.Split(m.Content.Text.Body, " ")
command := strings.Replace(parts[0], "!", "", -1) command := strings.Replace(parts[0], "!", "", -1)
for _, v := range commands { for _, v := range commands {

Loading…
Cancel
Save