From be18980fa53d8095d1ec01bd009eb77b4ec53b32 Mon Sep 17 00:00:00 2001 From: Stephen Dranger Date: Mon, 21 Feb 2011 13:07:59 -0600 Subject: [PATCH] dsfa --- TODO | 6 +- convo.py | 5 +- convo.pyc | Bin 25659 -> 25674 bytes dataobjs.py | 24 +++-- dataobjs.pyc | Bin 14331 -> 14563 bytes irc.py | 26 +++-- irc.pyc | Bin 14880 -> 15170 bytes logs/chums.js | 2 +- menus.py | 7 +- menus.pyc | Bin 25786 -> 26130 bytes oyoyo/client.py | 45 +++++---- oyoyo/client.pyc | Bin 10670 -> 10871 bytes parsetools.py | 2 + parsetools.pyc | Bin 11107 -> 11147 bytes pesterchum.js | 2 +- pesterchum.py | 55 ++++++++--- profiles/ghostDunk.js | 2 +- readme.txt | 222 ++++++++++++++++++++++++++++++++++++++++++ 18 files changed, 336 insertions(+), 62 deletions(-) diff --git a/TODO b/TODO index d0913ce..41b5bdd 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ Bugs: -* idle doesnt seem to work? +* import quirks from 2.5! +* edit quirks? +* begin and end regexps should only be applied once! * X and _ buttons move around all crazy like Features: @@ -8,7 +10,6 @@ Features: * shared buddy lists - changes to the buddy list should refresh it? multiple clients share buddy list??? * chumList not scaling -- QListView + delegate? -* spell check? * help button on quirks menu? -- release beta * hide offline chums @@ -22,4 +23,3 @@ Features: * don't clear new message when clicking away from tab? * Spy mode * Animated -* put code into separate files diff --git a/convo.py b/convo.py index f67505c..892cf49 100644 --- a/convo.py +++ b/convo.py @@ -264,9 +264,10 @@ class PesterText(QtGui.QTextEdit): idlethreshhold = 60 if (not hasattr(self, 'lastmsg')) or \ datetime.now() - self.lastmsg > timedelta(0,idlethreshhold): + verb = window.theme["convo/text/idle"] idlemsg = me.idlemsg(systemColor, verb) - self.textArea.append(convertTags(idlemsg)) - window.chatlog.log(self.title(), idlemsg) + parent.textArea.append(convertTags(idlemsg)) + window.chatlog.log(parent.title(), idlemsg) parent.messageSent.emit("PESTERCHUM:IDLE", parent.title()) self.lastmsg = datetime.now() window.chatlog.log(chum.handle, lexmsg) diff --git a/convo.pyc b/convo.pyc index c5603c49dda375b5b3afbed6af96986a7f63b14d..55a2ab4765bce4b279e1c7b4b8b3319584e0fe2b 100644 GIT binary patch delta 649 zcmYjPOGuPa6h7ZHYD~@pqlOuq5zWUmEn<9T5Gi+2)WSs%2Sdb_q#F}KB201@wCLV(6WsH0&i%e~?m73~4@t}>k+HC4 zHr1~+PGu|=SZqX;CapqR>^E-~EW*w+g)Nw5U(q#$xKH9=UX?h+Cp{qqnLSNBq}i!$g00>_SL-&PPR$l_#4V)nBrS_{Bk30EHc;G3N}fxa zl{##sTd5mrrHW>fW=_$0s~N9hP9+dU#CvZKP#{hn za)6`7MX>S1;@({yMmcNejeAYCgPiLRm|`-VSL5qk=ZnG2pM5LH;<3Z;uvbL`P92G)VEUDm#}4=kP?>F5CttIDYZGZA7-?F-WNOD;VKueSodi zR!nhD^=y7ZZK}3C>gl#MTgn?(Fs$IY8ZAv}ga}^hg?zDvnmzKo^_o6Ri}uSdV4nMH zUt*EV>Rw@)SL>#+B8IMH0&D!Heg^9j-TXAvik|{k%Z)O*vY`8<8OQL~dc9^xh(eM;o8XJ3AfyCcloe=`|`vvZ)^KUIu*w)bKN0HTJ4>9q<1gV7J zP+@-_v?(JfTGuEL^r2`nsOX_26U>UB2u3~xK|%LUxaZ@X`+fJj=iHl`$ILuTZ&!28 z;cS1xv{-7a$E&8` z=7#DBCU~xT0Oexe?vId#)f+`6-|$|BQxxw>nlT~1*S!Gh_+kAYT;ce^ag2&X4QYcE z|2t5??M<(6O>AjC1H}32;l{j4*^I*=p`${#HYQ;k69M<((3;zQx+`upZ diff --git a/dataobjs.py b/dataobjs.py index dcf4d4b..59ff55f 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -4,7 +4,7 @@ import re import random from generic import PesterIcon -from parsetools import timeDifference, convertTags +from parsetools import timeDifference, convertTags, lexMessage from mispeller import mispeller _upperre = re.compile(r"upper\(([\w\\]+)\)") @@ -116,7 +116,7 @@ class pesterQuirks(object): suffix = [q for q in self.quirklist if q.type=='suffix'] replace = [q for q in self.quirklist if q.type=='replace' or q.type=='regexp'] - random = [q for q in self.quirklist if q.type=='random'] + randomrep = [q for q in self.quirklist if q.type=='random'] spelling = [q for q in self.quirklist if q.type=='spelling'] newlist = [] @@ -133,19 +133,27 @@ class pesterQuirks(object): string = o for s in spelling: string = s.apply(string) - for r in random: + for r in randomrep: string = r.apply(string, first=(i==0), last=lastStr) for r in replace: string = r.apply(string, first=(i==0), last=lastStr) if i == 0: - for p in prefix: - string = p.apply(string) + if len(prefix) >= 1: + myprefix = random.choice(prefix) + string = myprefix.apply(string) if lastStr: - for s in suffix: - string = s.apply(string) + if len(suffix) >= 1: + mysuffix = random.choice(suffix) + string = mysuffix.apply(string) newlist.append(string) - return newlist + final = [] + for n in newlist: + if type(n) in [str, unicode]: + final.extend(lexMessage(n)) + else: + final.append(n) + return final def __iter__(self): for q in self.quirklist: diff --git a/dataobjs.pyc b/dataobjs.pyc index 842d57821da34d7eb54fad173b060f089e36fa8d..b0e536168b8202d820c5771664e74440065e0b0c 100644 GIT binary patch delta 3636 zcmZuzYiwLc6`t96*N#P8>I(wVk-GV<&MYg)~l_`eyI7_a^(W z_g)iQ*mX-v`lmp{P>Gj9ng|3Ev&2=R*wRq79dc%1Lt^{ySo z(jL!zbIzIbzVq+wU*}rhey_4({srT3LgfD{=zl-`ocAxcOs%AXVj?J{DTEmi=R+bD z5)&aItrB5Z3bRyPlwzVvm}SBWi)ks$a`BuH7lk-E5fNs^8X7F1)xr#|p_K)+MwnG= zXt;pZ3bQV<23Hs0I$b6Y$xZsW>8=b}_ z5fx+XR*AK{9M~pc9|8djYZ=Ly*1}LOm(9g}IEdk(gh<9nTY7v;pX}6M@c(#AC-5>N zqt+s`D=70c#fzAyvRl6uYUe*va9J7W!v~pp7%F4L7FK4kr*H3F_Hf6iTn~m97D`Tosh#*+!vUVmOq6KC2 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jDlb_%_lfu{tqs&FO|hSb+kFU^ z8r1I+$#!p}UHx2@DJx~K{79?r+d+1O_aU#g^?0PWnadZdGR~@%i?6Py)Q)~MqU6u? zt;lajdT7TD$eq$q!EXYp)lE5va0km?o)`aX^j4)Z8Ivq{Qy(%m!|$V`Y|^mgwW4Ig zOv3hGkR44r(v$uOOS9=;!X4XyCkfmKk_!bY96unDvX19ssZ=bdT$NRa8sx8Z>!CNd zFbCY|eUT^yW!!+DUbWJSz1ar8bRFjjbH#va*H^v?{pFbIS#Ym`Ml;1%W9hV&R7K_L zE7+<6kX4S?y6jN!@k`>Xy+Qewex>&(lY2cTyzJ6Q3 z{^5_ycXV^#8yEN9T;>v@Rpu9J!NBjYl1u7&EQ=1^;e>htyKH*{hncD?gC~{pbXz}m z_enp`MTt{u>|v-sDF2`%{clWefQfB)u*?$0b!}TQDm%9g5d1T_b<52tmnsj@MNruK!97BvAw_Lb-K8NMwfF}SN@C@KO;0EA1 zz>9#d0lrS))DqZE%t_S8DT}KaQ+)$_-^6hAW{AA5XYT!1i2E7sZO1-knWeEb#uM;8 z{Y>;(<2w*!`#2!qrX^P(M9PNt7ue&SL9aJWHS+k>DrNK)a}nqDw{}J{9}|WFmvf)EAF_Z j(vQP<=@c@mUZ$HS^v#jZ`W6}V1UxNmEk|0SEern#L`-yX diff --git a/irc.py b/irc.py index 979e401..ae58c52 100644 --- a/irc.py +++ b/irc.py @@ -16,22 +16,29 @@ class PesterIRC(QtCore.QThread): QtCore.QThread.__init__(self) self.mainwindow = window self.config = config + self.registeredIRC = False + self.stopIRC = None def IRCConnect(self): server = self.config.server() port = self.config.port() - self.cli = IRCClient(PesterHandler, host=server, port=int(port), nick=self.mainwindow.profile().handle, real_name='pcc30', blocking=True, timeout=5) + self.cli = IRCClient(PesterHandler, host=server, port=int(port), nick=self.mainwindow.profile().handle, real_name='pcc30', blocking=True, timeout=15) self.cli.command_handler.parent = self self.cli.command_handler.mainwindow = self.mainwindow - self.conn = self.cli.connect() - self.stopIRC = None - self.registeredIRC = False + self.cli.connect() + self.conn = self.cli.conn() def run(self): - self.IRCConnect() + try: + self.IRCConnect() + except socket.error, se: + self.stopIRC = se + return while 1: + res = True try: + logging.debug("updateIRC()") res = self.updateIRC() except socket.timeout, se: - print "timeout in thread %s" % (self) + logging.debug("timeout in thread %s" % (self)) self.cli.close() self.stopIRC = se return @@ -40,16 +47,18 @@ class PesterIRC(QtCore.QThread): self.stopIRC = None else: self.stopIRC = se + logging.debug("socket error, exiting thread") return else: if not res: + logging.debug("false Yield: %s, returning" % res) return def setConnected(self): self.registeredIRC = True self.connected.emit() def setConnectionBroken(self): - print "setconnection broken" + logging.debug("setconnection broken") self.reconnectIRC() #self.brokenConnection = True @QtCore.pyqtSlot() @@ -64,12 +73,13 @@ class PesterIRC(QtCore.QThread): except socket.error, se: raise se except StopIteration: + self.conn = self.cli.conn() return True else: return res @QtCore.pyqtSlot() def reconnectIRC(self): - print "reconnectIRC() from thread %s" % (self) + logging.debug("reconnectIRC() from thread %s" % (self)) self.cli.close() @QtCore.pyqtSlot(PesterProfile) diff --git a/irc.pyc b/irc.pyc index c529c5e2574dc102db6f7d05214041494bb38d44..3176494144726dfd1d8fe0fc933fe4f328217195 100644 GIT binary patch delta 4034 zcmbVPT}&L;6~1?27k1g@*MJR+SzKe59~1LqFNP#7Mnth|uzhg?4sy}5JHXh>4D1XT z6x*xXbsp+QX?$fhvErynswP#_R;k-YO7oOfs!~6+m0I<&Qh%N!Regx^(Dr<1mR(Hk zs*TW`y+7xkbMAM(b7uIq`_X#fcYlwBzV+sNfsab%kp8%|eXr{mmxY)Mh_v8AIR;a4 zDTJ7e2lZ#ABYmVI#8b(PW4I9-WsODCagD5zKCZ^xQYhM%;g-?BaqSga)QA1EZ6TTq zSuKP7mx93(dMfD|qsMt$|G=+nB{?@k!mJe6J^z(@Ixy2*MH+Dk1&?k32aN2xkyZ8j z*MaLbahOuI5X}(v`lYh*Ts_p_K*%ck8>gpMMr6TvkapO&pQ72U#C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nYr)D?=J-IIX@(*BidzXZO16 zqy0$ru%C@J>UDa)aj`#t0*-mgvF!hG01TV}oRow+*Hoe2qAxZrud|X#WW7&pMFNmE zr@Y~rgl(JY@6+l%&kx<{)>$igc0+^chqq<1?;F;T&%^3n`r4NFj*BgHeV<9(bJj_j z8yduW*f%J)CV48YB^7laEpSJ1z<^{cv@UH5hruIynsIc>_aQ{qS3nVx1p zWYMyx94*AwLk<;w0>yYpUZGoX#w=hbAlJP7W-*GjM*z9nmREE#ZJD;Gv)GwC#3=df zX4002iy7JmIDia8T+B+Lqw|PcNlp*HYf4)hrC9uF^@p3^h)30mI30_99ir7hd^Z7f1Y zj4xm$0g=!kdU2s5&mmGUYbIRB=B6yo^F>~%p?B_|XuH!!T!IfxiJg z_S4&)h1_p1b-b+3QLMA+;7h#qNj%Eg^{*=yulQ!gp$Q&0(GNSXgyi;T==jdNK)o8yBTp%mYK!sCxc-(+T=$=fT#yU08pWMSUwM{aZ|7yo0WG{cHt}`5Dc5 zlbY1Hx{G_YxO-b%37A~Y&tUOgYF`rZWtQ{fl`kOSM8fwhcKZO5g*mePxTjNyLO_3o z{vdQ)@cTzGm*)db}FBFerfoM5Io_h?CU%}NH_XYozV2T^e_?+bClhtEzZ4) zv!z1Q_+QFSjoe)7?^Z{}KFG?qD}52u{F_rq=;pQCd_$0O&0{(}Kgq9!e-8|=eOwOh z=^UGekr}|30ha+U08n%K2>_B^a#TyENdx#c)?NeL0N}RzO+YWbzvqEq9S?s`YVS&k Yg!(z`#Od3}hDz0*M+1hD;!01Sw|(ni;GC zQsSq<1SEs3fkX)lkjThPNu68}?jXbqL6q=FeGO;jDw&$~%+>&C-C<2JItiB(fzU|>jPV2EO5NC6@Sh89MKC}xIK7KTh#hGw8R z8$(dA2GeHkI5}o!KMnTDr)*^>uTBc(U;*l5W8@K=%#*yG(PZ+G>> cli = IRCClient(my_handler, host="irc.freenode.net", port=6667) - >>> g = cli.connect() - >>> while 1: - ... g.next() - """ - #logfile = open('irctest.log', 'a') - try: - logging.info('connecting to %s:%s' % (self.host, self.port)) - self.socket.connect(("%s" % self.host, self.port)) - if not self.blocking: - self.socket.setblocking(0) - if self.timeout: - self.socket.settimeout(self.timeout) - helpers.nick(self, self.nick) - helpers.user(self, self.nick, self.real_name) + logging.info('connecting to %s:%s' % (self.host, self.port)) + self.socket.connect(("%s" % self.host, self.port)) + if not self.blocking: + self.socket.setblocking(0) + if self.timeout: + self.socket.settimeout(self.timeout) + helpers.nick(self, self.nick) + helpers.user(self, self.nick, self.real_name) - if self.connect_cb: - self.connect_cb(self) + if self.connect_cb: + self.connect_cb(self) + def conn(self): + """returns a generator object. """ + try: buffer = bytes() while not self._end: try: @@ -169,12 +163,12 @@ class IRCClient: except socket.timeout, e: if self._end: break - print "timeout in client.py" + logging.debug("timeout in client.py") raise e except socket.error, e: if self._end: break - print "error %s" % e + logging.debug("error %s" % e) try: # a little dance of compatibility to get the errno errno = e.errno except AttributeError: @@ -202,14 +196,19 @@ class IRCClient: yield True except socket.timeout, se: + logging.debug("passing timeout") raise se except socket.error, se: - print "problem: %s" % (se) + logging.debug("problem: %s" % (se)) if self.socket: logging.info('error: closing socket') self.socket.close() raise se + except Exception, e: + logging.debug("other exception: %s" % e) + raise e else: + logging.debug("ending while, end is %s" % self._end) if self.socket: logging.info('finished: closing socket') self.socket.close() diff --git a/oyoyo/client.pyc b/oyoyo/client.pyc index 31c4e50a7b7e397e38ad5523634415ac9aa0b574..6f10e6db8cfd4514e82aa4882e0d83e0b8408a6c 100644 GIT binary patch delta 1654 zcmZ`(U1%It6h3Euc6T`ZI|yDk{kO;#7F9#V+b{XiyGK1L*FqX zJ4STJh(Tz`tqEGemjt5O{aM1+C{1VA zX%L_9nHJyl9#E%?De-pJ69fGx8;?+Ii{m{6pcT->IQG!WVg_?c94lNnPOFnvg;sD= z0oeEiLx4?yI>P$n-O05LF;jFOxTtY`QV1t8{pQ4mTt}O?>3i zq)o0tK~Djk;|b!B@F`lOwslxiz}Em*KajcH#;5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vGh-84j|V+O}i6zGXLR=De6K7V$ai z>zsO?QmS~r_>RI&2+S-jTI5V2m66B+sl>L#CCpwneQYkX2}F*v7xaFWz3XhasA0k3_D#n&CzR75--3Ubh@~!{-gWhWUcHS-#P~#-uPC{_L4cM871?k3Wu|{sYQz B5N7}Y diff --git a/parsetools.py b/parsetools.py index 8b5c757..b223c78 100644 --- a/parsetools.py +++ b/parsetools.py @@ -151,6 +151,8 @@ def lexMessage(string): if beginc > endc: for i in range(0, beginc-endc): balanced.append(colorEnd("")) + if len(balanced) == 0: + balanced.append("") if type(balanced[len(balanced)-1]) not in [str, unicode]: balanced.append("") return balanced diff --git a/parsetools.pyc b/parsetools.pyc index ded990b8bd964afd44c590835edda42d3dfeee7a..27b346241215b7b427aa9b44ec50ce7621937b7c 100644 GIT binary patch delta 109 zcmaDH)*a4%@e?ms`-X&#>`NpVH*H=c5ymJl%2311(9Fn?!pM-t#E>t@zzF1L3NfUx zfJ7NL|CQXq$Y?cro3tsjFr(n+SJJUej0-k<$h9#tZrOZZ{uLwRp3S=yg_#*oZ$77D M$Hu5QnO8du0Q;OEX#fBK delta 87 zcmV-d0I2_qSL0R((ee!nNv~V62c#GQj " +You type: "Hi" +Result: +CT: D --> Hi + +Suffixes work the same way, but at the end of the message: +SUFFIX: "!!!" +You type: hey there +Result: +GD: hey there!!! + +Remember that it doesn't automatically add a space! You'll need to add +it in (see CT and AC examples again!) + +Simple Replace: +This will simply take a set of characters and replace them with other +characters. Let's add a quirk to our Nepeta: + +Replace: "ee" With: "33" +You type: "*ac saunters from her dark cave a little bit sleepy from +the recent kill*" +Result: +AC: :33 < *ac saunters from her dark cave a little bit sl33py from the +recent kill* + +Let's add two to Equius: +Replace: "loo" With: "100" +Replace: "x" With "%" +You type: "look" +Result: +CT: D --> 100k +You type: "What are you expecting to accomplish with this" +Result: +CT: D --> What are you e%pecting to accomplish with this + +Aradia: +Replace: "o" With: "0" +You type: "and the reward would be within our reach" +Result: +AA: and the reward w0uld be within 0ur reach + +Notice that it is CASE SENSITIVE. So in the above case, if you typed +"ABSCOND", it would not replace the "O". + +Sollux: +Replace: "i" With: "ii" +Replace: "s" With: "2" + +Eridan: +Replace: "v" With: "vv" +Replace: "w" With: "ww" + +Feferi: +Replace: "h" with: ")(" +Replace: "H" with: ")(" +Replace: "E" with: "-E" + +Regexp Replace: + +This is a more complex kind of replacement. Regexp stands for "regular +expression", a kind of programming language (yes, it is a language) +used to find and replace text. PC 3.14 also includes a function to +handle capitalization (upper()). If you want to learn it on your own, +I suggest you start with the Python tutorial +(http://docs.python.org/howto/regex.html) since PC 3.14 uses Python's +regexps. Check out V2.5's tutorial too, as that is a pretty good start +as well. + +Let's start with Karkat. Regexps are just like your every day find and +replace: they search for a string that matches what you want to +replace, and replaces it with... the replacement. + +Regexp: "(.)" Replace with: "upper(\1)" + +Three concepts here. Let's look at the regexp. "(.)" has two things +going on. The first is that ".". In regexp speak, "." is the wildcard: +it will match *any* character -- and just one. + +The parentheses tell the regexp to *save* what's inside them so you +can put it back when you replace. That's what the "\1" is for -- it +means, "put the match inside parentheses #1 here". You can have any +number of parentheses. + +"upper()" is a function special to PC 3.14 -- it will uppercase +anything inside the parentheses. So in this case, upper will uppercase +"\1" -- which, as you recall is what we found inside the +parentheses. Which was *every* character. So to sum up, it replaces +every character with an uppercase version of that character. WHICH +MAKES YOU TALK LIKE THIS. + +Let's look at Terezi next. + +Regexp: "[aA]" Replace with: "4" +Regexp: "[iI]" Replace with: "1" +Regexp: "[eE]" Replace with: "3" +Regexp: "(.)" Replace with: "upper(\1)" + +We already know what the last line does. But what's up with those +brackets? What's their deal? Basically, in regular expressions, +brackets indicate a list of matching characters. So, basically any +single character within the brackets will be matched. In this case, +either "a" or "A" will be matched and replaced with "4," and likewise, +"i" and "I" will be replaced with "1", and "e" and "E" will be +replaced with "3." + +You should also know that "^" is a special character in brackets. If +placed immediately after the opening bracket (like "[^"), then the +brackets instead match every character *except* the ones in the +brackets. So, for example, if you wanted to have a quirk where you +capitalized all your letters *except* o, you'd do this: + +Regexp: "([^o])" Replace with: "upper(\1)" +You type: "hello there" +Result: +GD: HELLo THERE + +You can also specify a *range* of characters inside the brackets, by +using the "-" character. [a-z] will match any lowercase letter. You +can combine them, too: [a-z0-9] will match any digit and lowercase letter. + +There are also different shortcuts for character types: + +\d matches any digit; same as [0-9] +\D matches any non-digit; same as [^0-9] +\s matches any spaces +\S matches any non-space +\w matches any alphanumeric character; same as [a-zA-Z0-9_] +\W matches any non-alphanumeric character; same as [^a-zA-Z0-9_] + +You can include this inside brackets, too. + +There's also a special character, \b. What \b does is make sure that +you are at the beginning or end of a word. So with that knowledge, +let's try Kanaya: + +Regexp: \b(\w) Replace with: upper(\1) +You type: "i suggest you come to terms with it" +Result: +GA: I Suggest You Come To Terms With It + +Another feature of regular expressions is the ability to match +*repeated* characters. There are three repeat characters: the "*", the +"+", "?", and "{m,n}". They work by playing them after the character, +or character type you want to match. (So, you could say "\s+" or ".*") + +The "*" character matches ZERO or more of that character. So, for +example, "f*" would match "f" and "ff" -- and any other character! +That's right, every character counts as matching it zero times. Yeah, +it's weird. I suggest you use... + +The "+" character matches ONE or more of that character. So, if we +wanted to have a character that wanted to elongate their s's so that +they used four 's's every time, like sssso, but didn't want to have +eight s's when using words with double s's, like pass, we'd do this: + +Regexp: "s+" Replace with: "ssss" +You type: "you shall not pass" +Result: +UU: you sssshall not passss + +As for the other two, I can't really think of any useful quirks to be +made with them. But to let you know, "?" matches either 0 or 1 of that +character, so "trolls?" would match "troll" and "trolls". "{m,n}" +matches between m and n characters. (If you leave out 'n', any number +of characters more than m will be matched.) So "s{2,4}" will match +"ss", "sss", and "ssss" and that's it. + +Now with repeating expressions, we can do something like make EVERY +other WORD capitalized: + +Regexp: "(\w+) (\w+)" Replace with: "upper(\1) \2" +You type: "this is pretty annoying i bet" +Result: +GD: THIS is PRETTY annoying I bet + +The \1 matches the first word -- which has been matched because the +word is alphanumeric characters, repeated once or more -- and \2 +matches the second word. + +Another operator to use is the "|", which will match more than one set +of characters. For example, "black|red" will match "black" or +"red". If you want to match something in the middle of words, you have +to use parentheses: "(black|red) romance" will match "black romance" +and "red romance". + +Finally, there are the "^" and "$" characters. Yes, we already did the +"^" character, but this is OUTSIDE of brackets, not INSIDE. "^" +matches the beginning of a message, and "$" matches the end of it. You +can use this to make more sophisticated prefix and suffix +behaviors. For example, if we have a quirk that adds "..." to the end +of all our messages, we can set it up so it doesn't do that if we put +punctuation [?!.] at the end. So: + +Regexp: "([^?!.])$" Replace with: "\1..." + +This will match the end of any message as long as it doesn't have +"?", "!", or "." at the end. Then it will replace it with whatever the +last character of the sentence was (remember we're replacing it, so we +have to put it back!) and add "..." at the end. + +Careful with the beginning and ending replaces -- if you use more than +one, you may not get what you expect because they will ALL be applied, +one after the other! This is a bug in my opinion, that I plan to fix! + +Random replace: + SMILIES ------- Here's a list of smilies: