go: server: Fix unreachable active endpoint

master
Luther Wen Xu 2019-10-18 11:48:14 +07:00
parent ec43666620
commit c934af81e2
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 5 additions and 4 deletions

@ -35,17 +35,18 @@ func handleIncomingMessage(who *websocket.Conn, msg string) {
who.WriteMessage(websocket.TextMessage, []byte("leave "+message[1])) who.WriteMessage(websocket.TextMessage, []byte("leave "+message[1]))
} }
case "active": case "active":
if len(message) < 3 { arg := strings.Split(msg, " ")
if len(arg) < 3 {
return return
} }
arg := strings.Split(msg, " ") arg[1] = strings.Join(arg[1:len(arg)-1], " ")
arg[1] = strings.Join(arg[1:], " ") arg[2] = arg[len(arg)-1]
id, err := db.GetDiscordID(arg[1]) id, err := db.GetDiscordID(arg[1])
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
value, err := strconv.Atoi(arg[len(arg)-1]) value, err := strconv.Atoi(arg[2])
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return