This library is intended to encapsulate the IRC protocol at a quite
low level. Clients are written by registering callbacks (i.e. not by
-inheriting a class), to make it able to use different programming
-paradigms easily. (It should be quite easy to write an
-object-oriented wrapper for one server connection, for example.)
+inheriting a class), to make it easy to use different programming
+paradigms. (It should be quite easy to write an object-oriented
+wrapper for one server connection, for example.)
The class hierarchy is inspired by the Perl IRC module (Net::IRC).
self.connected = 0 # Not connected yet.
- def connect(self, server, port, nickname, username, ircname
+ def connect(self, server, port, nickname, username, ircname=None):
"""(Re)connect to a server.
This function can be called to reconnect a closed connection.
- self.username = username
+ self.username = username or nickname
+ self.ircname = ircname or nickname
self.localhost = socket.gethostname()
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.send_raw("TRACE" + (target and (" " + target)))
def user(self, username, localhost, server, ircname):
- self.send_raw("USER %s
* * :%s" % (username, localhost, server, ircname))
+ self.send_raw("USER %s :%s" % (username, localhost, server, ircname))
def userhost(self, nicks):
self.send_raw("USERHOST " + string.join(nicks, ","))