except Exception:
VERSION = ()
-DEBUG = False
-
# TODO
# ----
# (maybe) thread safety
self.previous_buffer = lines.pop()
for line in lines:
- if DEBUG:
- print "FROM SERVER:", line
+ self.irclibobj.debug(1, "FROM SERVER: %s" % repr(line))
if not line:
continue
command = "ctcpreply"
m = list(m)
- if DEBUG:
- print "command: %s, source: %s, target: %s, arguments: %s" % (
- command, prefix, target, m)
+ self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, m))
self._handle_event(Event(command, prefix, target, m))
if command == "ctcp" and m[0] == "ACTION":
self._handle_event(Event("action", prefix, target, m[1:]))
else:
- if DEBUG:
- print "command: %s, source: %s, target: %s, arguments: %s" % (
- command, prefix, target, [m])
+ self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, [m]))
self._handle_event(Event(command, prefix, target, [m]))
else:
target = None
if not is_channel(target):
command = "umode"
- if DEBUG:
- print "command: %s, source: %s, target: %s, arguments: %s" % (
- command, prefix, target, arguments)
+ self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, m))
self._handle_event(Event(command, prefix, target, arguments))
def _handle_event(self, event):
self.ssl.write(string + "\r\n")
else:
self.socket.send(string + "\r\n")
- if DEBUG:
- print "TO SERVER:", string
+ self.irclibobj.debug(1, "TO SERVER: " + repr(string))
except socket.error:
# Ouch!
self.disconnect("Connection reset by peer.")
"""
def __init__(self, irclibobj, dcctype):
super(DCCConnection, self).__init__(irclibobj)
+ self.irclibobj = irclibobj
self.connected = 0
self.passive = 0
self.dcctype = dcctype
self.socket.close()
self.socket = conn
self.connected = 1
- if DEBUG:
- print "DCC connection from %s:%d" % (
- self.peeraddress, self.peerport)
+ self.irclibobj.debug(1, "DCC connection from %s:%d" % (
+ self.peeraddress, self.peerport))
self.irclibobj._handle_event(
self,
Event("dcc_connect", self.peeraddress, None, None))
prefix = self.peeraddress
target = None
for chunk in chunks:
- if DEBUG:
- print "FROM PEER:", chunk
+ self.irclibobj.debug(1, "FROM PEER: " + repr(chunk))
arguments = [chunk]
- if DEBUG:
- print "command: %s, source: %s, target: %s, arguments: %s" % (
- command, prefix, target, arguments)
+ self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (
+ command, prefix, target, arguments))
self.irclibobj._handle_event(
self,
Event(command, prefix, target, arguments))
self.socket.send(string)
if self.dcctype == "chat":
self.socket.send("\n")
- if DEBUG:
- print "TO PEER: %s\n" % string
+ self.irclibobj.debug("TO PEER: %s\n" % repr(string))
except socket.error:
# Ouch!
self.disconnect("Connection reset by peer.")
def _dispatcher(self, c, e):
"""[Internal]"""
- if DEBUG:
- print("irclib.py:_dispatcher:%s" % e.eventtype())
+ self.irclibobj.debug("dispatcher:%s" % e.eventtype())
m = "on_" + e.eventtype()
if hasattr(self, m):