Disable random encounter options when bot is offline

This commit is contained in:
Kiooeht 2011-08-29 01:56:44 -07:00
parent 6267fc071c
commit 85c01da1fd
7 changed files with 26 additions and 12 deletions

View file

@ -30,6 +30,7 @@ CHANGELOG
* Explain why a chumhandle is invalid - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance]) * Explain why a chumhandle is invalid - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
* Netsplit notification in memos - Kiooeht [evacipatedBox] * Netsplit notification in memos - Kiooeht [evacipatedBox]
* Toast Notifications - Kiooeht [evacipatedBox] * Toast Notifications - Kiooeht [evacipatedBox]
* Disable randomEncounter options when it's offline - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
* Bug fixes * Bug fixes
* Don't delete random chum when blocking someone not on chumroll - Kiooeht [evacipatedBox] * Don't delete random chum when blocking someone not on chumroll - Kiooeht [evacipatedBox]
* Openning global userlist doesn't reset OP status of memo users - Kiooeht [evacipatedBox] * Openning global userlist doesn't reset OP status of memo users - Kiooeht [evacipatedBox]

View file

@ -17,7 +17,6 @@ Features
* When 'banned' make impossible to connect using timestamp banned under * When 'banned' make impossible to connect using timestamp banned under
* Auto download/install updates via Windows installer * Auto download/install updates via Windows installer
* Turn memo notifications on/off from right-click menu on memos (Idea: lostGash) * Turn memo notifications on/off from right-click menu on memos (Idea: lostGash)
* Gray out random encounter option when RE is offline
Bugs Bugs
---- ----

11
irc.py
View file

@ -400,8 +400,10 @@ class PesterHandler(DefaultCommandHandler):
helpers.nick(self.client, newnick) helpers.nick(self.client, newnick)
self.parent.nickCollision.emit(nick, newnick) self.parent.nickCollision.emit(nick, newnick)
def quit(self, nick, reason): def quit(self, nick, reason):
#print reason
handle = nick[0:nick.find("!")] handle = nick[0:nick.find("!")]
logging.info("---> recv \"QUIT %s: %s\"" % (handle, reason))
if handle == self.parent.mainwindow.randhandler.randNick:
self.parent.mainwindow.randhandler.setRunning(False)
server = self.parent.mainwindow.config.server() server = self.parent.mainwindow.config.server()
baseserver = server[server.rfind(".", 0, server.rfind(".")):] baseserver = server[server.rfind(".", 0, server.rfind(".")):]
if reason.count(baseserver) == 2: if reason.count(baseserver) == 2:
@ -424,6 +426,8 @@ class PesterHandler(DefaultCommandHandler):
logging.info("---> recv \"JOIN %s: %s\"" % (handle, channel)) logging.info("---> recv \"JOIN %s: %s\"" % (handle, channel))
self.parent.userPresentUpdate.emit(handle, channel, "join") self.parent.userPresentUpdate.emit(handle, channel, "join")
if channel == "#pesterchum": if channel == "#pesterchum":
if handle == self.parent.mainwindow.randhandler.randNick:
self.parent.mainwindow.randhandler.setRunning(True)
self.parent.moodUpdated.emit(handle, Mood("chummy")) self.parent.moodUpdated.emit(handle, Mood("chummy"))
def mode(self, op, channel, mode, *handles): def mode(self, op, channel, mode, *handles):
if len(handles) <= 0: handles = [""] if len(handles) <= 0: handles = [""]
@ -463,6 +467,10 @@ class PesterHandler(DefaultCommandHandler):
self.parent.userPresentUpdate.emit("%s:%s" % (oldhandle, newnick), "", "nick") self.parent.userPresentUpdate.emit("%s:%s" % (oldhandle, newnick), "", "nick")
if newnick in self.mainwindow.chumList.chums: if newnick in self.mainwindow.chumList.chums:
self.getMood(newchum) self.getMood(newchum)
if oldhandle == self.parent.mainwindow.randhandler.randNick:
self.parent.mainwindow.randhandler.setRunning(False)
elif newnick == self.parent.mainwindow.randhandler.randNick:
self.parent.mainwindow.randhandler.setRunning(True)
def namreply(self, server, nick, op, channel, names): def namreply(self, server, nick, op, channel, names):
namelist = names.split(" ") namelist = names.split(" ")
logging.info("---> recv \"NAMES %s: %d names\"" % (channel, len(namelist))) logging.info("---> recv \"NAMES %s: %d names\"" % (channel, len(namelist)))
@ -478,6 +486,7 @@ class PesterHandler(DefaultCommandHandler):
self.parent.namesReceived.emit(channel, pl) self.parent.namesReceived.emit(channel, pl)
if channel == "#pesterchum" and not hasattr(self, "joined"): if channel == "#pesterchum" and not hasattr(self, "joined"):
self.joined = True self.joined = True
self.parent.mainwindow.randhandler.setRunning(self.parent.mainwindow.randhandler.randNick in namelist)
chums = self.mainwindow.chumList.chums chums = self.mainwindow.chumList.chums
lesschums = [] lesschums = []
for c in chums: for c in chums:

