Network/IRC/IrcWidget.py

changeset 2234
1e33501a0d33
parent 2232
47290dad6d0b
child 2236
e30d5f978919
--- a/Network/IRC/IrcWidget.py	Tue Nov 27 20:05:59 2012 +0100
+++ b/Network/IRC/IrcWidget.py	Wed Nov 28 19:00:40 2012 +0100
@@ -10,7 +10,7 @@
 import re
 import logging
 
-from PyQt4.QtCore import pyqtSlot, Qt, QByteArray
+from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QTimer
 from PyQt4.QtGui import QWidget, QToolButton, QLabel
 from PyQt4.QtNetwork import QTcpSocket, QAbstractSocket
 
@@ -164,11 +164,12 @@
         dlg = IrcNetworkListDialog(self.__ircNetworkManager, self)
         dlg.exec_()
     
-    def __joinChannel(self, name):
+    def __joinChannel(self, name, key=""):
         """
         Private slot to join a channel.
         
         @param name name of the channel (string)
+        @param key key of the channel (string)
         """
         # step 1: check, if this channel is already joined
         for channel in self.__channelList:
@@ -187,7 +188,7 @@
         self.channelsWidget.addTab(channel, name)
         self.__channelList.append(channel)
         
-        self.__send("JOIN " + name)
+        self.__send("JOIN " + name) # TODO: add channel key
         self.__send("MODE " + name)
         
         emptyIndex = self.channelsWidget.indexOf(self.__emptyLabel)
@@ -464,6 +465,7 @@
         if code == 1:
             # register with services after the welcome message
             self.__registerWithServices()
+            QTimer.singleShot(1000, self.__autoJoinChannels)
         elif code == 5:
             # extract the user privilege prefixes
             # ... PREFIX=(ov)@+ ...
@@ -488,6 +490,16 @@
         if service and password:
             self.__send("PRIVMSG " + service + " :identify " + password)
     
+    def __autoJoinChannels(self):
+        """
+        Private slot to join channels automatically once a server got connected.
+        """
+        for channel in self.networkWidget.getNetworkChannels():
+            if channel.autoJoin():
+                name = channel.getName()
+                key = channel.getKey()
+                self.__joinChannel(name, key)
+    
     def __tcpError(self, error):
         """
         Private slot to handle errors reported by the TCP socket.

eric ide

mercurial