Properly clean, parse, and reformat data

master
Sven Slootweg 13 years ago
parent 00855e17fd
commit 9a06fb5ad8

@ -1,6 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import math, socket, ssl, select, time, threading, random, string import math, socket, ssl, select, time, threading, random, string
from collections import deque
EOC = "\r\n" EOC = "\r\n"
@ -149,8 +150,17 @@ class user:
self.registered = 1 self.registered = 1
def process_data(self, data): def process_data(self, data):
if data[0].upper() in ["USER", "NICK"] and self.registered == 1: data = deque(data)
if data[0].upper() == "USER":
if data[0].startswith(":"):
origin = data.popleft()
else:
origin = ""
data[0] = data[0].upper()
if data[0] in ["USER", "NICK"] and self.registered == 1:
if data[0] == "USER":
if len(data) >= 5: if len(data) >= 5:
self.ident = data[1] self.ident = data[1]
self.realname = data[4] self.realname = data[4]
@ -158,7 +168,7 @@ class user:
self.verify_registration() self.verify_registration()
else: else:
self.client.send_numeric("461", "%s USER :Not enough parameters." % self.nickname) self.client.send_numeric("461", "%s USER :Not enough parameters." % self.nickname)
elif data[0].upper() == "NICK": elif data[0] == "NICK":
if len(data) >= 2: if len(data) >= 2:
self.nickname = data[1] self.nickname = data[1]
self.registered_nick = True self.registered_nick = True

Loading…
Cancel
Save