This commit is contained in:
Stephen Dranger 2011-02-06 00:02:39 -06:00
parent 15b6ae5b71
commit f4d2b2f049
16 changed files with 149 additions and 31 deletions

2
TODO
View file

@ -1,6 +1,4 @@
Features: Features:
* memo change theme
* 1 MINUTES FROM NOW
* memo kicking * memo kicking
* user import * user import
* Transparent background? * Transparent background?

BIN
convo.pyc

Binary file not shown.

View file

@ -147,7 +147,11 @@ class PesterProfile(object):
initials = pcf+self.initials() initials = pcf+self.initials()
return "<c=%s><c=%s>%s</c> %s %s %s.</c>" % \ return "<c=%s><c=%s>%s</c> %s %s %s.</c>" % \
(syscolor.name(), self.colorhtml(), initials, timetext, verb, channel[1:].upper().replace("_", " ")) (syscolor.name(), self.colorhtml(), initials, timetext, verb, channel[1:].upper().replace("_", " "))
def memobanmsg(self, opchum, opgrammar, syscolor, timeGrammar):
initials = timeGrammar.pcf+self.initials()+timeGrammar.number
opinit = opgrammar.pcf+opchum.initials()+opgrammar.number
return "<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo." % \
(opchum.colorhtml(), opinit, self.colorhtml(), initials)
def memojoinmsg(self, syscolor, td, timeGrammar, verb): def memojoinmsg(self, syscolor, td, timeGrammar, verb):
(temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when) (temporal, pcf, when) = (timeGrammar.temporal, timeGrammar.pcf, timeGrammar.when)
timetext = timeDifference(td) timetext = timeDifference(td)

Binary file not shown.

16
irc.py
View file

@ -3,11 +3,12 @@ from oyoyo.client import IRCClient
from oyoyo.cmdhandler import DefaultCommandHandler from oyoyo.cmdhandler import DefaultCommandHandler
from oyoyo import helpers from oyoyo import helpers
import logging import logging
import random
from dataobjs import Mood, PesterProfile from dataobjs import Mood, PesterProfile
from generic import PesterList from generic import PesterList
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.DEBUG)
class PesterIRC(QtCore.QObject): class PesterIRC(QtCore.QObject):
def __init__(self, window): def __init__(self, window):
@ -79,6 +80,11 @@ class PesterIRC(QtCore.QObject):
def leftChannel(self, channel): def leftChannel(self, channel):
c = unicode(channel) c = unicode(channel)
helpers.part(self.cli, c) helpers.part(self.cli, c)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def kickUser(self, handle, channel):
c = unicode(channel)
h = unicode(handle)
helpers.kick(self.cli, h, c)
def updateIRC(self): def updateIRC(self):
self.conn.next() self.conn.next()
@ -155,7 +161,10 @@ class PesterHandler(DefaultCommandHandler):
def quit(self, nick, reason): def quit(self, nick, reason):
handle = nick[0:nick.find("!")] handle = nick[0:nick.find("!")]
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, op):
self.parent.userPresentUpdate.emit(handle, channel, "kick:%s" % (op))
# ok i shouldnt be overloading that but am lazy
def part(self, nick, channel, reason="nanchos"): def part(self, nick, channel, reason="nanchos"):
handle = nick[0:nick.find("!")] handle = nick[0:nick.find("!")]
self.parent.userPresentUpdate.emit(handle, channel, "left") self.parent.userPresentUpdate.emit(handle, channel, "left")
@ -170,8 +179,7 @@ class PesterHandler(DefaultCommandHandler):
oldhandle = oldnick[0:oldnick.find("!")] oldhandle = oldnick[0:oldnick.find("!")]
newchum = PesterProfile(newnick, chumdb=self.mainwindow.chumdb) newchum = PesterProfile(newnick, chumdb=self.mainwindow.chumdb)
self.parent.moodUpdated.emit(oldhandle, Mood("offline")) self.parent.moodUpdated.emit(oldhandle, Mood("offline"))
self.parent.userPresentUpdate.emit(oldhandle, "", "oldnick") self.parent.userPresentUpdate.emit("%s:%s" % (oldhandle, newnick), "", "nick")
self.parent.userPresentUpdate.emit(newnick, "", "newnick")
if newnick in self.mainwindow.chumList.chums: if newnick in self.mainwindow.chumList.chums:
self.getMood(newchum) self.getMood(newchum)
def namreply(self, server, nick, op, channel, names): def namreply(self, server, nick, op, channel, names):

