Support for the new randomEncounter (when it's done)
This commit is contained in:
parent
bcf389625f
commit
a99e4bb14c
12 changed files with 103 additions and 3 deletions
|
@ -39,6 +39,7 @@ CHANGELOG
|
|||
* Notify user if channel blocks message - Kiooeht [evacipatedBox]
|
||||
* Bug reporter - Kiooeht [evacipatedBox]
|
||||
* Python quirks (users can create own quirk functions) - Kiooeht [evacipatedBox]
|
||||
* Incorporate support for the new randomEncounter - Kiooeht [evacipatedBox]
|
||||
* Bug fixes
|
||||
* Logviewer updates - Kiooeht [evacipatedBox]
|
||||
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
||||
|
|
|
@ -5,7 +5,6 @@ Features
|
|||
--------
|
||||
* OOC
|
||||
* log viewer needs to have BBCode/HTML/Text copy modes
|
||||
* random pesters
|
||||
* copy quirks between profiles?
|
||||
* More complex quirks: by-sound
|
||||
* Spy mode
|
||||
|
|
8
irc.py
8
irc.py
|
@ -90,6 +90,14 @@ class PesterIRC(QtCore.QThread):
|
|||
def getMoods(self, chums):
|
||||
self.cli.command_handler.getMood(*chums)
|
||||
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
||||
def sendNotice(self, text, handle):
|
||||
h = unicode(handle)
|
||||
t = unicode(text)
|
||||
try:
|
||||
helpers.notice(self.cli, h, t)
|
||||
except socket.error:
|
||||
self.setConnectionBroken()
|
||||
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
||||
def sendMessage(self, text, handle):
|
||||
h = unicode(handle)
|
||||
textl = [unicode(text)]
|
||||
|
|
8
menus.py
8
menus.py
|
@ -69,6 +69,7 @@ class PesterQuirkList(QtGui.QTreeWidget):
|
|||
child_1.setCheckState(0,0)
|
||||
child_1.setExpanded(True)
|
||||
child_1.addChild(item)
|
||||
self.changeCheckState()
|
||||
|
||||
def currentQuirk(self):
|
||||
if type(self.currentItem()) is PesterQuirkItem:
|
||||
|
@ -152,6 +153,7 @@ class PesterQuirkList(QtGui.QTreeWidget):
|
|||
self.takeTopLevelItem(self.indexOfTopLevelItem(f))
|
||||
else:
|
||||
f.parent().takeChild(f.parent().indexOfChild(f))
|
||||
self.changeCheckState()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def addQuirkGroup(self):
|
||||
|
@ -904,6 +906,10 @@ class PesterOptions(QtGui.QDialog):
|
|||
self.updatecheck = QtGui.QCheckBox("Check for Updates on Start", self)
|
||||
self.updatecheck.setChecked(self.config.checkForUpdates())
|
||||
|
||||
if parent.randhandler.running:
|
||||
self.randomscheck = QtGui.QCheckBox("Receive Random Encounters")
|
||||
self.randomscheck.setChecked(parent.userprofile.randoms)
|
||||
|
||||
avail_themes = self.config.availableThemes()
|
||||
self.themeBox = QtGui.QComboBox(self)
|
||||
for (i, t) in enumerate(avail_themes):
|
||||
|
@ -964,6 +970,8 @@ class PesterOptions(QtGui.QDialog):
|
|||
layout_chat.addWidget(self.memomessagecheck)
|
||||
layout_chat.addWidget(self.animationscheck)
|
||||
layout_chat.addWidget(animateLabel)
|
||||
if parent.randhandler.running:
|
||||
layout_chat.addWidget(self.randomscheck)
|
||||
# Re-enable these when it's possible to disable User and Memo links
|
||||
#layout_chat.addWidget(hr)
|
||||
#layout_chat.addWidget(QtGui.QLabel("User and Memo Links"))
|
||||
|
|
|
@ -490,7 +490,8 @@ def themeChecker(theme):
|
|||
"convo/text/closememo", "convo/text/kickedmemo", \
|
||||
"main/chums/userlistcolor", "main/defaultwindow/style", \
|
||||
"main/chums/moods", "main/chums/moods/chummy/icon", "main/menus/help/help", \
|
||||
"main/menus/help/calsprite", "main/menus/help/nickserv", "main/menus/rclickchumlist/invitechum"]
|
||||
"main/menus/help/calsprite", "main/menus/help/nickserv", \
|
||||
"main/menus/rclickchumlist/invitechum", "main/menus/client/randen"]
|
||||
|
||||
for n in needs:
|
||||
try:
|
||||
|
|
|
@ -53,6 +53,7 @@ from memos import PesterMemo, MemoTabWindow, TimeTracker
|
|||
from irc import PesterIRC
|
||||
from logviewer import PesterLogUserSelect, PesterLogViewer
|
||||
from bugreport import BugReporter
|
||||
from randomer import RandomHandler
|
||||
|
||||
_datadir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation)+"Pesterchum/"
|
||||
canon_handles = ["apocalypseArisen", "arsenicCatnip", "arachnidsGrip", "adiosToreador", \
|
||||
|
@ -534,6 +535,7 @@ class userProfile(object):
|
|||
self.chat.mood = Mood(self.theme["main/defaultmood"])
|
||||
self.lastmood = self.chat.mood.value()
|
||||
self.quirks = pesterQuirks([])
|
||||
self.randoms = False
|
||||
else:
|
||||
fp = open("%s/%s.js" % (self.profiledir, user))
|
||||
self.userprofile = json.load(fp)
|
||||
|
@ -547,6 +549,9 @@ class userProfile(object):
|
|||
QtGui.QColor(self.userprofile["color"]),
|
||||
Mood(self.lastmood))
|
||||
self.quirks = pesterQuirks(self.userprofile["quirks"])
|
||||
if "randoms" not in self.userprofile:
|
||||
self.userprofile["randoms"] = False
|
||||
self.randoms = self.userprofile["randoms"]
|
||||
|
||||
def setMood(self, mood):
|
||||
self.chat.mood = mood
|
||||
|
@ -562,6 +567,10 @@ class userProfile(object):
|
|||
self.quirks = quirks
|
||||
self.userprofile["quirks"] = self.quirks.plainList()
|
||||
self.save()
|
||||
def setRandom(self, random):
|
||||
self.randoms = random
|
||||
self.userprofile["randoms"] = random
|
||||
self.save()
|
||||
def getLastMood(self):
|
||||
return self.lastmood
|
||||
def setLastMood(self, mood):
|
||||
|
@ -1407,6 +1416,8 @@ class PesterWindow(MovingWindow):
|
|||
self.theme = self.userprofile.getTheme()
|
||||
self.modes = ""
|
||||
|
||||
self.randhandler = RandomHandler(self)
|
||||
|
||||
try:
|
||||
themeChecker(self.theme)
|
||||
except ThemeException, (inst):
|
||||
|
@ -1428,6 +1439,9 @@ class PesterWindow(MovingWindow):
|
|||
self.grps = grps
|
||||
self.connect(grps, QtCore.SIGNAL('triggered()'),
|
||||
self, QtCore.SLOT('addGroupWindow()'))
|
||||
self.rand = QtGui.QAction(self.theme["main/menus/client/randen"], self)
|
||||
self.connect(self.rand, QtCore.SIGNAL('triggered()'),
|
||||
self.randhandler, QtCore.SLOT('getEncounter()'))
|
||||
opts = QtGui.QAction(self.theme["main/menus/client/options"], self)
|
||||
self.opts = opts
|
||||
self.connect(opts, QtCore.SIGNAL('triggered()'),
|
||||
|
@ -1463,6 +1477,8 @@ class PesterWindow(MovingWindow):
|
|||
filemenu.addAction(opts)
|
||||
filemenu.addAction(memoaction)
|
||||
filemenu.addAction(logv)
|
||||
if self.randhandler.running:
|
||||
filemenu.addAction(self.rand)
|
||||
filemenu.addAction(userlistaction)
|
||||
filemenu.addAction(self.idleaction)
|
||||
filemenu.addAction(grps)
|
||||
|
@ -1829,6 +1845,7 @@ class PesterWindow(MovingWindow):
|
|||
self.menu.move(*theme["main/menu/loc"])
|
||||
self.logv.setText(theme["main/menus/client/logviewer"])
|
||||
self.grps.setText(theme["main/menus/client/addgroup"])
|
||||
self.rand.setText(self.theme["main/menus/client/randen"])
|
||||
self.opts.setText(theme["main/menus/client/options"])
|
||||
self.exitaction.setText(theme["main/menus/client/exit"])
|
||||
self.userlistaction.setText(theme["main/menus/client/userlist"])
|
||||
|
@ -2056,7 +2073,9 @@ class PesterWindow(MovingWindow):
|
|||
def deliverNotice(self, handle, msg):
|
||||
h = unicode(handle)
|
||||
m = unicode(msg)
|
||||
if self.convos.has_key(h):
|
||||
if h == self.randhandler.randNick:
|
||||
self.randhandler.incoming(msg)
|
||||
elif self.convos.has_key(h):
|
||||
self.newMessage(h, m)
|
||||
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
||||
def deliverInvite(self, handle, channel):
|
||||
|
@ -2552,6 +2571,8 @@ class PesterWindow(MovingWindow):
|
|||
self.idlethreshold = 60*idlesetting
|
||||
# theme
|
||||
self.themeSelected()
|
||||
# randoms
|
||||
self.randhandler.setRandomer(self.optionmenu.randomscheck.isChecked())
|
||||
# button actions
|
||||
minisetting = self.optionmenu.miniBox.currentIndex()
|
||||
curmini = self.config.minimizeAction()
|
||||
|
@ -2760,6 +2781,7 @@ class PesterWindow(MovingWindow):
|
|||
closeToTraySignal = QtCore.pyqtSignal()
|
||||
newConvoStarted = QtCore.pyqtSignal(QtCore.QString, bool, name="newConvoStarted")
|
||||
sendMessage = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
|
||||
sendNotice = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
|
||||
convoClosed = QtCore.pyqtSignal(QtCore.QString)
|
||||
profileChanged = QtCore.pyqtSignal()
|
||||
moodRequest = QtCore.pyqtSignal(PesterProfile)
|
||||
|
@ -2876,6 +2898,8 @@ class MainProgram(QtCore.QObject):
|
|||
|
||||
widget2irc = [('sendMessage(QString, QString)',
|
||||
'sendMessage(QString, QString)'),
|
||||
('sendNotice(QString, QString)',
|
||||
'sendNotice(QString, QString)'),
|
||||
('newConvoStarted(QString, bool)',
|
||||
'startConvo(QString, bool)'),
|
||||
('convoClosed(QString)',
|
||||
|
|
54
randomer.py
Normal file
54
randomer.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
class RandomHandler(QtCore.QObject):
|
||||
def __init__(self, parent):
|
||||
QtCore.QObject.__init__(self, parent)
|
||||
self.randNick = "randomEncounter"
|
||||
self.mainwindow = parent
|
||||
self.queue = []
|
||||
# Make True when Lex's new randomEncounter bot (C++) is online
|
||||
self.running = False
|
||||
|
||||
def getRandomer(self):
|
||||
self.queue.append("?")
|
||||
self.mainwindow.sendNotice.emit("?", self.randNick)
|
||||
|
||||
def setRandomer(self, r):
|
||||
if r: code = "+"
|
||||
else: code = "-"
|
||||
self.queue.append(code)
|
||||
self.mainwindow.sendNotice.emit(code, self.randNick)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def getEncounter(self):
|
||||
self.queue.append("!")
|
||||
self.mainwindow.sendNotice.emit("!", self.randNick)
|
||||
|
||||
def incoming(self, msg):
|
||||
l = msg.split("=")
|
||||
code = l[0][0]
|
||||
if code not in self.queue:
|
||||
return # Ignore if we didn't request this
|
||||
self.queue.remove(code)
|
||||
if code == "?":
|
||||
if l[1][0] == "y":
|
||||
self.mainwindow.userprofile.setRandom(True)
|
||||
elif l[1][0] == "n":
|
||||
self.mainwindow.userprofile.setRandom(False)
|
||||
elif code in ["+","-"]:
|
||||
if l[1][0] == "k":
|
||||
if code == "+":
|
||||
self.mainwindow.userprofile.setRandom(True)
|
||||
else:
|
||||
self.mainwindow.userprofile.setRandom(False)
|
||||
elif code == "!":
|
||||
if l[1] == "x":
|
||||
from PyQt4 import QtGui
|
||||
msgbox = QtGui.QMessageBox()
|
||||
msgbox.setText("Unable to fetch you a random encounter!")
|
||||
msgbox.setInformativeText("Try again later :(")
|
||||
msgbox.exec_()
|
||||
return
|
||||
name = unicode(l[1])
|
||||
print name
|
||||
self.mainwindow.newConversation(name)
|
|
@ -19,6 +19,7 @@
|
|||
"options": "Options",
|
||||
"memos": "Memos",
|
||||
"logviewer": "Pesterlogs",
|
||||
"randen": "Random Encounter",
|
||||
"userlist": "Userlist",
|
||||
"addgroup": "Add Group",
|
||||
"import": "Import",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"options": "Options",
|
||||
"memos": "Memos",
|
||||
"logviewer": "Pesterlogs",
|
||||
"randen": "Random Encounter",
|
||||
"userlist": "Userlist",
|
||||
"addgroup": "Add Group",
|
||||
"import": "Import",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"options": "OPTIONS",
|
||||
"memos": "MEMOS",
|
||||
"logviewer": "PESTERLOGS",
|
||||
"randen": "RANDOM ENCOUNTER",
|
||||
"userlist": "USERLIST",
|
||||
"addgroup": "ADD GROUP",
|
||||
"import": "IMPORT",
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
"options": "Options",
|
||||
"memos": "Memos",
|
||||
"logviewer": "Pesterlogs",
|
||||
"randen": "Random Encounter",
|
||||
"userlist": "Fresh Targets",
|
||||
"addgroup": "Add Group",
|
||||
"import": "import U2;",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"options": "Preferences",
|
||||
"memos": "Bulletin Boards",
|
||||
"logviewer": "Pesterlogs",
|
||||
"randen": "Random Encounter",
|
||||
"userlist": "Userlist",
|
||||
"addgroup": "Add Group",
|
||||
"import": "Import",
|
||||
|
|
Loading…
Reference in a new issue