class BufferOverflowException(Exception):
pass
+class IDGenerationException(Exception):
+ pass
+
def jsondump(fn):
def decorator(*args, **kwargs):
x = fn(*args, **kwargs)
return [False, "Nickname not supplied"]
nick = nick[0]
-
- id = get_session_id()
-
+
+ for i in xrange(10):
+ id = get_session_id()
+ if not Sessions.get(id):
+ break
+ else:
+ raise IDGenerationException()
+
session = IRCSession(id)
- client = ircclient.createIRC(session, nick=nick, ident=ident, ip=ip, realname=nick)
+ client = ircclient.createIRC(session, nick=nick, ident=ident, ip=ip, realname=config.REALNAME)
session.client = client
Sessions[id] = session
except UnicodeDecodeError:
decoded = command.decode("iso-8859-1", "ignore")
+ if len(decoded) > config.MAXLINELEN:
+ session.disconnect()
+ return [False, "Line too long"]
+
try:
session.push(decoded)
except AttributeError: # occurs when we haven't noticed an error