BIN
irc.pyc

Binary file not shown.

103
memos.py
View file

@ -4,7 +4,7 @@ from PyQt4 import QtGui, QtCore
from datetime import time, timedelta, datetime from datetime import time, timedelta, datetime
from dataobjs import PesterProfile, Mood from dataobjs import PesterProfile, Mood
from generic import PesterIcon from generic import PesterIcon, RightClickList
from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow
from parsetools import convertTags, escapeBrackets, addTimeInitial, timeProtocol from parsetools import convertTags, escapeBrackets, addTimeInitial, timeProtocol
@ -282,8 +282,17 @@ class PesterMemo(PesterConvo):
self.textInput = MemoInput(self.mainwindow.theme, self) self.textInput = MemoInput(self.mainwindow.theme, self)
self.textInput.setFocus() self.textInput.setFocus()
self.userlist = QtGui.QListWidget(self) self.userlist = RightClickList(self)
self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)) self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding))
self.userlist.optionsMenu = QtGui.QMenu(self)
self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.connect(self.addchumAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('addChumSlot()'))
self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
self.connect(self.banuserAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('banSelectedUser()'))
self.userlist.optionsMenu.addAction(self.addchumAction)
# ban list added if we are op
self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self) self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self)
self.timeinput = TimeInput(self.timeslider, self) self.timeinput = TimeInput(self.timeslider, self)
@ -396,6 +405,8 @@ class PesterMemo(PesterConvo):
self.userlist.setStyleSheet(theme["memos/userlist/style"]) self.userlist.setStyleSheet(theme["memos/userlist/style"])
self.userlist.setFixedWidth(theme["memos/userlist/width"]) self.userlist.setFixedWidth(theme["memos/userlist/width"])
self.addchumAction.setText(theme["main/menus/rclickchumlist/addchum"])
self.banuserAction.setText(theme["main/menus/rclickchumlist/banuser"])
self.timeinput.setFixedWidth(theme["memos/time/text/width"]) self.timeinput.setFixedWidth(theme["memos/time/text/width"])
self.timeinput.setStyleSheet(theme["memos/time/text/style"]) self.timeinput.setStyleSheet(theme["memos/time/text/style"])
@ -431,6 +442,7 @@ class PesterMemo(PesterConvo):
op = True op = True
handle = handle[1:] handle = handle[1:]
if handle == self.mainwindow.profile().handle: if handle == self.mainwindow.profile().handle:
self.userlist.optionsMenu.addAction(self.banuserAction)
self.op = True self.op = True
item = QtGui.QListWidgetItem(handle) item = QtGui.QListWidgetItem(handle)
if handle == self.mainwindow.profile().handle: if handle == self.mainwindow.profile().handle:
@ -439,6 +451,8 @@ class PesterMemo(PesterConvo):
color = chumdb.getColor(handle, defaultcolor) color = chumdb.getColor(handle, defaultcolor)
item.setTextColor(color) item.setTextColor(color)
self.userlist.addItem(item) self.userlist.addItem(item)
self.userlist
def timeUpdate(self, handle, cmd): def timeUpdate(self, handle, cmd):
window = self.mainwindow window = self.mainwindow
@ -516,32 +530,103 @@ class PesterMemo(PesterConvo):
@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):
if (update in ["join","left"]) and channel != self.channel:
return
chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0))
h = unicode(handle) h = unicode(handle)
c = unicode(channel) c = unicode(channel)
update = unicode(update)
if update[0:4] == "kick": # yeah, i'm lazy.
l = update.split(":")
update = l[0]
op = l[1]
if update == "nick":
l = h.split(":")
oldnick = l[0]
newnick = l[1]
h = oldnick
if (update in ["join","left", "kick"]) and channel != self.channel:
return
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 == "oldnick": if update == "quit" or update == "left" or update == "nick":
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))
if not self.times.has_key(h): if not self.times.has_key(h):
return self.times[h] = TimeTracker(timedelta(0))
while self.times[h].getTime() is not None: while self.times[h].getTime() is not None:
t = self.times[h] t = self.times[h]
grammar = t.getGrammar() grammar = t.getGrammar()
self.textArea.append(convertTags(chum.memoclosemsg(systemColor, grammar, self.mainwindow.theme["convo/text/closememo"]))) self.textArea.append(convertTags(chum.memoclosemsg(systemColor, grammar, self.mainwindow.theme["convo/text/closememo"])))
self.times[h].removeTime(t.getTime()) self.times[h].removeTime(t.getTime())
if update == "nick":
self.addUser(newnick)
elif update == "kick":
print "KICKING"
if len(chums) == 0:
return
c = chums[0]
chum = PesterProfile(h)
if h == self.mainwindow.profile().handle:
chum = self.mainwindow.profile()
ttracker = self.time
curtime = self.time.getTime()
elif self.times.has_key(h):
ttracker = self.times[h]
else:
ttracker = TimeTracker(timedelta(0))
while ttracker.getTime() is not None:
grammar = ttracker.getGrammar()
opchum = PesterProfile(op)
if self.times.has_key(op):
opgrammar = self.times[op].getGrammar()
elif op == self.mainwindow.profile().handle:
opgrammar = self.time.getGrammar()
else:
opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW")
self.textArea.append(convertTags(chum.memobanmsg(opchum, opgrammar, systemColor, grammar)))
ttracker.removeTime(ttracker.getTime())
if chum is self.mainwindow.profile():
# are you next?
msgbox = QtGui.QMessageBox()
msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"])
msgbox.setInformativeText("press 0k to rec0nnect or cancel to absc0nd")
msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
ret = msgbox.exec_()
if ret == QtGui.QMessageBox.Ok:
self.userlist.clear()
self.time = TimeTracker(curtime)
self.resetSlider(curtime)
self.mainwindow.joinChannel.emit(self.channel)
me = self.mainwindow.profile()
self.textArea.append(convertTags(me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel)))
elif ret == QtGui.QMessageBox.Cancel:
if self.parent():
i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i)
else:
self.close()
else:
# i warned you about those stairs bro
self.userlist.takeItem(self.userlist.row(c))
elif update == "join": elif update == "join":
self.addUser(h) self.addUser(h)
time = self.time.getTime() time = self.time.getTime()
serverText = "PESTERCHUM:TIME>"+delta2txt(time, "server") serverText = "PESTERCHUM:TIME>"+delta2txt(time, "server")
self.messageSent.emit(serverText, self.title()) self.messageSent.emit(serverText, self.title())
elif update == "newnick":
self.addUser(h)
@QtCore.pyqtSlot()
def addChumSlot(self):
if not self.userlist.currentItem():
return
currentChum = PesterProfile(unicode(self.userlist.currentItem().text()))
self.mainwindow.addChum(currentChum)
@QtCore.pyqtSlot()
def banSelectedUser(self):
if not self.userlist.currentItem():
return
currentHandle = unicode(self.userlist.currentItem().text())
self.mainwindow.kickUser.emit(currentHandle, self.channel)
def resetSlider(self, time): def resetSlider(self, time):
self.timeinput.setText(delta2txt(time)) self.timeinput.setText(delta2txt(time))
self.timeinput.setSlider() self.timeinput.setSlider()

