Skip to content

Commit

Permalink
Better responses
Browse files Browse the repository at this point in the history
  • Loading branch information
btvoidx committed Aug 20, 2021
1 parent bccf2da commit d6eaf8e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func HandleNewMessage(json *sjson.Json) {

resp, err := requests.Get(config.RestUrl+"/v3/server/rawcmd", qs, nil)
if err != nil {
SendVKMessage("[Server request failed]\n"+err.Error(), from_id)
SendVKMessage("Server request failed.", from_id) // Sending back err.Error() expsoses token
return
}

json, err := sjson.NewJson(resp.Raw().Bytes())
if err != nil {
SendVKMessage("[Server didn't return anything]\n"+err.Error(), from_id)
SendVKMessage("Failed parsing server response.\n"+err.Error(), from_id)
return
}

Expand All @@ -81,8 +81,9 @@ func HandleNewMessage(json *sjson.Json) {
result := strings.Join(response, "\n")
SendVKMessage(result, from_id)
} else {
SendVKMessage("[No responce]", from_id)
SendVKMessage("Command didn't return output.", from_id)
}

fmt.Println("id" + strconv.Itoa(from_id) + " executed " + text)
}
}
Expand Down

0 comments on commit d6eaf8e

Please sign in to comment.