Merge branch 'master' of git://github.com/kiooeht/pesterchum

This commit is contained in:
Lexi 2011-07-23 23:02:16 +01:00
commit 5afff509a6
9 changed files with 69 additions and 18 deletions

View file

@ -58,6 +58,7 @@ CHANGELOG
* Display channel mode change message - Kiooeht [evacipatedBox] * Display channel mode change message - Kiooeht [evacipatedBox]
* Disable quirks in +c memos - Lexi [lexicalNuance] * Disable quirks in +c memos - Lexi [lexicalNuance]
* Founder, admin, and halfop support - Kiooeht [evacipatedBox] * Founder, admin, and halfop support - Kiooeht [evacipatedBox]
* Button for direct access to logs directory - Kiooeht [evacipatedBox]
* Bug fixes * Bug fixes
* Logviewer updates - Kiooeht [evacipatedBox] * Logviewer updates - Kiooeht [evacipatedBox]
* Memo scrollbar thing - Kiooeht [evacipatedBox] * Memo scrollbar thing - Kiooeht [evacipatedBox]

View file

@ -34,7 +34,6 @@ Bugs
* right clicking an offline chum and choosing remove asks you why you're reporting someone, and if you hit cancel the menus stop working * right clicking an offline chum and choosing remove asks you why you're reporting someone, and if you hit cancel the menus stop working
* Closing a timeclone doesn't actually cease for everyone else * Closing a timeclone doesn't actually cease for everyone else
* Kill Zalgo * Kill Zalgo
* Handle netsplits
Windows Bugs Windows Bugs
------------ ------------

View file

@ -236,6 +236,8 @@ class PesterProfile(object):
return "<c=%s><c=%s>%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), ", ".join(initials), verb) return "<c=%s><c=%s>%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), ", ".join(initials), verb)
else: else:
return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), initials.pcf, self.initials(), initials.number, verb) return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), initials.pcf, self.initials(), initials.number, verb)
def memonetsplitmsg(self, syscolor, initials):
return "<c=%s>Netsplit quits: <c=black>%s</c></c>" % (syscolor.name(), ", ".join(initials))
def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel): def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel):
(temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when) (temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when)
timetext = timeDifference(td) timetext = timeDifference(td)

6
irc.py
View file

@ -396,7 +396,13 @@ 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("!")]
server = self.parent.mainwindow.config.server()
baseserver = server[server.rfind(".", 0, server.rfind(".")):]
if reason.count(baseserver) == 2:
self.parent.userPresentUpdate.emit(handle, "", "netsplit")
else:
self.parent.userPresentUpdate.emit(handle, "", "quit") self.parent.userPresentUpdate.emit(handle, "", "quit")
self.parent.moodUpdated.emit(handle, Mood("offline")) self.parent.moodUpdated.emit(handle, Mood("offline"))
def kick(self, opnick, channel, handle, reason): def kick(self, opnick, channel, handle, reason):

View file

@ -83,12 +83,16 @@ class PesterLogUserSelect(QtGui.QDialog):
layout_ok = QtGui.QHBoxLayout() layout_ok = QtGui.QHBoxLayout()
layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.cancel)
layout_ok.addWidget(self.ok) layout_ok.addWidget(self.ok)
self.directory = QtGui.QPushButton("LOG DIRECTORY", self)
self.connect(self.directory, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('openDir()'))
layout_0 = QtGui.QVBoxLayout() layout_0 = QtGui.QVBoxLayout()
layout_0.addWidget(instructions) layout_0.addWidget(instructions)
layout_0.addWidget(self.chumsBox) layout_0.addWidget(self.chumsBox)
layout_0.addWidget(self.search) layout_0.addWidget(self.search)
layout_0.addLayout(layout_ok) layout_0.addLayout(layout_ok)
layout_0.addWidget(self.directory)
self.setLayout(layout_0) self.setLayout(layout_0)
@ -119,6 +123,14 @@ class PesterLogUserSelect(QtGui.QDialog):
self.pesterlogviewer.close() self.pesterlogviewer.close()
self.pesterlogviewer = None self.pesterlogviewer = None
@QtCore.pyqtSlot()
def openDir(self):
if sys.platform == "darwin":
_datadir = os.path.join(str(QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation)),"Pesterchum/")
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(_datadir, "logs"), QtCore.QUrl.TolerantMode))
else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(os.getcwd(), "logs"), QtCore.QUrl.TolerantMode))
class PesterLogViewer(QtGui.QDialog): class PesterLogViewer(QtGui.QDialog):
def __init__(self, chum, config, theme, parent): def __init__(self, chum, config, theme, parent):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)

View file