BIN
memos.pyc

Binary file not shown.

View file

@ -38,6 +38,9 @@ def names(cli, *channels):
def channel_list(cli): def channel_list(cli):
cli.send("LIST") cli.send("LIST")
def kick(cli, handle, channel):
cli.send("KICK %s %s" % (channel, handle))
def msgrandom(cli, choices, dest, user=None): def msgrandom(cli, choices, dest, user=None):
o = "%s: " % user if user else "" o = "%s: " % user if user else ""
o += random.choice(choices) o += random.choice(choices)

Binary file not shown.

View file

@ -121,9 +121,15 @@ def timeDifference(td):
if atd == timedelta(0): if atd == timedelta(0):
timetext = "RIGHT NOW" timetext = "RIGHT NOW"
elif atd < timedelta(0,3600): elif atd < timedelta(0,3600):
timetext = "%d MINUTES %s" % (minutes, when) if minutes == 1:
timetext = "%d MINUTE %s" % (minutes, when)
else:
timetext = "%d MINUTES %s" % (minutes, when)
elif atd < timedelta(0,3600*100): elif atd < timedelta(0,3600*100):
timetext = "%d:%02d HOURS %s" % (hours, leftoverminutes, when) if hours == 1 and leftoverminutes == 0:
timetext = "%d:%02d HOUR %s" % (hours, leftoverminutes, when)
else:
timetext = "%d:%02d HOURS %s" % (hours, leftoverminutes, when)
else: else:
timetext = "%d HOURS %s" % (hours, when) timetext = "%d HOURS %s" % (hours, when)
return timetext return timetext

