diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 6ba8856..5f2dce4 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -25,6 +25,7 @@ CHANGELOG * Lua quirks * Multi-select memo chooser - [alGore] * Auto-identify with NickServ - Kiooeht [evacipatedBox] +* Auto-join memos - Kiooeht [evacipatedBox] * Bug fixes * Don't require pygame (it's kind of optional, you just don't get sound) - Kiooeht [evacipatedBox] * Allow add chum dialog to open after adding an existing chum - Kiooeht [evacipatedBox] diff --git a/irc.py b/irc.py index 4cec0a5..5d794c6 100644 --- a/irc.py +++ b/irc.py @@ -177,6 +177,8 @@ class PesterIRC(QtCore.QThread): self.setConnectionBroken() self.mainwindow.closeConversations(True) self.mainwindow.doAutoIdentify() + self.mainwindow.autoJoinDone = False + self.mainwindow.doAutoJoins() self.updateMood() @QtCore.pyqtSlot() def updateMood(self): diff --git a/menus.py b/menus.py index 37d3bb7..8e542e1 100644 --- a/menus.py +++ b/menus.py @@ -1029,6 +1029,15 @@ class PesterOptions(QtGui.QDialog): self.nickservpass.setEchoMode(QtGui.QLineEdit.PasswordEchoOnEdit) self.nickservpass.setText(parent.userprofile.getNickServPass()) + self.autojoinlist = QtGui.QListWidget(self) + self.autojoinlist.addItems(parent.userprofile.getAutoJoins()) + self.addAutoJoinBtn = QtGui.QPushButton("Add", self) + self.connect(self.addAutoJoinBtn, QtCore.SIGNAL('clicked()'), + self, QtCore.SLOT('addAutoJoin()')) + self.delAutoJoinBtn = QtGui.QPushButton("Remove", self) + self.connect(self.delAutoJoinBtn, QtCore.SIGNAL('clicked()'), + self, QtCore.SLOT('delAutoJoin()')) + self.tabcheck = QtGui.QCheckBox("Tabbed Conversations", self) if self.config.tabs(): self.tabcheck.setChecked(True) @@ -1383,6 +1392,12 @@ class PesterOptions(QtGui.QDialog): layout_indent.addWidget(self.nickservpass) layout_indent.setContentsMargins(22,0,0,0) layout_connect.addLayout(layout_indent) + layout_connect.addWidget(QtGui.QLabel("Auto-Join Memos:")) + layout_connect.addWidget(self.autojoinlist) + layout_8 = QtGui.QHBoxLayout() + layout_8.addWidget(self.addAutoJoinBtn) + layout_8.addWidget(self.delAutoJoinBtn) + layout_connect.addLayout(layout_8) self.pages.addWidget(widget) # Advanced @@ -1435,6 +1450,28 @@ class PesterOptions(QtGui.QDialog): def autoNickServChange(self, state): self.nickservpass.setEnabled(state != 0) + @QtCore.pyqtSlot() + def addAutoJoin(self, mitem=None): + d = {"label": "Memo:", "inputname": "value" } + if mitem is not None: + d["value"] = str(mitem.text()) + pdict = MultiTextDialog("ENTER MEMO", self, d).getText() + if pdict is None: + return + pdict["value"] = "#" + pdict["value"] + if mitem is None: + items = self.autojoinlist.findItems(pdict["value"], QtCore.Qt.MatchFixedString) + if len(items) == 0: + self.autojoinlist.addItem(pdict["value"]) + else: + mitem.setText(pdict["value"]) + + @QtCore.pyqtSlot() + def delAutoJoin(self): + i = self.autojoinlist.currentRow() + if i >= 0: + self.autojoinlist.takeItem(i) + @QtCore.pyqtSlot(int) def soundChange(self, state): if state == 0: diff --git a/pesterchum.py b/pesterchum.py index c64cefe..f5b7b41 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -990,6 +990,7 @@ class PesterWindow(MovingWindow): MovingWindow.__init__(self, parent, (QtCore.Qt.CustomizeWindowHint | QtCore.Qt.FramelessWindowHint)) + self.autoJoinDone = False self.app = app self.convos = CaseInsensitiveDict() self.memos = CaseInsensitiveDict() @@ -1714,6 +1715,12 @@ class PesterWindow(MovingWindow): if self.userprofile.getAutoIdentify(): self.sendMessage.emit("identify " + self.userprofile.getNickServPass(), "NickServ") + def doAutoJoins(self): + if not self.autoJoinDone: + self.autoJoinDone = True + for memo in self.userprofile.getAutoJoins(): + self.newMemo(memo, "i") + @QtCore.pyqtSlot() def connected(self): if self.loadingscreen: @@ -1721,6 +1728,7 @@ class PesterWindow(MovingWindow): self.loadingscreen = None self.doAutoIdentify() + self.doAutoJoins() @QtCore.pyqtSlot() def blockSelectedChum(self): @@ -2467,6 +2475,11 @@ class PesterWindow(MovingWindow): nickservpass = self.optionmenu.nickservpass.text() self.userprofile.setAutoIdentify(autoidentify) self.userprofile.setNickServPass(str(nickservpass)) + # auto join memos + autojoins = [] + for i in range(self.optionmenu.autojoinlist.count()): + autojoins.append(str(self.optionmenu.autojoinlist.item(i).text())) + self.userprofile.setAutoJoins(autojoins) # advanced ## user mode if self.advanced: @@ -2643,6 +2656,7 @@ class PesterWindow(MovingWindow): def myHandleChanged(self, handle): if self.profile().handle == handle: self.doAutoIdentify() + self.doAutoJoins() return else: self.nickCollision(self.profile().handle, handle) diff --git a/profile.py b/profile.py index 13c48ea..5e6915b 100644 --- a/profile.py +++ b/profile.py @@ -370,6 +370,7 @@ class userProfile(object): self.mentions = [r"\b(%s)\b" % ("|".join(initials))] else: self.mentions = [] + self.autojoins = [] else: fp = open("%s/%s.js" % (self.profiledir, user)) self.userprofile = json.load(fp) @@ -394,6 +395,9 @@ class userProfile(object): else: self.userprofile["mentions"] = [] self.mentions = self.userprofile["mentions"] + if "autojoins" not in self.userprofile: + self.userprofile["autojoins"] = [] + self.autojoins = self.userprofile["autojoins"] with open(_datadir+"passwd.js") as fp: try: @@ -462,6 +466,12 @@ class userProfile(object): self.passwd[self.chat.handle] = {} self.passwd[self.chat.handle]["pw"] = pw self.saveNickServPass() + def getAutoJoins(self): + return self.autojoins + def setAutoJoins(self, autojoins): + self.autojoins = autojoins + self.userprofile["autojoins"] = self.autojoins + self.save() def save(self): handle = self.chat.handle if handle[0:12] == "pesterClient":