@ -876,6 +876,15 @@ class PesterMemo(PesterConvo):
icon = QtGui.QIcon() icon = QtGui.QIcon()
c.setIcon(icon) c.setIcon(icon)
@QtCore.pyqtSlot()
def dumpNetsplit(self):
chum = self.mainwindow.profile()
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
msg = chum.memonetsplitmsg(systemColor, self.netsplit)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
del self.netsplit
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
def userPresentChange(self, handle, channel, update): def userPresentChange(self, handle, channel, update):
h = unicode(handle) h = unicode(handle)
@ -903,7 +912,11 @@ class PesterMemo(PesterConvo):
chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0)) chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0))
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
# print exit # print exit
if update == "quit" or update == "left" or update == "nick": if update in ("quit", "left", "nick", "netsplit"):
if update == "netsplit":
if not hasattr(self, "netsplit"):
self.netsplit = []
QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()'))
for c in chums: for c in chums:
chum = PesterProfile(h) chum = PesterProfile(h)
self.userlist.takeItem(self.userlist.row(c)) self.userlist.takeItem(self.userlist.row(c))
@ -915,6 +928,9 @@ class PesterMemo(PesterConvo):
grammar = t.getGrammar() grammar = t.getGrammar()
allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number)) allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number))
self.times[h].removeTime(t.getTime()) self.times[h].removeTime(t.getTime())
if update == "netsplit":
self.netsplit.extend(initials)
else:
msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"])
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)

View file

@ -609,6 +609,8 @@ 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 getRandom(self):
return self.randoms
def setRandom(self, random): def setRandom(self, random):
self.randoms = random self.randoms = random
self.userprofile["randoms"] = random self.userprofile["randoms"] = random
@ -1800,7 +1802,8 @@ class PesterWindow(MovingWindow):
if self.config.memoSound(): if self.config.memoSound():
if self.config.nameSound(): if self.config.nameSound():
initials = self.userprofile.chat.initials() initials = self.userprofile.chat.initials()
search = r"\b[%s%s][%s%s]\b" % (initials[0].lower(), initials[0], initials[1].lower(), initials[1]) initials = (initials, "%s%s" % (initials[0].lower(), initials[1]), "%s%s" % (initials[0], initials[1].lower()))
search = r"\b%s\b" % ("|".join(initials))
m = convertTags(msg, "text") m = convertTags(msg, "text")
if m.find(":") <= 3: if m.find(":") <= 3:
m = m[m.find(":"):] m = m[m.find(":"):]
@ -2208,7 +2211,7 @@ class PesterWindow(MovingWindow):
msgbox = QtGui.QMessageBox() msgbox = QtGui.QMessageBox()
msgbox.setText("This chumhandle has been registered; you may not use it.") msgbox.setText("This chumhandle has been registered; you may not use it.")
msgbox.setInformativeText("Your handle is now being changed to %s." % (changedto)) msgbox.setInformativeText("Your handle is now being changed to %s." % (changedto))
msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
ret = msgbox.exec_() ret = msgbox.exec_()
elif h == self.randhandler.randNick: elif h == self.randhandler.randNick:
self.randhandler.incoming(msg) self.randhandler.incoming(msg)
@ -2261,7 +2264,7 @@ class PesterWindow(MovingWindow):
l = n.split(":") l = n.split(":")
oldnick = l[0] oldnick = l[0]
newnick = l[1] newnick = l[1]
if update == "quit": if update in ("quit", "netsplit"):
for c in self.namesdb.keys(): for c in self.namesdb.keys():
try: try:
i = self.namesdb[c].index(n) i = self.namesdb[c].index(n)

View file

@ -14,6 +14,7 @@ class RandomHandler(QtCore.QObject):
self.mainwindow.sendNotice.emit("?", self.randNick) self.mainwindow.sendNotice.emit("?", self.randNick)
def setRandomer(self, r): def setRandomer(self, r):
if r != self.mainwindow.userprofile.getRandom():
if r: code = "+" if r: code = "+"
else: code = "-" else: code = "-"
self.queue.append(code) self.queue.append(code)

View file

@ -3,6 +3,7 @@
import feedparser import feedparser
import pickle import pickle
import os import os
import threading
from time import mktime from time import mktime
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -12,10 +13,10 @@ class MSPAChecker(QtGui.QWidget):
self.mainwindow = parent self.mainwindow = parent
self.refreshRate = 30 # seconds self.refreshRate = 30 # seconds
self.status = None self.status = None
self.lock = False
self.timer = QtCore.QTimer(self) self.timer = QtCore.QTimer(self)
self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.connect(self.timer, QtCore.SIGNAL('timeout()'),
self, QtCore.SLOT('check_site()')) self, QtCore.SLOT('check_site_wrapper()'))
self.check_site()
self.timer.start(1000*self.refreshRate) self.timer.start(1000*self.refreshRate)
def save_state(self): def save_state(self):
@ -42,15 +43,25 @@ class MSPAChecker(QtGui.QWidget):
msg.show() msg.show()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def check_site(self): def check_site_wrapper(self):
if not self.mainwindow.config.checkMSPA(): if not self.mainwindow.config.checkMSPA():
return return
if self.lock:
return
print "Checking MSPA updates..."
s = threading.Thread(target=self.check_site)
s.start()
def check_site(self):
rss = None rss = None
must_save = False must_save = False
try: try:
self.lock = True
rss = feedparser.parse("http://www.mspaintadventures.com/rss/rss.xml") rss = feedparser.parse("http://www.mspaintadventures.com/rss/rss.xml")
except: except:
return return
finally:
self.lock = False
if len(rss.entries) == 0: if len(rss.entries) == 0:
return return
entries = sorted(rss.entries,key=(lambda x: mktime(x.updated_parsed))) entries = sorted(rss.entries,key=(lambda x: mktime(x.updated_parsed)))