Binary file not shown.

View file

@ -1 +1 @@
{"tabs": true, "chums": ["aquaMarinist", "marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "fireSwallow", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium"], "defaultprofile": "testProfile", "block": []} {"tabs": false, "chums": ["aquaMarinist", "marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "illuminatedWax"], "defaultprofile": "testProfile", "block": []}

View file

@ -1037,7 +1037,11 @@ class PesterWindow(MovingWindow):
def userPresentUpdate(self, handle, channel, update): def userPresentUpdate(self, handle, channel, update):
c = unicode(channel) c = unicode(channel)
n = unicode(handle) n = unicode(handle)
if update == "quit" or update == "oldnick": if update == "nick":
l = n.split(":")
oldnick = l[0]
newnick = l[1]
if update == "quit":
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)
@ -1054,14 +1058,16 @@ class PesterWindow(MovingWindow):
pass pass
except KeyError: except KeyError:
self.namesdb[c] = [] self.namesdb[c] = []
elif update == "newnick": elif update == "nick":
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(oldnick)
self.namesdb[c].pop(i)
self.namesdb[c].append(newnick)
except ValueError: except ValueError:
self.namesdb[c].append(n) pass
except KeyError: except KeyError:
self.namesdb[c] = [n] pass
elif update == "join": elif update == "join":
try: try:
i = self.namesdb[c].index(n) i = self.namesdb[c].index(n)
@ -1406,6 +1412,7 @@ class PesterWindow(MovingWindow):
trayIconSignal = QtCore.pyqtSignal(int) trayIconSignal = QtCore.pyqtSignal(int)
blockedChum = QtCore.pyqtSignal(QtCore.QString) blockedChum = QtCore.pyqtSignal(QtCore.QString)
unblockedChum = QtCore.pyqtSignal(QtCore.QString) unblockedChum = QtCore.pyqtSignal(QtCore.QString)
kickUser = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
joinChannel = QtCore.pyqtSignal(QtCore.QString) joinChannel = QtCore.pyqtSignal(QtCore.QString)
leftChannel = QtCore.pyqtSignal(QtCore.QString) leftChannel = QtCore.pyqtSignal(QtCore.QString)
@ -1511,7 +1518,10 @@ def main():
QtCore.SIGNAL('leftChannel(QString)'), QtCore.SIGNAL('leftChannel(QString)'),
irc, irc,
QtCore.SLOT('leftChannel(QString)')) QtCore.SLOT('leftChannel(QString)'))
irc.connect(widget,
QtCore.SIGNAL('kickUser(QString, QString)'),
irc,
QtCore.SLOT('kickUser(QString, QString)'))
# IRC --> Main window # IRC --> Main window
irc.connect(irc, QtCore.SIGNAL('connected()'), irc.connect(irc, QtCore.SIGNAL('connected()'),

View file

@ -30,7 +30,8 @@
"removechum": "REMOVE CHUM", "removechum": "REMOVE CHUM",
"blockchum": "BLOCK", "blockchum": "BLOCK",
"addchum": "ADD CHUM", "addchum": "ADD CHUM",
"unblockchum": "UNBLOCK" "unblockchum": "UNBLOCK",
"banuser": "BAN USER"
} }
}, },
"chums": { "style": "border:2px solid yellow; background-color: black;color: white;font: bold;font-family: 'Courier';selection-background-color:#646464; ", "chums": { "style": "border:2px solid yellow; background-color: black;color: white;font: bold;font-family: 'Courier';selection-background-color:#646464; ",
@ -211,7 +212,8 @@
"unblocked": "unblocked", "unblocked": "unblocked",
"openmemo": "opened memo on board", "openmemo": "opened memo on board",
"joinmemo": "responded to memo", "joinmemo": "responded to memo",
"closememo": "ceased responding to memo" "closememo": "ceased responding to memo",
"kickedmemo": "You have been banned from this memo!"
}, },
"systemMsgColor": "#646464" "systemMsgColor": "#646464"
}, },

