pesterchum:begin

This commit is contained in:
Stephen Dranger 2011-01-28 02:10:00 -06:00
parent 9bb57931a2
commit 3c1f40e0f2
3 changed files with 37 additions and 28 deletions

3
TODO
View file

@ -1,6 +1,4 @@
Features: Features:
* Profile management
* pesterchum:begin
* pesterchum:cease * pesterchum:cease
* changeColor * changeColor
* protect against messages from yourself :P * protect against messages from yourself :P
@ -16,6 +14,7 @@ Features:
* Quirks * Quirks
* Block list * Block list
* User list/add from list * User list/add from list
* User commands/stop user from sending commands accidentally
* System tray stuff * System tray stuff
* Chat rooms * Chat rooms

View file

@ -5,6 +5,7 @@ from oyoyo import helpers
import logging import logging
import os, sys import os, sys
import os.path import os.path
from datetime import *
import random import random
import json import json
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
@ -47,10 +48,10 @@ class PesterProfile(object):
def colorcmd(self): def colorcmd(self):
(r, g, b, a) = self.color.getRgb() (r, g, b, a) = self.color.getRgb()
return "%d,%d,%d" % (r,g,b) return "%d,%d,%d" % (r,g,b)
def update(self, newprofile): def beganpestermsg(self, otherchum):
self.handle = newprofile.handle return "<span style='color:black;'>-- %s <span style='color:%s'>[%s]</span> began pestering %s <span style='color:%s'>[%s]</span> at %s --</span>" % (self.handle, self.colorhtml(), self.initials(), otherchum.handle, otherchum.colorhtml(), otherchum.initials(), datetime.now().strftime("%H:%M"))
self.color = newprofile.color
self.mood = newprofile.mood
class pesterTheme(dict): class pesterTheme(dict):
def __init__(self, name): def __init__(self, name):
@ -434,7 +435,15 @@ class PesterText(QtGui.QTextEdit):
def addMessage(self, text, chum): def addMessage(self, text, chum):
color = chum.colorhtml() color = chum.colorhtml()
initials = chum.initials() initials = chum.initials()
msg = str(text) msg = unicode(text)
if msg == "PESTERCHUM:BEGIN":
parent = self.parent()
parent.ceased = False
window = parent.mainwindow
me = window.profile
msg = chum.beganpestermsg(me)
self.append(msg)
else:
msg = msg.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;") msg = msg.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
self.append("<span style='color:%s'>%s: %s</span>" % \ self.append("<span style='color:%s'>%s: %s</span>" % \
(color, initials, msg)) (color, initials, msg))
@ -471,9 +480,13 @@ class PesterConvo(QtGui.QFrame):
self.layout.addWidget(self.textInput) self.layout.addWidget(self.textInput)
self.setLayout(self.layout) self.setLayout(self.layout)
self.ceased = False
if parent: if parent:
parent.addChat(self) parent.addChat(self)
if initiated:
msg = self.mainwindow.profile.beganpestermsg(self.chum)
self.textArea.append(msg)
def updateMood(self, mood): def updateMood(self, mood):
if self.parent(): if self.parent():
@ -585,8 +598,15 @@ class PesterWindow(MovingWindow):
event.accept() event.accept()
def newMessage(self, handle, msg): def newMessage(self, handle, msg):
if not self.convos.has_key(handle): if not self.convos.has_key(handle):
chum = PesterProfile(handle) matchingChums = [c for c in self.chumList.chums if c.handle == handle]
if len(matchingChums) > 0:
mood = matchingChums[0].mood
else:
mood = Mood(0)
chum = PesterProfile(handle, mood=mood)
self.newConversation(chum, False) self.newConversation(chum, False)
if len(matchingChums) == 0:
self.moodRequest.emit(chum)
convo = self.convos[handle] convo = self.convos[handle]
convo.addMessage(msg, False) convo.addMessage(msg, False)
# play sound here # play sound here
@ -601,10 +621,6 @@ class PesterWindow(MovingWindow):
def newConversation(self, chum, initiated=True): def newConversation(self, chum, initiated=True):
if self.convos.has_key(chum.handle): if self.convos.has_key(chum.handle):
self.convos[chum.handle].showChat() self.convos[chum.handle].showChat()
if not initiated:
# self.convos[chum.handle]
# add pesterchum:begin
pass
return return
if self.config.tabs(): if self.config.tabs():
if not self.tabconvo: if not self.tabconvo:
@ -653,10 +669,6 @@ class PesterWindow(MovingWindow):
h = str(handle) h = str(handle)
self.changeColor(h, color) self.changeColor(h, color)
@QtCore.pyqtSlot(PesterProfile)
def pesterchumBeginSlot(self, chum):
self.newConversation(chum, False)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def deliverMessage(self, handle, msg): def deliverMessage(self, handle, msg):
h = str(handle) h = str(handle)
@ -754,6 +766,7 @@ class PesterWindow(MovingWindow):
sendMessage = QtCore.pyqtSignal(QtCore.QString, PesterProfile) sendMessage = QtCore.pyqtSignal(QtCore.QString, PesterProfile)
convoClosed = QtCore.pyqtSignal(QtCore.QString) convoClosed = QtCore.pyqtSignal(QtCore.QString)
profileChanged = QtCore.pyqtSignal() profileChanged = QtCore.pyqtSignal()
moodRequest = QtCore.pyqtSignal(PesterProfile)
class PesterIRC(QtCore.QObject): class PesterIRC(QtCore.QObject):
def __init__(self, window): def __init__(self, window):
@ -765,6 +778,7 @@ class PesterIRC(QtCore.QObject):
self.cli.command_handler.window = self.window self.cli.command_handler.window = self.window
self.conn = self.cli.connect() self.conn = self.cli.connect()
@QtCore.pyqtSlot(PesterProfile)
def getMood(self, *chums): def getMood(self, *chums):
self.cli.command_handler.getMood(*chums) self.cli.command_handler.getMood(*chums)
@ -793,7 +807,6 @@ class PesterIRC(QtCore.QObject):
moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood) moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood)
colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor) colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor)
pesterchumBegin = QtCore.pyqtSignal(PesterProfile)
messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
nickCollision = QtCore.pyqtSignal(QtCore.QString) nickCollision = QtCore.pyqtSignal(QtCore.QString)
@ -829,9 +842,6 @@ class PesterHandler(DefaultCommandHandler):
colors = [0,0,0] colors = [0,0,0]
color = QtGui.QColor(*colors) color = QtGui.QColor(*colors)
self.parent.colorUpdated.emit(handle, color) self.parent.colorUpdated.emit(handle, color)
elif msg == "PESTERCHUM:BEGIN":
chum = PesterProfile(handle)
self.parent.pesterchumBegin.emit(chum)
else: else:
self.parent.messageReceived.emit(handle, msg) self.parent.messageReceived.emit(handle, msg)
@ -893,6 +903,10 @@ def main():
QtCore.SIGNAL('profileChanged()'), QtCore.SIGNAL('profileChanged()'),
irc, irc,
QtCore.SLOT('updateProfile()')) QtCore.SLOT('updateProfile()'))
irc.connect(widget,
QtCore.SIGNAL('moodRequest(PyQt_PyObject)'),
irc,
QtCore.SLOT('getMood(PyQt_PyObject)'))
irc.connect(irc, irc.connect(irc,
QtCore.SIGNAL('moodUpdated(QString, PyQt_PyObject)'), QtCore.SIGNAL('moodUpdated(QString, PyQt_PyObject)'),
widget, widget,
@ -901,10 +915,6 @@ def main():
QtCore.SIGNAL('colorUpdated(QString, QColor)'), QtCore.SIGNAL('colorUpdated(QString, QColor)'),
widget, widget,
QtCore.SLOT('updateColorSlot(QString, QColor)')) QtCore.SLOT('updateColorSlot(QString, QColor)'))
irc.connect(irc,
QtCore.SIGNAL('pesterchumBegin(PyQt_PyObject)'),
widget,
QtCore.SLOT('pesterchumBeginSlot(PyQt_PyObject)'))
irc.connect(irc, irc.connect(irc,
QtCore.SIGNAL('messageReceived(QString, QString)'), QtCore.SIGNAL('messageReceived(QString, QString)'),
widget, widget,

View file

@ -30,7 +30,7 @@
}, },
"convo": "convo":
{"style": "background: #fdb302; font-family: 'Courier New'", {"style": "background: #fdb302; font-family: 'Courier New'",
"size": [500, 500], "size": [600, 500],
"chumlabel": { "style": "background: rgba(255, 255, 255, 25%);" }, "chumlabel": { "style": "background: rgba(255, 255, 255, 25%);" },
"textarea": { "textarea": {
"style": "background: white;" "style": "background: white;"