MSPA update notifier
This commit is contained in:
parent
d1920d2cca
commit
545746b911
7 changed files with 3000 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ irctest.log
|
|||
pesterchum.js
|
||||
quirks/*
|
||||
!quirks/defaults.py
|
||||
*.pkl
|
||||
|
|
|
@ -49,6 +49,7 @@ CHANGELOG
|
|||
* Ctrl + click to copy links - Kiooeht [evacipatedBox]
|
||||
* Say something when server is full - Kiooeht [evacipatedBox]
|
||||
* Ping server if no ping from server to test connection - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
|
||||
* MSPA comic update notifier - Kiooeht [evacipatedBox]
|
||||
* Bug fixes
|
||||
* Logviewer updates - Kiooeht [evacipatedBox]
|
||||
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
||||
|
|
|
@ -10,9 +10,9 @@ Features
|
|||
* Spy mode
|
||||
* Turn @ and # links on/off?
|
||||
* "someone has friended you" notifier
|
||||
* MSPA update notifier option
|
||||
* Show true bans?
|
||||
* Colour saving boxes things?
|
||||
* Chum notes?
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
|
2858
feedparser.py
Executable file
2858
feedparser.py
Executable file
File diff suppressed because it is too large
Load diff
8
menus.py
8
menus.py
|
@ -1035,6 +1035,9 @@ class PesterOptions(QtGui.QDialog):
|
|||
layout_6.addWidget(QtGui.QLabel("Check for\nPesterchum Updates:"))
|
||||
layout_6.addWidget(self.updateBox)
|
||||
|
||||
self.mspaCheck = QtGui.QCheckBox("Check for MSPA Updates", self)
|
||||
self.mspaCheck.setChecked(self.config.checkMSPA())
|
||||
|
||||
if parent.randhandler.running:
|
||||
self.randomscheck = QtGui.QCheckBox("Receive Random Encounters")
|
||||
self.randomscheck.setChecked(parent.userprofile.randoms)
|
||||
|
@ -1145,6 +1148,7 @@ class PesterOptions(QtGui.QDialog):
|
|||
layout_idle.setAlignment(QtCore.Qt.AlignTop)
|
||||
layout_idle.addLayout(layout_5)
|
||||
layout_idle.addLayout(layout_6)
|
||||
layout_idle.addWidget(self.mspaCheck)
|
||||
self.pages.addWidget(widget)
|
||||
|
||||
# Theme
|
||||
|
@ -1437,7 +1441,9 @@ Art by:\n\
|
|||
\n\
|
||||
Special Thanks:\n\
|
||||
ABT\n\
|
||||
gamblingGenocider")
|
||||
gamblingGenocider\n\
|
||||
Lexi (lexicalNuance)\n\
|
||||
Eco-Mono")
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
|
|
|
@ -54,6 +54,7 @@ from irc import PesterIRC
|
|||
from logviewer import PesterLogUserSelect, PesterLogViewer
|
||||
from bugreport import BugReporter
|
||||
from randomer import RandomHandler
|
||||
from updatecheck import MSPAChecker
|
||||
|
||||
_datadir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation)+"Pesterchum/"
|
||||
canon_handles = ["apocalypseArisen", "arsenicCatnip", "arachnidsGrip", "adiosToreador", \
|
||||
|
@ -419,6 +420,8 @@ class userConfig(object):
|
|||
# Never
|
||||
def lastUCheck(self):
|
||||
return self.config.get('lastUCheck', 0)
|
||||
def checkMSPA(self):
|
||||
return self.config.get('mspa', False)
|
||||
def addChum(self, chum):
|
||||
if chum.handle not in self.chums():
|
||||
fp = open(self.filename) # what if we have two clients open??
|
||||
|
@ -1638,6 +1641,8 @@ class PesterWindow(MovingWindow):
|
|||
if not self.config.defaultprofile():
|
||||
self.changeProfile()
|
||||
|
||||
QtCore.QTimer.singleShot(1000, self, QtCore.SLOT('mspacheck()'))
|
||||
|
||||
self.connect(self, QtCore.SIGNAL('pcUpdate(QString, QString)'),
|
||||
self, QtCore.SLOT('updateMsg(QString, QString)'))
|
||||
|
||||
|
@ -1647,6 +1652,10 @@ class PesterWindow(MovingWindow):
|
|||
self.lastping = int(time())
|
||||
self.pingtimer.start(1000*10)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def mspacheck(self):
|
||||
checker = MSPAChecker(self)
|
||||
|
||||
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
||||
def updateMsg(self, ver, url):
|
||||
if not hasattr(self, 'updatemenu'):
|
||||
|
@ -2677,6 +2686,11 @@ class PesterWindow(MovingWindow):
|
|||
curupdatecheck = self.config.checkForUpdates()
|
||||
if updatechecksetting != curupdatecheck:
|
||||
self.config.set('checkUpdates', updatechecksetting)
|
||||
# mspa update check
|
||||
mspachecksetting = self.optionmenu.mspaCheck.isChecked()
|
||||
curmspacheck = self.config.checkMSPA()
|
||||
if mspachecksetting != curmspacheck:
|
||||
self.config.set('mspa', mspachecksetting)
|
||||
# advanced
|
||||
## user mode
|
||||
if self.advanced:
|
||||
|
|
118
updatecheck.py
Normal file
118
updatecheck.py
Normal file
|
@ -0,0 +1,118 @@
|
|||
# Adapted from Eco-Mono's F5Stuck RSS Client
|
||||
|
||||
import feedparser
|
||||
import pickle
|
||||
import os
|
||||
from time import mktime
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
class MSPAChecker(QtGui.QWidget):
|
||||
def __init__(self, parent=None):
|
||||
QtCore.QObject.__init__(self, parent)
|
||||
self.mainwindow = parent
|
||||
self.refreshRate = 30 # seconds
|
||||
self.status = None
|
||||
self.timer = QtCore.QTimer(self)
|
||||
self.connect(self.timer, QtCore.SIGNAL('timeout()'),
|
||||
self, QtCore.SLOT('check_site()'))
|
||||
self.check_site()
|
||||
self.timer.start(1000*self.refreshRate)
|
||||
|
||||
def save_state(self):
|
||||
try:
|
||||
current_status = open("status_new.pkl","w")
|
||||
pickle.dump(self.status, current_status)
|
||||
current_status.close()
|
||||
try:
|
||||
os.rename("status.pkl","status_old.pkl")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
os.rename("status_new.pkl","status.pkl")
|
||||
except:
|
||||
if os.path.exists("status_old.pkl"):
|
||||
os.rename("status_old.pkl","status.pkl")
|
||||
raise
|
||||
if os.path.exists("status_old.pkl"):
|
||||
os.remove("status_old.pkl")
|
||||
except Exception, e:
|
||||
print e
|
||||
msg = QtGui.QMessageBox(self)
|
||||
msg.setText("Problems writing save file.")
|
||||
msg.show()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def check_site(self):
|
||||
if not self.mainwindow.config.checkMSPA():
|
||||
return
|
||||
rss = None
|
||||
must_save = False
|
||||
try:
|
||||
rss = feedparser.parse("http://www.mspaintadventures.com/rss/rss.xml")
|
||||
except:
|
||||
return
|
||||
if len(rss.entries) == 0:
|
||||
return
|
||||
entries = sorted(rss.entries,key=(lambda x: mktime(x.updated_parsed)))
|
||||
if self.status == None:
|
||||
self.status = {}
|
||||
self.status['last_visited'] = {'pubdate':mktime(entries[-1].updated_parsed),'link':entries[-1].link}
|
||||
self.status['last_seen'] = {'pubdate':mktime(entries[-1].updated_parsed),'link':entries[-1].link}
|
||||
must_save = True
|
||||
elif mktime(entries[-1].updated_parsed) > self.status['last_seen']['pubdate']:
|
||||
#This is the first time the app itself has noticed this update.
|
||||
self.status['last_seen'] = {'pubdate':mktime(entries[-1].updated_parsed),'link':entries[-1].link}
|
||||
must_save = True
|
||||
if self.status['last_seen']['pubdate'] > self.status['last_visited']['pubdate']:
|
||||
self.mspa = MSPAUpdateWindow(self.parent())
|
||||
self.connect(self.mspa, QtCore.SIGNAL('accepted()'),
|
||||
self, QtCore.SLOT('visit_site()'))
|
||||
self.connect(self.mspa, QtCore.SIGNAL('rejected()'),
|
||||
self, QtCore.SLOT('nothing()'))
|
||||
self.mspa.show()
|
||||
else:
|
||||
#print "No new updates :("
|
||||
pass
|
||||
if must_save:
|
||||
self.save_state()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def visit_site(self):
|
||||
print self.status['last_visited']['link']
|
||||
QtGui.QDesktopServices.openUrl(QtCore.QUrl(self.status['last_visited']['link'], QtCore.QUrl.TolerantMode))
|
||||
if self.status['last_seen']['pubdate'] > self.status['last_visited']['pubdate']:
|
||||
#Visited for the first time. Untrip the icon and remember that we saw it.
|
||||
self.status['last_visited'] = self.status['last_seen']
|
||||
self.save_state()
|
||||
self.mspa = None
|
||||
@QtCore.pyqtSlot()
|
||||
def nothing(self):
|
||||
self.mspa = None
|
||||
|
||||
class MSPAUpdateWindow(QtGui.QDialog):
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.mainwindow = parent
|
||||
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
||||
self.setWindowTitle("MSPA Update!")
|
||||
self.setModal(False)
|
||||
|
||||
self.title = QtGui.QLabel("You have an unread MSPA update! :o)")
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(self.title)
|
||||
|
||||
self.ok = QtGui.QPushButton("GO READ NOW!", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("LATER", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_2 = QtGui.QHBoxLayout()
|
||||
layout_2.addWidget(self.cancel)
|
||||
layout_2.addWidget(self.ok)
|
||||
|
||||
layout_0.addLayout(layout_2)
|
||||
|
||||
self.setLayout(layout_0)
|
Loading…
Reference in a new issue