SERVER DE LA MUERTE V2.0
This commit is contained in:
		| @@ -22,8 +22,10 @@ def handleConnection(connection, client_address): | |||||||
| def handleRequest(connection, data): | def handleRequest(connection, data): | ||||||
|     #try: |     #try: | ||||||
|     arrayData = data.split(" ") |     arrayData = data.split(" ") | ||||||
|  |  | ||||||
|  |     ### Command for user with nickname ### | ||||||
|     if usersConnected[connection][1] is not None: |     if usersConnected[connection][1] is not None: | ||||||
|         if (not arrayData[0][0] == "/"): |         if not arrayData[0][0] == "/" and usersConnected[connection][2]: | ||||||
|             connection.sendall("SUCC_MESSAGE_SENDED".encode()) |             connection.sendall("SUCC_MESSAGE_SENDED".encode()) | ||||||
|             broadcastMsg(connection, "NEW_MSG {} {} ".format(usersConnected[connection][1], data)) |             broadcastMsg(connection, "NEW_MSG {} {} ".format(usersConnected[connection][1], data)) | ||||||
|             return |             return | ||||||
| @@ -37,6 +39,21 @@ def handleRequest(connection, data): | |||||||
|             if arrayData[0] == "/userlistaway": |             if arrayData[0] == "/userlistaway": | ||||||
|                 userListAway(connection) |                 userListAway(connection) | ||||||
|                 return |                 return | ||||||
|  |             if arrayData[0] == "/enable": | ||||||
|  |                 enableUser(connection) | ||||||
|  |                 return | ||||||
|  |             if arrayData[0] == "/disable": | ||||||
|  |                 disableUser(connection) | ||||||
|  |                 return | ||||||
|  |             if arrayData[0] == "/quit": | ||||||
|  |                 connection.shutdown(socket.SHUT_RD) | ||||||
|  |                 return | ||||||
|  |  | ||||||
|  |             ### Command available for enable only ### | ||||||
|  |             if not usersConnected[connection][2] : | ||||||
|  |                 connection.sendall("ERR_U_ARE_DISABLE".encode()) | ||||||
|  |                 return | ||||||
|  |             else : | ||||||
|                 if arrayData[0] == "/askpm": |                 if arrayData[0] == "/askpm": | ||||||
|                     askPrivateMsg(connection, arrayData[1]) |                     askPrivateMsg(connection, arrayData[1]) | ||||||
|                     return |                     return | ||||||
| @@ -58,17 +75,9 @@ def handleRequest(connection, data): | |||||||
|                 if arrayData[0] == "/rejectfile": |                 if arrayData[0] == "/rejectfile": | ||||||
|                     rejectFile(connection, arrayData[1], " ".join(arrayData[2:])) |                     rejectFile(connection, arrayData[1], " ".join(arrayData[2:])) | ||||||
|                     return |                     return | ||||||
|             if arrayData[0] == "/enable": |  | ||||||
|                 enableUser(connection) |  | ||||||
|                 return |  | ||||||
|             if arrayData[0] == "/disable": |  | ||||||
|                 disableUser(connection) |  | ||||||
|                 return |  | ||||||
|             if arrayData[0] == "/quit": |  | ||||||
|                 connection.shutdown(socket.SHUT_RD) |  | ||||||
|                 return |  | ||||||
|         connection.sendall("ERR_COMMAND_NOT_FOUND".encode()) |         connection.sendall("ERR_COMMAND_NOT_FOUND".encode()) | ||||||
|     else: |     else: | ||||||
|  |         ### Command for user without nickname | ||||||
|         if arrayData[0] == "/newname": |         if arrayData[0] == "/newname": | ||||||
|             newName(connection, arrayData[1]) |             newName(connection, arrayData[1]) | ||||||
|             return |             return | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user