View file

@ -1140,9 +1140,10 @@ class PesterOptions(QtGui.QDialog):
self.mspaCheck = QtGui.QCheckBox("Check for MSPA Updates", self) self.mspaCheck = QtGui.QCheckBox("Check for MSPA Updates", self)
self.mspaCheck.setChecked(self.config.checkMSPA()) self.mspaCheck.setChecked(self.config.checkMSPA())
if parent.randhandler.running: self.randomscheck = QtGui.QCheckBox("Receive Random Encounters")
self.randomscheck = QtGui.QCheckBox("Receive Random Encounters") self.randomscheck.setChecked(parent.userprofile.randoms)
self.randomscheck.setChecked(parent.userprofile.randoms) if not parent.randhandler.running:
self.randomscheck.setEnabled(False)
avail_themes = self.config.availableThemes() avail_themes = self.config.availableThemes()
self.themeBox = QtGui.QComboBox(self) self.themeBox = QtGui.QComboBox(self)
@ -1246,8 +1247,7 @@ class PesterOptions(QtGui.QDialog):
if not ostools.isOSXBundle(): if not ostools.isOSXBundle():
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)
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"))

View file

@ -1663,8 +1663,9 @@ 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(self.rand) if not self.randhandler.running:
self.rand.setEnabled(False)
filemenu.addAction(userlistaction) filemenu.addAction(userlistaction)
filemenu.addAction(self.idleaction) filemenu.addAction(self.idleaction)
filemenu.addAction(grps) filemenu.addAction(grps)
@ -2072,7 +2073,7 @@ class PesterWindow(MovingWindow):
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"]) self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
self.backgroundMask = self.backgroundImage.mask() self.backgroundMask = self.backgroundImage.mask()
self.setMask(self.backgroundMask) self.setMask(self.backgroundMask)
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s }" % (theme["main/menu/style"], theme["main/menu/selected"])) self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"]))
newcloseicon = PesterIcon(theme["main/close/image"]) newcloseicon = PesterIcon(theme["main/close/image"])
self.closeButton.setIcon(newcloseicon) self.closeButton.setIcon(newcloseicon)
self.closeButton.setIconSize(newcloseicon.realsize()) self.closeButton.setIconSize(newcloseicon.realsize())

View file

@ -6,8 +6,11 @@ class RandomHandler(QtCore.QObject):
self.randNick = "randomEncounter" self.randNick = "randomEncounter"
self.mainwindow = parent self.mainwindow = parent
self.queue = [] self.queue = []
# Make True when Lex's new randomEncounter bot (C++) is online self.running = False
self.running = True
def setRunning(self, on):
self.running = on
self.mainwindow.rand.setEnabled(on)
def getRandomer(self): def getRandomer(self):
self.queue.append("?") self.queue.append("?")

View file

@ -13,6 +13,7 @@
"menu" : { "style": "font-family: 'Courier'; font: bold; font-size: 12px; color: black; background-color: #fdb302;border:2px solid #ffff00", "menu" : { "style": "font-family: 'Courier'; font: bold; font-size: 12px; color: black; background-color: #fdb302;border:2px solid #ffff00",
"menuitem": "margin-right:10px;", "menuitem": "margin-right:10px;",
"selected": "background-color: #ffff00", "selected": "background-color: #ffff00",
"disabled": "color: grey",
"loc": [10,0] "loc": [10,0]
}, },
"sounds": { "alertsound": "$path/alarm.wav", "sounds": { "alertsound": "$path/alarm.wav",