View file

@ -30,7 +30,8 @@
"removechum": "Trash", "removechum": "Trash",
"blockchum": "Block", "blockchum": "Block",
"addchum": "Add Chump", "addchum": "Add Chump",
"unblockchum": "Mercy"} "unblockchum": "Mercy",
"banuser": "BAN USER" }
}, },
"chums": { "style": "font-size: 12px; background: white; border:2px solid #c2c2c2; padding: 5px; font-family: 'Arial';selection-background-color:rgb(200,200,200); ", "chums": { "style": "font-size: 12px; background: white; border:2px solid #c2c2c2; padding: 5px; font-family: 'Arial';selection-background-color:rgb(200,200,200); ",
"loc": [475, 89], "loc": [475, 89],
@ -259,7 +260,8 @@
"unblocked": "mercifully forgave", "unblocked": "mercifully forgave",
"openmemo": "opened memo on board", "openmemo": "opened memo on board",
"joinmemo": "responded to memo", "joinmemo": "responded to memo",
"closememo": "ceased responding to memo" "closememo": "ceased responding to memo",
"kickedmemo": "You have been banned from this memo!"
}, },
"systemMsgColor": "#646464" "systemMsgColor": "#646464"
}, },
@ -293,8 +295,8 @@
"style": "color: black; font:bold; border:1px solid #c2c2c2; background: white; height: 19px;" "style": "color: black; font:bold; border:1px solid #c2c2c2; background: white; height: 19px;"
}, },
"slider": { "style": " border:1px solid #c2c2c2;", "slider": { "style": " border:1px solid #c2c2c2;",
"groove": "border-image:url($path/timeslideraqua.png);", "groove": "border-image:url($path/timeslider.png);",
"handle": "image:url($path/aquaicon.png);" "handle": "image:url($path/acceptant.png);"
}, },
"buttons": { "style": "border:1px solid #a68168; height: 17px; width: 50px; color: #cd8f9d; font-family: 'Arial'; background: rgb(190, 19, 4); margin-left: 2px;" }, "buttons": { "style": "border:1px solid #a68168; height: 17px; width: 50px; color: #cd8f9d; font-family: 'Arial'; background: rgb(190, 19, 4); margin-left: 2px;" },
"arrows": { "left": "$path/leftarrow.png", "arrows": { "left": "$path/leftarrow.png",