From 4b504a0e9870130ac89c327386ffe57ba6535c63 Mon Sep 17 00:00:00 2001 From: illuminatedwax Date: Wed, 13 Apr 2011 01:12:19 -0500 Subject: [PATCH] derp --- CHANGELOG.mkdn | 1 + convo.py | 18 +++++------ generic.py | 4 ++- menus.py | 17 ++++++++-- parsetools.py | 15 ++++++--- pesterchum.js | 2 +- pesterchum.py | 65 +++++++++++++++++++++++++++++++++++++- themes/enamel/style.js | 1 + themes/gold/style.js | 1 + themes/pesterchum/style.js | 1 + themes/trollian/style.js | 1 + themes/typewriter/style.js | 1 + 12 files changed, 107 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 239aeab..527eaed 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -18,6 +18,7 @@ CHANGELOG * Quirk ordering - alGore * # of users in a memo - alGore * @links to users - illuminatedwax [ghostDunk] +* Support for REPORT and ALT to calSprite built in BUG FIXES: * mixer bug fixed diff --git a/convo.py b/convo.py index 6f5ad20..fab1ed6 100644 --- a/convo.py +++ b/convo.py @@ -8,7 +8,7 @@ from PyQt4 import QtGui, QtCore from dataobjs import PesterProfile, Mood, PesterHistory -from generic import PesterIcon, RightClickList +from generic import PesterIcon from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, img2smiley class PesterTabWindow(QtGui.QFrame): @@ -306,14 +306,7 @@ def mousePressEvent(self, event): self.parent().mainwindow.showMemos(url[1:]) elif url[0] == "@": handle = unicode(url[1:]) - mw = self.parent().mainwindow - matchingChums = [c for c in mw.chumList.chums if c.handle == handle] - if len(matchingChums) > 0: - mood = matchingChums[0].mood - else: - mood = Mood(0) - chum = PesterProfile(handle, mood=mood, chumdb=mw.chumdb) - mw.newConversation(chum) + self.parent().mainwindow.newConversation(handle) else: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) QtGui.QTextEdit.mousePressEvent(self, event) @@ -453,10 +446,14 @@ def __init__(self, chum, initiated, mainwindow, parent=None): self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self) self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('unblockChumSlot()')) + self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self) + self.connect(self.reportchum, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('reportThisChum()')) self.optionsMenu.addAction(self.quirksOff) self.optionsMenu.addAction(self.addChumAction) self.optionsMenu.addAction(self.blockAction) + self.optionsMenu.addAction(self.reportchum) self.chumopen = False self.applyquirks = True @@ -629,6 +626,9 @@ def addThisChum(self): def blockThisChum(self): self.mainwindow.blockChum(self.chum.handle) @QtCore.pyqtSlot() + def reportThisChum(self): + self.mainwindow.reportChum(self.chum.handle) + @QtCore.pyqtSlot() def unblockChumSlot(self): self.mainwindow.unblockChum(self.chum.handle) @QtCore.pyqtSlot(bool) diff --git a/generic.py b/generic.py index fd77ad6..0e5b21a 100644 --- a/generic.py +++ b/generic.py @@ -35,7 +35,9 @@ def contextMenuEvent(self, event): if event.reason() == QtGui.QContextMenuEvent.Mouse: listing = self.itemAt(event.pos()) self.setCurrentItem(listing) - self.optionsMenu.popup(event.globalPos()) + self.getOptionsMenu().popup(event.globalPos()) + def getOptionsMenu(self): + return self.optionsMenu class MultiTextDialog(QtGui.QDialog): def __init__(self, title, parent, *queries): diff --git a/menus.py b/menus.py index 1ffe9ef..2081b00 100644 --- a/menus.py +++ b/menus.py @@ -610,7 +610,11 @@ def __init__(self, config, theme, parent): self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self) self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('addChumSlot()')) + self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) + self.connect(self.pesterChumAction, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('pesterChumSlot()')) self.userarea.optionsMenu.addAction(self.addChumAction) + self.userarea.optionsMenu.addAction(self.pesterChumAction) self.ok = QtGui.QPushButton("OK", self) self.ok.setDefault(True) @@ -634,7 +638,7 @@ def __init__(self, config, theme, parent): self.updateUsers() @QtCore.pyqtSlot() def updateUsers(self): - names = self.mainwindow.namesdb["#pesterchum"] + names = self.mainwindow.namesdb["#PESTERCHUM"] self.userarea.clear() for n in names: item = QtGui.QListWidgetItem(n) @@ -675,8 +679,15 @@ def addChumSlot(self): if not cur: return self.addChum.emit(cur.text()) + @QtCore.pyqtSlot() + def pesterChumSlot(self): + cur = self.userarea.currentItem() + if not cur: + return + self.pesterChum.emit(cur.text()) addChum = QtCore.pyqtSignal(QtCore.QString) + pesterChum = QtCore.pyqtSignal(QtCore.QString) class MemoListItem(QtGui.QListWidgetItem): @@ -798,6 +809,6 @@ def showReconnect(self): class AboutPesterchum(QtGui.QMessageBox): def __init__(self, parent=None): QtGui.QMessageBox.__init__(self, parent) - self.setText("P3ST3RCHUM V. 3.14") - self.setInformativeText("Programming by illuminatedwax (ghostDunk), art by Grimlive (aquaMarinist). Special thanks to ABT and gamblingGenocider.") + self.setText("P3ST3RCHUM V. 3.14.1") + self.setInformativeText("Programming by illuminatedwax (ghostDunk), Kiooeht (evacipatedBox), alGore, art by Grimlive (aquaMarinist). Special thanks to ABT and gamblingGenocider.") self.mainwindow = parent diff --git a/parsetools.py b/parsetools.py index 500a143..fad5e1f 100644 --- a/parsetools.py +++ b/parsetools.py @@ -192,6 +192,15 @@ def convertTags(lexed, format="html"): def splitMessage(msg, format="ctag"): """Splits message if it is too long.""" + # split long text lines + buf = [] + for o in msg: + if type(o) in [str, unicode] and len(o) > 200: + for i in range(0, len(o), 200): + buf.append(o[i:i+200]) + else: + buf.append(o) + msg = buf okmsg = [] cbegintags = [] output = [] @@ -200,11 +209,7 @@ def splitMessage(msg, format="ctag"): if type(o) is colorBegin: cbegintags.append(o) elif type(o) is colorEnd: - print len(cbegintags) - try: - cbegintags.pop() - except IndexError: - print len(cbegintags) + cbegintags.pop() # yeah normally i'd do binary search but im lazy msglen = len(convertTags(okmsg, format)) + 4*(len(cbegintags)) if msglen > 400: diff --git a/pesterchum.js b/pesterchum.js index 6aabab5..fb794b4 100644 --- a/pesterchum.js +++ b/pesterchum.js @@ -1 +1 @@ -{"hideOfflineChums": false, "time12Format": true, "tabs": true, "showSeconds": false, "server": "irc.mindfang.org", "soundon": true, "showTimeStamps": false, "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "grayscaleVisionary", "corruptedInsanity", "stupidlyBrilliant", "artsyGyarados", "obliviousCrafter", "sporadicAgent", "subtleChaotician", "nareSolee", "apostateCourier", "nocturnalTherapist", "herpaDerp", "clockworkUtopia", "digitalSamurai", "astronomicalMaster", "slipshodBrisant", "genialDustbuster", "hyperdriveTyphoon", "magnificentMiser", "gentleRuffian", "riskRepeats", "globalsoftPrika", "globalsoftPirka", "devonianCritter", "lethargicSerpent", "laughingShisa", "bluntInstrument", "sunilaSeed", "bluntInstrument", "nickServ", "ghostBinoculars", "alGore", "evacipatedBox", "acrylicEmulator", "prettyGemmaiden", "calSprite", "fairytalePorn", "brooklynRage"], "defaultprofile": "testProfile", "block": []} +{"hideOfflineChums": false, "time12Format": true, "tabs": true, "soundon": true, "server": "irc.mindfang.org", "showSeconds": false, "showTimeStamps": false, "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "grayscaleVisionary", "corruptedInsanity", "stupidlyBrilliant", "artsyGyarados", "obliviousCrafter", "sporadicAgent", "subtleChaotician", "nareSolee", "apostateCourier", "nocturnalTherapist", "herpaDerp", "clockworkUtopia", "digitalSamurai", "astronomicalMaster", "slipshodBrisant", "genialDustbuster", "hyperdriveTyphoon", "magnificentMiser", "gentleRuffian", "riskRepeats", "globalsoftPrika", "globalsoftPirka", "devonianCritter", "lethargicSerpent", "laughingShisa", "bluntInstrument", "sunilaSeed", "bluntInstrument", "nickServ", "ghostBinoculars", "alGore", "evacipatedBox", "acrylicEmulator", "prettyGemmaiden", "calSprite", "fairytalePorn", "brooklynRage"], "defaultprofile": "testProfile", "block": []} \ No newline at end of file diff --git a/pesterchum.py b/pesterchum.py index 5965023..5cf669b 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -26,6 +26,7 @@ from logviewer import PesterLogUserSelect, PesterLogViewer _datadir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation)+"Pesterchum/" +canon_handles = ["apocalypseArisen", "arsenicCatnip", "arachnidsGrip", "adiosToreador", "caligulasAquarium", "cuttlefishCuller", "carcinoGeneticist", "centaursTesticle", "grimAuxiliatrix", "gallowsCalibrator", "gardenGnostic", "ectoBiologist", "twinArmageddons", "terminallyCapricious", "turntechGodhead", "tentacleTherapist"] if sys.platform == "darwin": if not os.path.exists(_datadir): @@ -452,6 +453,7 @@ def __init__(self, chums, parent=None): if not self.mainwindow.config.hideOfflineChums(): self.showAllChums() self.optionsMenu = QtGui.QMenu(self) + self.canonMenu = QtGui.QMenu(self) self.pester = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) self.connect(self.pester, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('activateChum()')) @@ -464,13 +466,35 @@ def __init__(self, chums, parent=None): self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self) self.connect(self.logchum, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('openChumLogs()')) + self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self) + self.connect(self.reportchum, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('reportChum()')) + self.findalts = QtGui.QAction("Find Alts", self) + self.connect(self.findalts, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('findAlts()')) + self.optionsMenu.addAction(self.pester) self.optionsMenu.addAction(self.logchum) self.optionsMenu.addAction(self.blockchum) self.optionsMenu.addAction(self.removechum) + self.optionsMenu.addAction(self.reportchum) + + + self.canonMenu.addAction(self.pester) + self.canonMenu.addAction(self.logchum) + self.canonMenu.addAction(self.blockchum) + self.canonMenu.addAction(self.removechum) + self.canonMenu.addAction(self.reportchum) + self.canonMenu.addAction(self.findalts) self.initTheme(theme) self.sortItems() + def getOptionsMenu(self): + currenthandle = self.currentItem().chum.handle + if currenthandle in canon_handles: + return self.canonMenu + else: + return self.optionsMenu def addChum(self, chum): if len([c for c in self.chums if c.handle == chum.handle]) != 0: return @@ -566,6 +590,18 @@ def blockChum(self): return self.blockChumSignal.emit(self.currentItem().chum.handle) @QtCore.pyqtSlot() + def reportChum(self): + currentChum = self.currentItem() + if not currentChum: + return + self.mainwindow.reportChum(self.currentItem().chum.handle) + @QtCore.pyqtSlot() + def findAlts(self): + currentChum = self.currentItem() + if not currentChum: + return + self.mainwindow.sendMessage.emit("ALT %s" % (currentChum.chum.handle) , "calSprite") + @QtCore.pyqtSlot() def openChumLogs(self): currentChum = self.currentItem().text() if not currentChum: @@ -910,15 +946,18 @@ def __init__(self, parent=None): self.aboutAction = QtGui.QAction(self.theme["main/menus/help/about"], self) self.connect(self.aboutAction, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('aboutPesterchum()')) + self.botAction = QtGui.QAction("CALSPRITE", self) + self.connect(self.botAction, QtCore.SIGNAL('triggered()'), + self, QtCore.SLOT('loadCalsprite()')) self.helpAction = QtGui.QAction("HELP", self) self.connect(self.helpAction, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('launchHelp()')) helpmenu = self.menu.addMenu(self.theme["main/menus/help/_name"]) self.helpmenu = helpmenu self.helpmenu.addAction(self.helpAction) + self.helpmenu.addAction(self.botAction) self.helpmenu.addAction(self.aboutAction) - self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self) self.connect(self.closeButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('closeToTray()')) @@ -1069,6 +1108,16 @@ def updateMood(self, handle, mood): if hasattr(self, 'trollslum') and self.trollslum: self.trollslum.updateMood(handle, mood) def newConversation(self, chum, initiated=True): + if type(chum) in [str, unicode]: + matchingChums = [c for c in self.chumList.chums if c.handle == chum] + if len(matchingChums) > 0: + mood = matchingChums[0].mood + else: + mood = Mood(2) + chum = PesterProfile(chum, mood=mood, chumdb=self.chumdb) + if len(matchingChums) == 0: + self.moodRequest.emit(chum) + if self.convos.has_key(chum.handle): self.convos[chum.handle].showChat() return @@ -1454,6 +1503,11 @@ def addChumWindow(self): @QtCore.pyqtSlot(QtCore.QString) def removeChum(self, chumlisting): self.config.removeChum(chumlisting) + def reportChum(self, handle): + (reason, ok) = QtGui.QInputDialog.getText(self, "Report User", "Enter the reason you are reporting this user (optional):") + if ok: + self.sendMessage.emit("REPORT %s %s" % (handle, reason) , "calSprite") + @QtCore.pyqtSlot(QtCore.QString) def blockChum(self, handle): h = unicode(handle) @@ -1613,6 +1667,8 @@ def showAllUsers(self): self, QtCore.SLOT('userListClose()')) self.connect(self.allusers, QtCore.SIGNAL('addChum(QString)'), self, QtCore.SLOT('userListAdd(QString)')) + self.connect(self.allusers, QtCore.SIGNAL('pesterChum(QString)'), + self, QtCore.SLOT('userListPester(QString)')) self.requestNames.emit("#pesterchum") self.allusers.show() @@ -1621,6 +1677,10 @@ def userListAdd(self, handle): h = unicode(handle) chum = PesterProfile(h, chumdb=self.chumdb) self.addChum(chum) + @QtCore.pyqtSlot(QtCore.QString) + def userListPester(self, handle): + h = unicode(handle) + self.newConversation(h) @QtCore.pyqtSlot() def userListClose(self): self.allusers = None @@ -1851,6 +1911,9 @@ def aboutPesterchum(self): self.aboutwindow.exec_() self.aboutwindow = None @QtCore.pyqtSlot() + def loadCalsprite(self): + self.newConversation("calSprite") + @QtCore.pyqtSlot() def launchHelp(self): QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://nova.xzibition.com/~illuminatedwax/help.html", QtCore.QUrl.TolerantMode)) diff --git a/themes/enamel/style.js b/themes/enamel/style.js index 07f8b06..b1b0c0e 100644 --- a/themes/enamel/style.js +++ b/themes/enamel/style.js @@ -35,6 +35,7 @@ "rclickchumlist": {"pester": "Pester", "removechum": "Remove Chum", "blockchum": "Block", + "report", "Report", "addchum": "Add Chum", "viewlog": "View Pesterlog", "unblockchum": "Unblock", diff --git a/themes/gold/style.js b/themes/gold/style.js index c7fb706..b8223be 100644 --- a/themes/gold/style.js +++ b/themes/gold/style.js @@ -36,6 +36,7 @@ "about": "About" }, "rclickchumlist": {"pester": "Pester", "removechum": "Remove Chum", + "report": "Report", "blockchum": "Block", "addchum": "Add Chum", "viewlog": "View Pesterlog", diff --git a/themes/pesterchum/style.js b/themes/pesterchum/style.js index eb6e9db..35127de 100644 --- a/themes/pesterchum/style.js +++ b/themes/pesterchum/style.js @@ -36,6 +36,7 @@ "about": "ABOUT" }, "rclickchumlist": {"pester": "PESTER", "removechum": "REMOVE CHUM", + "report": "REPORT", "blockchum": "BLOCK", "addchum": "ADD CHUM", "viewlog": "VIEW PESTERLOG", diff --git a/themes/trollian/style.js b/themes/trollian/style.js index 0ec8137..ac22821 100644 --- a/themes/trollian/style.js +++ b/themes/trollian/style.js @@ -34,6 +34,7 @@ "about": "About" }, "rclickchumlist": {"pester": "Troll", "removechum": "Trash", + "report": "Remove", "blockchum": "Block", "addchum": "Add Chump", "viewlog": "View Pesterlog", diff --git a/themes/typewriter/style.js b/themes/typewriter/style.js index d141d74..13306f0 100644 --- a/themes/typewriter/style.js +++ b/themes/typewriter/style.js @@ -36,6 +36,7 @@ "about": "About" }, "rclickchumlist": {"pester": "Converse", "removechum": "Erase User", + "report": "Report User", "blockchum": "Condemn", "addchum": "Add User", "viewlog": "View Pesterlog",