diff --git a/convo.py b/convo.py
index 84f797f..7a8364c 100644
--- a/convo.py
+++ b/convo.py
@@ -5,7 +5,7 @@ from PyQt4 import QtGui, QtCore
from dataobjs import PesterProfile, Mood, PesterHistory
from generic import PesterIcon, RightClickList
-from parsetools import escapeBrackets, convertTags
+from parsetools import convertTags
class PesterTabWindow(QtGui.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"):
@@ -211,6 +211,7 @@ class PesterText(QtGui.QTextEdit):
parent = self.parent()
window = parent.mainwindow
me = window.profile()
+ quirks = window.userprofile.quirks if parent.applyquirks else None
if msg == "PESTERCHUM:BEGIN":
parent.setChumOpen(True)
msg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"])
@@ -238,6 +239,8 @@ class PesterText(QtGui.QTextEdit):
window.chatlog.log(chum.handle, convertTags(msg, "bbcode"))
self.append(convertTags(msg))
elif msg[0:3] == "/me" or msg[0:13] == "PESTERCHUM:ME":
+ if quirks:
+ msg = quirks.apply(msg)
if msg[0:3] == "/me":
start = 3
else:
@@ -256,11 +259,10 @@ class PesterText(QtGui.QTextEdit):
window.chatlog.log(chum.handle, convertTags(beginmsg, "bbcode"))
self.append(convertTags(beginmsg))
- msg = escapeBrackets(msg)
msg = "%s: %s" % (color, initials, msg)
- self.append(convertTags(msg))
+ self.append(convertTags(msg, quirkobj=quirks))
if chum is me:
- window.chatlog.log(parent.chum.handle, convertTags(msg, "bbcode"))
+ window.chatlog.log(parent.chum.handle, convertTags(msg, "bbcode", quirkobj=quirks))
else:
if window.idle:
idlethreshhold = 60
@@ -514,16 +516,13 @@ class PesterConvo(QtGui.QFrame):
if text == "" or text[0:11] == "PESTERCHUM:":
return
self.history.add(text)
- # deal with quirks here
- if self.applyquirks:
- qtext = self.mainwindow.userprofile.quirks.apply(text)
- text = qtext
self.addMessage(text, True)
# if ceased, rebegin
if hasattr(self, 'chumopen') and not self.chumopen:
self.mainwindow.newConvoStarted.emit(QtCore.QString(self.title()), True)
# convert color tags
- text = convertTags(text, "ctag")
+ quirkobj = self.mainwindow.userprofile.quirks if self.applyquirks else None
+ text = convertTags(text, "ctag", quirkobj)
self.messageSent.emit(text, self.title())
self.textInput.setText("")
diff --git a/convo.pyc b/convo.pyc
index 636409a..07ab907 100644
Binary files a/convo.pyc and b/convo.pyc differ
diff --git a/dataobjs.pyc b/dataobjs.pyc
index 22eeb00..f807641 100644
Binary files a/dataobjs.pyc and b/dataobjs.pyc differ
diff --git a/generic.pyc b/generic.pyc
index cc9b4e2..033bd9a 100644
Binary files a/generic.pyc and b/generic.pyc differ
diff --git a/irc.pyc b/irc.pyc
index e4a65a5..62a8eb1 100644
Binary files a/irc.pyc and b/irc.pyc differ
diff --git a/logs/chums.js b/logs/chums.js
index 9e77160..ee55015 100644
--- a/logs/chums.js
+++ b/logs/chums.js
@@ -1 +1 @@
-{"macruralAlchemist": {"color": "#700000", "handle": "macruralAlchemist", "mood": "offline"}, "lyricalKeraunoscopic": {"color": "#00c000", "handle": "lyricalKeraunoscopic", "mood": "offline"}, "fireSwallow": {"color": "#80bb9a", "handle": "fireSwallow", "mood": "offline"}, "aquaMarinist": {"color": "#00caca", "handle": "aquaMarinist", "mood": "offline"}, "centaursTesticle": {"color": "#000056", "handle": "centaursTesticle", "mood": "offline"}, "mechanicalSpectacle": {"color": "#0000ff", "handle": "mechanicalSpectacle", "mood": "offline"}, "carcinoGeneticist": {"color": "#999999", "handle": "carcinoGeneticist", "mood": "offline"}, "greyscalePacifist": {"color": "#7f7f7f", "handle": "greyscalePacifist", "mood": "offline"}, "aquaticMarinist": {"color": "#00caca", "handle": "aquaticMarinist", "mood": "offline"}, "wovenWay": {"color": "#000000", "handle": "wovenWay", "mood": "offline"}, "insipidTranscient": {"color": "#145064", "handle": "insipidTranscient", "mood": "offline"}, "caffeinatedAnalyst": {"color": "#aa0000", "handle": "caffeinatedAnalyst", "mood": "offline"}, "pesterClient394": {"color": "#ff3737", "handle": "pesterClient394", "mood": "offline"}, "absoluteTranquility": {"color": "#000033", "handle": "absoluteTranquility", "mood": "offline"}, "nitroZealist": {"color": "#ff3737", "handle": "nitroZealist", "mood": "offline"}, "quintessentialArbalest": {"color": "#999999", "handle": "quintessentialArbalest", "mood": "offline"}, "agogPorphyry": {"color": "#522d80", "handle": "agogPorphyry", "mood": "offline"}, "grimAuxiliatrix": {"color": "#008141", "handle": "grimAuxiliatrix", "mood": "offline"}, "androidTechnician": {"color": "#0000ff", "handle": "androidTechnician", "mood": "offline"}, "ardentAbettor": {"color": "#c8b670", "handle": "ardentAbettor", "mood": "offline"}, "aceIsm": {"color": "#ffcc66", "handle": "aceIsm", "mood": "offline"}, "apocalypseArisen": {"color": "#a10000", "handle": "apocalypseArisen", "mood": "offline"}, "radicalApologist": {"color": "#ffaa00", "handle": "radicalApologist", "mood": "offline"}, "microMachines": {"color": "#aa00ff", "handle": "microMachines", "mood": "offline"}, "uroborosUnbound": {"color": "#00416a", "handle": "uroborosUnbound", "mood": "offline"}, "arachnidsGrip": {"color": "#005682", "handle": "arachnidsGrip", "mood": "offline"}, "percipientPedestrian": {"color": "#00ffff", "handle": "percipientPedestrian", "mood": "offline"}, "tentacleTherapist": {"color": "#cc66ff", "handle": "tentacleTherapist", "mood": "offline"}, "sucroseSaboteur": {"color": "#00e700", "handle": "sucroseSaboteur", "mood": "offline"}, "illuminatedWax": {"color": "#000000", "handle": "illuminatedWax", "mood": "offline"}, "moirailBunp": {"color": "#6a3d0f", "handle": "moirailBunp", "mood": "offline"}, "madLurker": {"color": "#000000", "handle": "madLurker", "mood": "offline"}, "testOut": {"color": "#c760cc", "handle": "testOut", "mood": "offline"}, "pesterClient3022": {"color": "#336600", "handle": "pesterClient3022", "mood": "offline"}, "hellerificJefferson": {"color": "#3300ff", "handle": "hellerificJefferson", "mood": "offline"}, "DocScratch": {"color": "#ffffff", "handle": "DocScratch", "mood": "offline"}, "recalcitrantDisaster": {"color": "#8b0068", "handle": "recalcitrantDisaster", "mood": "offline"}, "superGhost": {"color": "#800564", "handle": "superGhost", "mood": "offline"}, "arsenicCatnip": {"color": "#006400", "handle": "arsenicCatnip", "mood": "offline"}, "kaleidoscopicMind": {"color": "#ff6666", "handle": "kaleidoscopicMind", "mood": "offline"}, "noSense": {"color": "#1d0059", "handle": "noSense", "mood": "offline"}, "captainCaveman": {"color": "#7c414e", "handle": "captainCaveman", "mood": "offline"}, "gamblingGenocider": {"color": "#00ff00", "handle": "gamblingGenocider", "mood": "offline"}, "cuttlefishCuller": {"color": "#77003c", "handle": "cuttlefishCuller", "mood": "offline"}, "iw": {"color": "#ff0000", "handle": "iw", "mood": "offline"}, "masterG": {"color": "#77003c", "handle": "masterG", "mood": "offline"}, "elegantDiversion": {"color": "#14b40a", "handle": "elegantDiversion", "mood": "offline"}, "plasmaModerator": {"color": "#5685cc", "handle": "plasmaModerator", "mood": "offline"}, "carcinoGenetecist": {"color": "#7f7f7f", "handle": "carcinoGenetecist", "mood": "offline"}, "marineAquist": {"color": "#00caca", "handle": "marineAquist", "mood": "offline"}, "remoteBloodbath": {"color": "#c70000", "handle": "remoteBloodbath", "mood": "offline"}, "oilslickOrchid": {"color": "#743f7e", "handle": "oilslickOrchid", "mood": "offline"}, "acapellaWaterfall": {"color": "#000099", "handle": "acapellaWaterfall", "mood": "offline"}, "gallowsCalibrator": {"color": "#008282", "handle": "gallowsCalibrator", "mood": "offline"}, "rageInducer": {"color": "#00ffff", "handle": "rageInducer", "mood": "offline"}, "anguillaNuntia": {"color": "#ff007f", "handle": "anguillaNuntia", "mood": "offline"}, "greenZephyr": {"color": "#00ca40", "handle": "greenZephyr", "mood": "offline"}, "lawdEngrish": {"color": "#00ff00", "handle": "lawdEngrish", "mood": "offline"}, "pretentiousFantasia": {"color": "#ff66cf", "handle": "pretentiousFantasia", "mood": "offline"}, "counterRealist": {"color": "#10d985", "handle": "counterRealist", "mood": "offline"}, "maxiumumFatness": {"color": "#3366ff", "handle": "maxiumumFatness", "mood": "offline"}, "schlagzeugGator": {"color": "#61821f", "handle": "schlagzeugGator", "mood": "offline"}, "metaliAggressive": {"color": "#9289d5", "handle": "metaliAggressive", "mood": "offline"}, "midnightSparrow": {"color": "#ff55ff", "handle": "midnightSparrow", "mood": "offline"}, "magmaExploiter": {"color": "#d90000", "handle": "magmaExploiter", "mood": "offline"}, "zealousScarecrow": {"color": "#00c882", "handle": "zealousScarecrow", "mood": "offline"}, "gardenGnostic": {"color": "#00ff00", "handle": "gardenGnostic", "mood": "offline"}, "unknownTraveler": {"color": "#006666", "handle": "unknownTraveler", "mood": "offline"}, "utilitarianTurnabout": {"color": "#dd0000", "handle": "utilitarianTurnabout", "mood": "offline"}, "adiosToreador": {"color": "#aa5500", "handle": "adiosToreador", "mood": "offline"}}
\ No newline at end of file
+{"macruralAlchemist": {"color": "#700000", "handle": "macruralAlchemist", "mood": "offline"}, "lyricalKeraunoscopic": {"color": "#00c000", "handle": "lyricalKeraunoscopic", "mood": "offline"}, "fireSwallow": {"color": "#80bb9a", "handle": "fireSwallow", "mood": "offline"}, "aquaMarinist": {"color": "#00caca", "handle": "aquaMarinist", "mood": "offline"}, "centaursTesticle": {"color": "#000056", "handle": "centaursTesticle", "mood": "offline"}, "mechanicalSpectacle": {"color": "#0000ff", "handle": "mechanicalSpectacle", "mood": "offline"}, "carcinoGeneticist": {"color": "#999999", "handle": "carcinoGeneticist", "mood": "offline"}, "greyscalePacifist": {"color": "#7f7f7f", "handle": "greyscalePacifist", "mood": "offline"}, "aquaticMarinist": {"color": "#00caca", "handle": "aquaticMarinist", "mood": "offline"}, "iw": {"color": "#ff0000", "handle": "iw", "mood": "offline"}, "insipidTranscient": {"color": "#145064", "handle": "insipidTranscient", "mood": "offline"}, "caffeinatedAnalyst": {"color": "#aa0000", "handle": "caffeinatedAnalyst", "mood": "offline"}, "midnightSparrow": {"color": "#ff55ff", "handle": "midnightSparrow", "mood": "offline"}, "absoluteTranquility": {"color": "#000033", "handle": "absoluteTranquility", "mood": "offline"}, "nitroZealist": {"color": "#ff3737", "handle": "nitroZealist", "mood": "offline"}, "quintessentialArbalest": {"color": "#999999", "handle": "quintessentialArbalest", "mood": "offline"}, "noSense": {"color": "#1d0059", "handle": "noSense", "mood": "offline"}, "agogPorphyry": {"color": "#522d80", "handle": "agogPorphyry", "mood": "offline"}, "grimAuxiliatrix": {"color": "#008141", "handle": "grimAuxiliatrix", "mood": "offline"}, "androidTechnician": {"color": "#0000ff", "handle": "androidTechnician", "mood": "offline"}, "ardentAbettor": {"color": "#c8b670", "handle": "ardentAbettor", "mood": "offline"}, "aceIsm": {"color": "#ffcc66", "handle": "aceIsm", "mood": "offline"}, "apocalypseArisen": {"color": "#a10000", "handle": "apocalypseArisen", "mood": "offline"}, "radicalApologist": {"color": "#ffaa00", "handle": "radicalApologist", "mood": "offline"}, "microMachines": {"color": "#aa00ff", "handle": "microMachines", "mood": "offline"}, "uroborosUnbound": {"color": "#00416a", "handle": "uroborosUnbound", "mood": "offline"}, "arachnidsGrip": {"color": "#005682", "handle": "arachnidsGrip", "mood": "offline"}, "caligulasAquarium": {"color": "#6a006a", "handle": "caligulasAquarium", "mood": "offline"}, "percipientPedestrian": {"color": "#00ffff", "handle": "percipientPedestrian", "mood": "offline"}, "tentacleTherapist": {"color": "#cc66ff", "handle": "tentacleTherapist", "mood": "offline"}, "sucroseSaboteur": {"color": "#00e700", "handle": "sucroseSaboteur", "mood": "offline"}, "illuminatedWax": {"color": "#000000", "handle": "illuminatedWax", "mood": "offline"}, "moirailBunp": {"color": "#6a3d0f", "handle": "moirailBunp", "mood": "offline"}, "madLurker": {"color": "#000000", "handle": "madLurker", "mood": "offline"}, "testOut": {"color": "#c760cc", "handle": "testOut", "mood": "offline"}, "pesterClient3022": {"color": "#336600", "handle": "pesterClient3022", "mood": "offline"}, "hellerificJefferson": {"color": "#3300ff", "handle": "hellerificJefferson", "mood": "offline"}, "DocScratch": {"color": "#ffffff", "handle": "DocScratch", "mood": "offline"}, "recalcitrantDisaster": {"color": "#8b0068", "handle": "recalcitrantDisaster", "mood": "offline"}, "superGhost": {"color": "#800564", "handle": "superGhost", "mood": "offline"}, "arsenicCatnip": {"color": "#006400", "handle": "arsenicCatnip", "mood": "offline"}, "kaleidoscopicMind": {"color": "#ff6666", "handle": "kaleidoscopicMind", "mood": "offline"}, "zealousScarecrow": {"color": "#00c882", "handle": "zealousScarecrow", "mood": "offline"}, "captainCaveman": {"color": "#7c414e", "handle": "captainCaveman", "mood": "offline"}, "gamblingGenocider": {"color": "#00ff00", "handle": "gamblingGenocider", "mood": "offline"}, "cuttlefishCuller": {"color": "#77003c", "handle": "cuttlefishCuller", "mood": "offline"}, "wovenWay": {"color": "#000000", "handle": "wovenWay", "mood": "offline"}, "masterG": {"color": "#77003c", "handle": "masterG", "mood": "offline"}, "elegantDiversion": {"color": "#14b40a", "handle": "elegantDiversion", "mood": "offline"}, "plasmaModerator": {"color": "#5685cc", "handle": "plasmaModerator", "mood": "offline"}, "carcinoGenetecist": {"color": "#7f7f7f", "handle": "carcinoGenetecist", "mood": "offline"}, "marineAquist": {"color": "#00caca", "handle": "marineAquist", "mood": "offline"}, "remoteBloodbath": {"color": "#c70000", "handle": "remoteBloodbath", "mood": "offline"}, "oilslickOrchid": {"color": "#743f7e", "handle": "oilslickOrchid", "mood": "offline"}, "acapellaWaterfall": {"color": "#000099", "handle": "acapellaWaterfall", "mood": "offline"}, "gallowsCalibrator": {"color": "#008282", "handle": "gallowsCalibrator", "mood": "offline"}, "rageInducer": {"color": "#00ffff", "handle": "rageInducer", "mood": "offline"}, "anguillaNuntia": {"color": "#ff007f", "handle": "anguillaNuntia", "mood": "offline"}, "greenZephyr": {"color": "#00ca40", "handle": "greenZephyr", "mood": "offline"}, "lawdEngrish": {"color": "#00ff00", "handle": "lawdEngrish", "mood": "offline"}, "pretentiousFantasia": {"color": "#ff66cf", "handle": "pretentiousFantasia", "mood": "offline"}, "counterRealist": {"color": "#10d985", "handle": "counterRealist", "mood": "offline"}, "maxiumumFatness": {"color": "#3366ff", "handle": "maxiumumFatness", "mood": "offline"}, "schlagzeugGator": {"color": "#61821f", "handle": "schlagzeugGator", "mood": "offline"}, "metaliAggressive": {"color": "#9289d5", "handle": "metaliAggressive", "mood": "offline"}, "pesterClient394": {"color": "#ff3737", "handle": "pesterClient394", "mood": "offline"}, "magmaExploiter": {"color": "#d90000", "handle": "magmaExploiter", "mood": "offline"}, "gardenGnostic": {"color": "#00ff00", "handle": "gardenGnostic", "mood": "offline"}, "unknownTraveler": {"color": "#006666", "handle": "unknownTraveler", "mood": "offline"}, "utilitarianTurnabout": {"color": "#dd0000", "handle": "utilitarianTurnabout", "mood": "offline"}, "adiosToreador": {"color": "#aa5500", "handle": "adiosToreador", "mood": "offline"}}
\ No newline at end of file
diff --git a/memos.py b/memos.py
index c44588d..10b7786 100644
--- a/memos.py
+++ b/memos.py
@@ -6,7 +6,7 @@ from datetime import time, timedelta, datetime
from dataobjs import PesterProfile, Mood, PesterHistory
from generic import PesterIcon, RightClickList
from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow
-from parsetools import convertTags, escapeBrackets, addTimeInitial, timeProtocol
+from parsetools import convertTags, addTimeInitial, timeProtocol
def delta2txt(d, format="pc"):
if format == "pc":
@@ -227,6 +227,7 @@ class MemoText(PesterText):
parent = self.parent()
window = parent.mainwindow
me = window.profile()
+ quirks = window.userprofile.quirks if parent.applyquirks else None
msg = unicode(text)
chumdb = window.chumdb
if chum is not me: # SO MUCH WH1T3SP4C3 >:]
@@ -268,6 +269,8 @@ class MemoText(PesterText):
time.openCurrentTime()
if msg[0:3] == "/me" or msg[0:13] == "PESTERCHUM:ME":
+ if quirks:
+ msg = quirks.apply(msg)
if msg[0:3] == "/me":
start = 3
else:
@@ -279,9 +282,8 @@ class MemoText(PesterText):
else:
if chum is not me:
msg = addTimeInitial(msg, parent.times[chum.handle].getGrammar())
- msg = escapeBrackets(msg)
- self.append(convertTags(msg))
- window.chatlog.log(parent.channel, convertTags(msg, "bbcode"))
+ self.append(convertTags(msg, quirksobj=quirks))
+ window.chatlog.log(parent.channel, convertTags(msg, "bbcode", quirks))
def changeTheme(self, theme):
@@ -554,23 +556,19 @@ class PesterMemo(PesterConvo):
if self.time.getTime() == None:
self.sendtime()
grammar = self.time.getGrammar()
- # deal with quirks here
- if self.applyquirks:
- qtext = self.mainwindow.userprofile.quirks.apply(text)
- else:
- qtext = text
- if qtext[0:3] != "/me":
+ if text[0:3] != "/me":
initials = self.mainwindow.profile().initials()
colorcmd = self.mainwindow.profile().colorcmd()
- clientText = "%s%s%s: %s" % (colorcmd, grammar.pcf, initials, grammar.number, qtext)
+ clientText = "%s%s%s: %s" % (colorcmd, grammar.pcf, initials, grammar.number, text)
# account for TC's parsing error
- serverText = "%s: %s " % (colorcmd, initials, qtext)
+ serverText = "%s: %s " % (colorcmd, initials, text)
else:
- clientText = qtext
+ clientText = text
serverText = clientText
self.addMessage(clientText, True)
# convert color tags
- serverText = convertTags(unicode(serverText), "ctag")
+ quirks = self.mainwindow.userprofile.quirks if self.applyquirks else None
+ serverText = convertTags(unicode(serverText), "ctag", quirks)
self.messageSent.emit(serverText, self.title())
self.textInput.setText("")
@QtCore.pyqtSlot()
diff --git a/memos.pyc b/memos.pyc
index b63b81e..749749e 100644
Binary files a/memos.pyc and b/memos.pyc differ
diff --git a/menus.pyc b/menus.pyc
index 53c48cf..a4bfd9e 100644
Binary files a/menus.pyc and b/menus.pyc differ
diff --git a/oyoyo/__init__.pyc b/oyoyo/__init__.pyc
index 28e3e80..be26c04 100644
Binary files a/oyoyo/__init__.pyc and b/oyoyo/__init__.pyc differ
diff --git a/oyoyo/client.pyc b/oyoyo/client.pyc
index 9115adc..5ba5325 100644
Binary files a/oyoyo/client.pyc and b/oyoyo/client.pyc differ
diff --git a/oyoyo/cmdhandler.pyc b/oyoyo/cmdhandler.pyc
index d97b3d1..e9def19 100644
Binary files a/oyoyo/cmdhandler.pyc and b/oyoyo/cmdhandler.pyc differ
diff --git a/oyoyo/helpers.pyc b/oyoyo/helpers.pyc
index e5b17da..e5c82c4 100644
Binary files a/oyoyo/helpers.pyc and b/oyoyo/helpers.pyc differ
diff --git a/oyoyo/ircevents.pyc b/oyoyo/ircevents.pyc
index c83999f..1f1ccd6 100644
Binary files a/oyoyo/ircevents.pyc and b/oyoyo/ircevents.pyc differ
diff --git a/oyoyo/parse.pyc b/oyoyo/parse.pyc
index 9095b24..e67f2ea 100644
Binary files a/oyoyo/parse.pyc and b/oyoyo/parse.pyc differ
diff --git a/parsetools.py b/parsetools.py
index 91308d9..cb703f9 100644
--- a/parsetools.py
+++ b/parsetools.py
@@ -4,35 +4,40 @@ from datetime import timedelta
from PyQt4 import QtGui
_ctag_begin = re.compile(r'(?i)')
+_ctag_end = re.compile(r'(?i)')
_ctag_rgb = re.compile(r'\d+,\d+,\d+')
-_urlre = re.compile(r"(?i)(http://[^\s<[]+)")
+_urlre = re.compile(r"(?i)http://[^\s]+")
_memore = re.compile(r" (#[A-Za-z0-9_]+)")
def lexer(string, objlist):
"""objlist is a list: [(objecttype, re),...] list is in order of preference"""
stringlist = [string]
for (oType, regexp) in objlist:
- newstringlist = copy(stringlist)
+ newstringlist = []
for (stri, s) in enumerate(stringlist):
- tmp = []
+ if type(s) not in [str, unicode]:
+ newstringlist.append(s)
+ continue
lasti = 0
- for m in regexp.finditer(string):
+ for m in regexp.finditer(s):
start = m.start()
end = m.end()
- tag = oType(group(0), *groups())
- tmp.append(string[lasti:start])
- tmp.append(tag)
+ tag = oType(m.group(0), *m.groups())
+ if lasti != start:
+ newstringlist.append(s[lasti:start])
+ newstringlist.append(tag)
+ lasti = end
if lasti < len(string):
- tmp.append(string[lasti:])
- stringlist = stringlist[0:stri]+tmp+stringlist[stri+1:]
+ newstringlist.append(s[lasti:])
stringlist = copy(newstringlist)
return stringlist
-def convertTags(string, format="html"):
- if format not in ["html", "bbcode", "ctag"]:
- raise ValueError("Color format not recognized")
- def colorrepfunc(matchobj):
- color = matchobj.group(1)
+class colorBegin(object):
+ def __init__(self, string, color):
+ self.string = string
+ self.color = color
+ def convert(self, format):
+ color = self.color
if _ctag_rgb.match(color) is not None:
if format=='ctag':
return "" % (color)
@@ -51,69 +56,75 @@ def convertTags(string, format="html"):
elif format == "ctag":
(r,g,b,a) = qc.getRgb()
return '' % (r,g,b)
- string = _ctag_begin.sub(colorrepfunc, string)
- endtag = {"html": "", "bbcode": "[/color]", "ctag": ""}
- string = string.replace("", endtag[format])
- def urlrep(matchobj):
- if format=="html":
- return "%s" % (matchobj.group(1).replace("&", "&"), matchobj.group(1))
- elif format=="bbcode":
- return "[url]%s[/url]" % (matchobj.group(1).replace("&", "&"))
- elif format=="ctag":
- return matchobj.group(1)
- string = _urlre.sub(urlrep, string)
- if format == "html":
- string = _memore.sub(r" \1", string)
- for (code, f) in smiledict.iteritems():
- string = string.replace(" %s" % (code), " " % (f))
- return string
+class colorEnd(object):
+ def __init__(self, string):
+ self.string = string
+ def convert(self, format):
+ if format == "html":
+ return ""
+ elif format == "bbcode":
+ return "[/color]"
+ else:
+ return self.string
+class hyperlink(object):
+ def __init__(self, string):
+ self.string = string
+ def convert(self, format):
+ if format == "html":
+ return "%s" % (self.string, self.string)
+ elif format == "bbcode":
+ return "[url]%s[/url]" % (self.string)
+ else:
+ return self.string
+class smiley(object):
+ def __init__(self, string):
+ self.string = string
+ def convert(self, format):
+ if format == "html":
+ return "" % (smiledict[self.string])
+ else:
+ return self.string
-def escapeBrackets(string):
- class beginTag(object):
- def __init__(self, tag):
- self.tag = tag
- class endTag(object):
- pass
- newlist = []
- begintagpos = [(m.start(), m.end()) for m in _ctag_begin.finditer(string)]
- lasti = 0
- for (s, e) in begintagpos:
- newlist.append(string[lasti:s])
- newlist.append(beginTag(string[s:e]))
- lasti = e
- if lasti < len(string):
- newlist.append(string[lasti:])
- tmp = []
- for o in newlist:
- if type(o) is not beginTag:
- l = o.split("")
- tmp.append(l[0])
- l = l[1:]
- for item in l:
- tmp.append(endTag())
- tmp.append(item)
- else:
- tmp.append(o)
- btlen = 0
- etlen = 0
- retval = ""
- newlist = tmp
- for o in newlist:
- if type(o) is beginTag:
- retval += o.tag.replace("&", "&")
- btlen +=1
- elif type(o) is endTag:
- if etlen >= btlen:
- continue
+def convertTags(string, format="html", quirkobj=None):
+ if format not in ["html", "bbcode", "ctag"]:
+ raise ValueError("Color format not recognized")
+ lexlist = [(colorBegin, _ctag_begin), (colorEnd, _ctag_end),
+ (hyperlink, _urlre), (hyperlink, _memore),
+ (smiley, _smilere)]
+
+ lexed = lexer(string, lexlist)
+ balanced = []
+ beginc = 0
+ endc = 0
+ for o in lexed:
+ if type(o) is colorBegin:
+ beginc += 1
+ balanced.append(o)
+ elif type(o) is colorEnd:
+ if beginc >= endc:
+ endc += 1
+ balanced.append(o)
else:
- retval += ""
- etlen += 1
+ balanced.append(o.string)
else:
- retval += o.replace("&", "&").replace("<", "<").replace(">", ">")
- if btlen > etlen:
- for i in range(0, btlen-etlen):
- retval += ""
- return retval
+ balanced.append(o)
+ if beginc > endc:
+ for i in range(0, beginc-endc):
+ balanced.append(colorEnd(""))
+
+ escaped = ""
+ for o in balanced:
+ if type(o) in [str, unicode]:
+ if quirkobj:
+ o = quirkobj.apply(o)
+ if format == "html":
+ escaped += o.replace("&", "&").replace(">", ">").replace("<","<")
+ else:
+ escaped += o
+ else:
+ escaped += o.convert(format)
+ return escaped
+
def addTimeInitial(string, grammar):
endofi = string.find(":")
@@ -196,3 +207,5 @@ smiledict = {
":befuddled:": "what.gif",
":pumpkin:": "whatpumpkin.gif",
":trollcool:": "trollcool.gif"}
+
+_smilere = re.compile("|".join(smiledict.keys()))
diff --git a/parsetools.pyc b/parsetools.pyc
index 15d589a..7b8e8b9 100644
Binary files a/parsetools.pyc and b/parsetools.pyc differ
diff --git a/pesterchum.py b/pesterchum.py
index 2a00624..5d87bed 100644
--- a/pesterchum.py
+++ b/pesterchum.py
@@ -9,6 +9,7 @@ import json
import codecs
import re
import socket
+import platform
from PyQt4 import QtGui, QtCore
import pygame
@@ -66,7 +67,10 @@ class PesterLog(object):
os.mkdir("logs/%s/%s" % (self.handle, handle))
fp = codecs.open("logs/%s/%s/%s.%s" % (self.handle, handle, handle, time), encoding='utf-8', mode='a')
self.convos[handle] = fp
- self.convos[handle].write(msg+"\n")
+ if platform.system() == "Windows":
+ self.convos[handle].write(msg+"\r\n")
+ else:
+ self.convos[handle].write(msg+"\n")
self.convos[handle].flush()
def finish(self, handle):
if not self.convos.has_key(handle):
diff --git a/profiles/doctorHorrible.js b/profiles/doctorHorrible.js
new file mode 100644
index 0000000..e9ba3a0
--- /dev/null
+++ b/profiles/doctorHorrible.js
@@ -0,0 +1 @@
+{"color": "#000000", "theme": "pesterchum", "quirks": [], "handle": "doctorHorrible"}
\ No newline at end of file
diff --git a/profiles/ghostDunk.js b/profiles/ghostDunk.js
index 43ce8df..ea311d0 100644
--- a/profiles/ghostDunk.js
+++ b/profiles/ghostDunk.js
@@ -1 +1 @@
-{"color": "#ff00ff", "theme": "trollian", "quirks": [], "handle": "ghostDunk"}
\ No newline at end of file
+{"color": "#ff00ff", "theme": "pesterchum", "quirks": [{"to": "7", "from": "t", "type": "replace"}], "handle": "ghostDunk"}
\ No newline at end of file