Want to convert all boren from boren to BoreN
Match: .* From: boren To: BoreN
Pretty straight forward, match anything, then substitute boren with BoreN.
You want to match everything with boren in it and send to the window called “boren”
Match: boren From: ^ To: ˜boren˜
Looks for “boren” if found, substitutes the beginning of the string (^) with ˜boren˜.
Though the previous example works, if the string already has
˜somewindow˜
on it, you'll now have two
˜boren˜˜somewindow˜...
So you
can do this instead.
Match: boren From: ^(?:˜\S+˜) To: ˜boren˜
Ok, the from line is a little bit more complicated. It means: match
0 or 1 copies of ˜\S+˜
. Which is 1
tilde, one or more non-whitespaces, and then another tilde. The
paranoid might do (*:˜\S+˜)
, which means:
match 0 or more channel directives in case prior rules are
broken.
Server kill messages tend to be long, ugly, annoying, etc. A basic message on dalnet looks like:
*** Notice -- Received KILL message for BOBO!ANDY@line82-basel.datacomm.ch from NickServ Path: empire.ny.us.dal.net[209.51.168.14]!trapdoor.ca.us.dal.net [206.86.127.252]!caris.ca.us.dal.net[208.1.222.221] !services.dal.net[2008.1.222.222]!services.dal.net (NickServ Enforcement)
When you're +s
you get tons of them; you don't
want all of them flying across your screen. I'm going to make 3 rules
to deal with them one bit at a time. You could do it in less rules, but
it'll show you the basic rule structure, in nice steps, and how to use
multiple rules to parse a message. The first step is to remove the
Path: portion of the message:
Match: ^\*\*\*.* KILL message for.* From: Path: \S+ To: .
Match looks for the message starting with ***
,
the *
's have to be quoted with \
since by themselves they mean 0 or more of the prior character.
.*
means: match anything until you find
KILL message for
. This allows us to avoid typing in
-- Received...
etc. The trailing
.*
means: match anything to the end of the line. (not
needed, I think)
The From line means: substitute " Path: " and any
non-whitespace characters with the To. To is a "."
therefore the entire path turns into a single period.
The message now looks like:
*** Notice -- Received KILL message for BOBO!ANDY@line82-basel.datacomm.ch from NickServ. (NickServ Enforcement)
Notice the new "."
after
NickServ
?
Ok, the message is a lot cleaner, but KILLs from nickserv aren't
really that important, so let's forward them to the
!discard
window.
Match: ^\*\*\*.*KILL message.*\(NickServ Enforcement\) From: ^(?:˜\S+˜) To: ˜!discard˜
Match rule searches for the KILL message and makes sure it's from
NickServ. Notice the \(
and \)
are both used in regex, therefore we have to quote
them. This is very similar to what we said two examples before.
We've now filtered out all the nickserv kills, but the message is still pretty hard to read by simply glancing at it. So let's reorder it to something like:
*** [KILL]KILLER
; killedKILLED
; (REASON
)
Match: \*\*\*.*KILL message From: \*\*\*.*for (.*?) from (.*?)\. \((.*?)\).* To: *** [KILL] $$2 killed $$1 ($$3)
Ok, the match looks for
***
.
We can't use something
KILL message^
since we may have just appended
˜<window>˜
.
The from line gets a little more interesting. The "for
(.*?) "
looks for the word "for" then some text.
.*?
means: match zero or more of anything except
newline, but isn't greedy. The rule is to stop when the first terminating condition is
found, not the last. In other words it matches anything until a space is encountered.
The surrounding ()
means: save the contents. Each
() saves the matched data in $#
where
#
starts at 1 for the first substring, etc. In
this case, $1
gets the nick/user-info of the person
killed. $2
is then filled with the name of the
killer. Between the ()
we have the reason for the
kill. Here the (
and \(
get a
little confusing. Remember \(
matches the actual
character '('
.
How to colorize your life.
Ok, you want to add some color to
KSirc. See the Colors section for
color info, but here's a filter rule to highlight the nickname between
<NICK>
on each line:
Match: ^(?:˜\S+˜)<\S+> From: <(\S+)> To: <˜4$$1˜c>
Takes the nickname and adds color #4 between the two
<>
. ˜c
clears the color.
Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team