Make whoami return "user,<user>" instead of "<user>", to prevent collisions with other returns.

This commit is contained in:
Fierelier 2021-04-11 20:04:44 +02:00
parent 399efeb320
commit 0d7d59d7fe
3 changed files with 5 additions and 5 deletions

View File

@ -18,7 +18,7 @@ A valid request contains a 4-byte (32-bit) big endian unsigned integer denoting
- **req**
Execute a command with an associated request ID. Returns with the same ID, and the command's return value(s).
*Arguments:* `req,<ID>,<command>,[argument 1],[argument 2],[...]`
*Return:* `<req>,<ID>,[return value 1],[return value 2],[...]`
*Return:* `req,<ID>,[return value 1],[return value 2],[...]`
- **register**
Register a new user on the server.
*Arguments:* `<user>,<password>`
@ -27,7 +27,7 @@ Log into an existing server.
*Arguments:* `<user>,<password>`
- **whoami**
Check which user this session is using.
*Return:* `<user>`
*Return:* `user,<user>`
- **send**
Sends command to another user's clients. The command will arrive as-is, with the user switched to be the sender instead of the receiver. So if you are fier, and you execute `send,fier2,text,hello`, fier2 will get `send,fier,text,hello`
*Arguments:* `<user>,<command>,[argument 1],[argument 2],[...]`

View File

@ -83,5 +83,5 @@ def textUserGet(self,command,args):
if not user:
return ["error","nonfatal","not_logged_in"]
return [user]
return ["user",user]
textCommandAddHandler("whoami",textUserGet)

View File

@ -1,7 +1,7 @@
global textTimeout
textTimeout = 30
global textKeepAliveTimeout
textKeepAliveTimeout = 600 # set to 0 for infinite time (not recommended)
textKeepAliveTimeout = 600 # set to None for infinite time (not recommended)
global textOnConnect
def textOnConnect(event,connection,address):
@ -13,7 +13,7 @@ global textOnPreRequest
def textOnPreRequest(event,self,requestLength):
global textTimeout
self.connection.settimeout(textTimeout)
if requestLength <= 128: return
if requestLength <= 100000: return
try:
sendResponse(self.connection,textListToCommand(["error","fatal","request_too_long"]).encode("utf-8"))
except threading.timeout: