cobalt.py

changeset 16
6672cecf3ed1
parent 15
e7999383db5a
child 17
f604687dd35b
equal deleted inserted replaced
15:e7999383db5a 16:6672cecf3ed1
164 #quit() 164 #quit()
165 165
166 sys.excepthook = handle_exception 166 sys.excepthook = handle_exception
167 167
168 def check_admin (sender, ident, host, command): 168 def check_admin (sender, ident, host, command):
169 if not "%s!%s@%s" % (sender, ident, host) in g_admins: 169 if not "%s@%s" % (ident, host) in g_admins:
170 raise logical_exception (".%s requires admin access" % command) 170 raise logical_exception (".%s requires admin access" % command)
171 171
172 class logical_exception (Exception): 172 class logical_exception (Exception):
173 def __init__ (self, value): 173 def __init__ (self, value):
174 self.value = value 174 self.value = value
244 self.send_buffer = [] 244 self.send_buffer = []
245 245
246 def handle_read (self): 246 def handle_read (self):
247 lines = self.recv (4096).splitlines() 247 lines = self.recv (4096).splitlines()
248 for utfline in lines: 248 for utfline in lines:
249 line = utfline.decode("utf-8").encode("ascii","ignore") 249 try:
250 line = utfline.decode("utf-8").encode("ascii","ignore")
251 except UnicodeDecodeError:
252 continue
253
250 if self.verbose: 254 if self.verbose:
251 print "[%s] -> %s" % (self.name, line) 255 print "[%s] -> %s" % (self.name, line)
252 256
253 if line.startswith ("PING :"): 257 if line.startswith ("PING :"):
254 self.write ("PONG :%s" % line[6:]) 258 self.write ("PONG :%s" % line[6:])

mercurial