Skip to content

Commit

Permalink
derp
Browse files Browse the repository at this point in the history
  • Loading branch information
illuminatedwax committed Apr 13, 2011
1 parent b389651 commit 4b504a0
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.mkdn
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions convo.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion generic.py
Expand Up @@ -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):
Expand Down
17 changes: 14 additions & 3 deletions menus.py
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
15 changes: 10 additions & 5 deletions parsetools.py
Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pesterchum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 64 additions & 1 deletion pesterchum.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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()'))
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()'))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions themes/enamel/style.js
Expand Up @@ -35,6 +35,7 @@
"rclickchumlist": {"pester": "Pester",
"removechum": "Remove Chum",
"blockchum": "Block",
"report", "Report",
"addchum": "Add Chum",
"viewlog": "View Pesterlog",
"unblockchum": "Unblock",
Expand Down
1 change: 1 addition & 0 deletions themes/gold/style.js
Expand Up @@ -36,6 +36,7 @@
"about": "About" },
"rclickchumlist": {"pester": "Pester",
"removechum": "Remove Chum",
"report": "Report",
"blockchum": "Block",
"addchum": "Add Chum",
"viewlog": "View Pesterlog",
Expand Down
1 change: 1 addition & 0 deletions themes/pesterchum/style.js
Expand Up @@ -36,6 +36,7 @@
"about": "ABOUT" },
"rclickchumlist": {"pester": "PESTER",
"removechum": "REMOVE CHUM",
"report": "REPORT",
"blockchum": "BLOCK",
"addchum": "ADD CHUM",
"viewlog": "VIEW PESTERLOG",
Expand Down
1 change: 1 addition & 0 deletions themes/trollian/style.js
Expand Up @@ -34,6 +34,7 @@
"about": "About" },
"rclickchumlist": {"pester": "Troll",
"removechum": "Trash",
"report": "Remove",
"blockchum": "Block",
"addchum": "Add Chump",
"viewlog": "View Pesterlog",
Expand Down
1 change: 1 addition & 0 deletions themes/typewriter/style.js
Expand Up @@ -36,6 +36,7 @@
"about": "About" },
"rclickchumlist": {"pester": "Converse",
"removechum": "Erase User",
"report": "Report User",
"blockchum": "Condemn",
"addchum": "Add User",
"viewlog": "View Pesterlog",
Expand Down

0 comments on commit 4b504a0

Please sign in to comment.