irkerd: Store less state in IRCServerConnection.connect()
authorW. Trevor King <wking@tremily.us>
Fri, 7 Mar 2014 04:21:02 +0000 (20:21 -0800)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 11 Mar 2014 04:38:01 +0000 (00:38 -0400)
We will never need the connection-time port, server_address, username,
ircname, or password again, so don't store them.  We *do* need server
and real_server_name for Event handling, so keep them around.

irkerd

diff --git a/irkerd b/irkerd
index a71c841f2f766e3a2a0863240ad1bcf662fd2e73..65828a650711364f127e52d4d76618ff9bed694d 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -214,23 +214,18 @@ class IRCServerConnection():
         self.event_handlers = {}
         self.real_server_name = ""
         self.server = server
-        self.port = port
-        self.server_address = (server, port)
         self.nickname = nickname
-        self.username = username or nickname
-        self.ircname = ircname or nickname
-        self.password = password
         try:
             self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             self.socket.bind(('', 0))
-            self.socket.connect(self.server_address)
+            self.socket.connect((server, port))
         except socket.error as err:
             raise IRCServerConnectionError("Couldn't connect to socket: %s" % err)
 
-        if self.password:
-            self.ship("PASS " + self.password)
+        if password:
+            self.ship("PASS " + password)
         self.nick(self.nickname)
-        self.user(self.username, self.ircname)
+        self.user(username=username or ircname, realname=ircname or nickname)
         return self
 
     def close(self):