Skip to content

Commit

Permalink
处理注销时的一个小bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumiko committed Dec 29, 2021
1 parent cd24248 commit a2fe09a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ proc login(username, password: string) =

proc logout() =
let stat = getResponse("status", initTable[string, string]())
let ip = stat["client_ip"].getStr()
if stat["error"].getStr() != "ok":
echo "user is not online. skip"
return
let ip = stat["online_ip"].getStr()
let user = stat["user_name"].getStr()
let params = {"action": "logout", "username": user, "ac_id": "1", "ip": ip}.toTable
let resp = getResponse("logout", params)
let res = resp["error"].getStr()
if res == "ok":
echo resp["suc_msg"].getStr()
else:
if res != "ok":
let error_msg = resp["error_msg"].getStr()
echo res & ", " & error_msg
else:
echo "logout success."

proc status() =
let resp = getResponse("status", initTable[string, string]())
Expand Down

0 comments on commit a2fe09a

Please sign in to comment.