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