Poulet
This commit is contained in:
parent
d5baaa74d2
commit
9030013c68
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.idea/
|
||||
__pycache__/
|
||||
log
|
||||
|
@ -1,27 +0,0 @@
|
||||
2015-04-01 08:42:26,046 :: INFO :: [95m Configuration load Namespace(port=8000, usermax=None) [0m
|
||||
2015-04-01 08:42:26,046 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 08:42:26,088 :: INFO :: [95m Server Listen on port 8000 [0m
|
||||
2015-04-01 08:43:10,939 :: INFO :: [95m Wait for threads ending [0m
|
||||
2015-04-01 08:43:10,940 :: INFO :: [95m Server shutdown [0m
|
||||
2015-04-01 08:43:21,055 :: INFO :: [95m Configuration load Namespace(port=2222, usermax=None) [0m
|
||||
2015-04-01 08:43:21,055 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 08:43:21,058 :: INFO :: [95m Server Listen on port 2222 [0m
|
||||
2015-04-01 08:43:32,103 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 53851) [0m
|
||||
2015-04-01 08:43:39,933 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) bob [0m
|
||||
2015-04-01 08:43:45,900 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) super ! [0m
|
||||
2015-04-01 08:43:52,170 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) /name bob [0m
|
||||
2015-04-01 08:44:08,771 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 53852) [0m
|
||||
2015-04-01 08:44:12,601 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53852) /quit [0m
|
||||
2015-04-01 08:44:45,278 :: INFO :: [95m Wait for threads ending [0m
|
||||
2015-04-01 08:44:45,278 :: INFO :: [95m Disconnection from IP -> ('127.0.0.1', 53851) [0m
|
||||
2015-04-01 14:01:21,465 :: INFO :: [95m Configuration load Namespace(port=8000, usermax=None) [0m
|
||||
2015-04-01 14:01:21,476 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 14:01:21,508 :: INFO :: [95m Server Listen on port 8000 [0m
|
||||
2015-04-01 14:01:59,767 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 60151) [0m
|
||||
2015-04-01 14:02:04,760 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) coucou [0m
|
||||
2015-04-01 14:02:20,518 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /name bob [0m
|
||||
2015-04-01 14:03:35,380 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname bob [0m
|
||||
2015-04-01 14:03:38,491 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) coucou [0m
|
||||
2015-04-01 14:03:48,807 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname [0m
|
||||
2015-04-01 14:03:56,293 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname renan [0m
|
||||
2015-04-01 14:04:53,177 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 60182) [0m
|
@ -23,8 +23,6 @@ def handleConnection(connection, client_address) :
|
||||
def handleRequest(connection, data):
|
||||
#try:
|
||||
arrayData = data.split(" ")
|
||||
if arrayData[0] == "/newname" :
|
||||
pass
|
||||
if usersConnected[connection][1] is not None :
|
||||
if(not arrayData[0][0] == "/"):
|
||||
broadcastMsg( "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
|
||||
@ -33,9 +31,6 @@ def handleRequest(connection, data):
|
||||
if arrayData[0] == "/name" :
|
||||
changeName(connection, arrayData[1])
|
||||
return
|
||||
if arrayData[0] == "/quit" :
|
||||
quit(connection)
|
||||
return
|
||||
if arrayData[0] == "/askpm" :
|
||||
askPrivateMsg(connection,arrayData[1])
|
||||
return
|
||||
@ -56,6 +51,12 @@ def handleRequest(connection, data):
|
||||
return
|
||||
connection.send("ERR_COMMAND_NOT_FOUND".encode())
|
||||
else:
|
||||
if arrayData[0] == "/newname" :
|
||||
newName(connection)
|
||||
return
|
||||
if arrayData[0] == "/quit" :
|
||||
quit(connection)
|
||||
return
|
||||
connection.send("CMD_NOT_ALLOWED".encode())
|
||||
"""except Exception as e :
|
||||
log.printL(str(e), Log.lvl.FAIL)"""
|
||||
@ -63,6 +64,7 @@ def handleRequest(connection, data):
|
||||
|
||||
def broadcastMsg(message):
|
||||
for con, value in usersConnected.items() :
|
||||
if usersConnected[con][1] is not None :
|
||||
con.send(message.encode())
|
||||
|
||||
|
||||
@ -87,6 +89,12 @@ def changeName(connection, pseudo):
|
||||
usersConnected[connection][1] = pseudo
|
||||
|
||||
|
||||
def newName(connection, pseudo):
|
||||
broadcastMsg("HAS_JOIN {} ".format(pseudo))
|
||||
connection.send("SUCC_VALID_NICKNAME")
|
||||
usersConnected[connection][1] = pseudo
|
||||
|
||||
|
||||
def askPrivateMsg(connection,pseudo):
|
||||
c = getConnectionByPseudo(pseudo)
|
||||
if c is None :
|
||||
|
Reference in New Issue
Block a user