At some point in time I got quite sick of colourful tags making my colour scheme look hideous. I was happy with mIRC's colour stripping functionality until less than a month later, people started using hideously long, obscure tags. This was the result of my anguish.
I also wrote a colour replacement script for the sake of replacing the colour of non-tag text. This script is best left for removing tags only.
; Seb @ irc.icq.com wrote this 2/1/2010 @ 1.20am ;)
menu * {
Tagfilter
.Add Tag : TagFilter_Add
.Remove Tag : TagFilter_Rem
}
on ^1:TEXT:*:*: {
if ($chan == $null) {
echo -tlbfmrc Normal $nick < $+ $nick $+ > $tagfilter($1-)
goto end
}
echo -tlbfmrc Normal # < $+ $nick(#,$nick).pnick $+ > $tagfilter($1-)
:end
haltdef
}
alias tagfilter {
var %x = 1, %y = $hfind(tagfilter,$1-,0,R).data, %data = $1-
while (%x <= %y) {
%item = $hfind(tagfilter,$1-,%x,R).data
%data = $regsubex(%data,$hget(tagfilter,%item),\1)
inc %x
}
return %data
}
on 1:START: { hload tagfilter tags.txt }
on 1:EXIT: { hsave tagfilter tags.txt }
; ---------------------------------------------
alias TagFilter_Add {
dialog -m TagFilter_Add tagfilter_add
did -c TagFilter_Add 4,8
TagFilter_AddRefresh
}
/* ConstantToRegex
** Returns a string containing the sequence of characters input, suitably escaped for
** use in a regular expression for hashtables.
*/
alias ConstantToRegex {
var %regex = /([ \\])/g
if ($1- == $null) { return }
hadd -m repl_table 32 \E\x20\Q
hadd -m repl_table $asc(\) \\
return $+(\Q,$regsubex($1-,%regex,$hget(repl_table,$asc(\t))),\E)
}
/* TagFilter_AddRefresh
** Refreshes the interface of TagFilter_Add dialog (regenerates the regular expression)
*/
alias TagFilter_AddRefresh {
; head
var %tag = /
if ($did(TagFilter_Add,4).state == 1) { %tag = %tag $+ ^ }
if ($did(TagFilter_Add,5).state == 0) { %tag = %tag $+ $ConstantToRegex($did(TagFilter_Add,3).text) }
else { %tag = %tag $+ $did(TagFilter_Add,3).text }
%tag = %tag $+ (.*)
; tail
if ($did(TagFilter_add,9).state == 0) { %tag = %tag $+ $ConstantToRegex($did(TagFilter_Add,7).text) }
else { %tag = %tag $+ $did(TagFilter_Add,7).text }
if ($did(TagFilter_Add,8).state == 1) { %tag = %tag $+ $ }
%tag = %tag $+ /
; case insensitive
if ($did(TagFilter_Add,10).state == 1) { %tag = %tag $+ i }
did -ra TagFilter_Add 11 %tag
}
dialog -l tagfilter_add {
title "Add Tag Filter"
size 60 60 344 232
option pixels
box "Add Tag", 1, 8 8 328 216
text "Head Tag", 2, 16 32 60 24
edit "", 3, 80 24 240 24
check "Anchor", 4, 80 48 80 24
check "Regex", 5, 160 48 80 24
text "Tail Tag", 6, 16 88 60 24
edit "", 7, 80 88 240 24
check "Anchor", 8, 80 112 80 24
check "Regex", 9, 160 112 80 24
check "Case insensitive", 10, 16 140 304 24
text "", 11, 16 164 304 24, nowrap
button "Add Tag", 12, 16 192 304 24
}
on 1:DIALOG:TagFilter_Add:EDIT:3,7: {
TagFilter_AddRefresh
}
on 1:DIALOG:TagFilter_Add:SCLICK:4,5,8,9,10: {
TagFilter_AddRefresh
}
on 1:DIALOG:TagFilter_Add:SCLICK:12: {
hadd -m tagfilter $+(t,$hget(tagfilter,0).item) $did(TagFilter_Add,11).text
did -r TagFilter_Add 3,7,11
did -u TagFilter_Add 4,5,8,9,10
TagFilter_AddRefresh
if ($dialog(TagFilter_Rem) != $null) {
TagFilter_RemRefresh
}
}
; ---------------------------------------------
; ---------------------------------------------
alias TagFilter_Rem {
dialog -m TagFilter_Rem tagfilter_rem
TagFilter_RemRefresh
}
/* TagFilter_RemRefresh
** Refreshes the user interface of TagFilter_Rem dialog (populates the tagfilter listbox)
*/
alias TagFilter_RemRefresh {
var %x = 1, %y = $hget(tagfilter,0).item
did -r TagFilter_Rem 2
while (%x <= %y) {
did -a TagFilter_Rem 2 $hget(tagfilter,%x).data
inc %x
}
}
dialog -l tagfilter_rem {
title "Remove Tag Filter"
size 60 60 344 160
option pixels
box "Remove Tag", 1, 8 8 328 144
list 2, 16 32 312 100
button "Remove Tag", 3, 16 120 312 24
}
on 1:DIALOG:TagFilter_Rem:SCLICK:3: {
var %x = 1, %y = $did(TagFilter_Rem,2,0).sel
while (%x <= %y) {
hdel tagfilter $hget(tagfilter,$did(TagFilter_Rem,2,%y).sel).item
dec %y
}
TagFilter_RemRefresh
}
; ---------------------------------------------
Unless you have any issues with a section of the script that cause your computer to explode, please don't comment. I haven't an issue that people will comment on my code, but the comments that aren't on my code hardly seem to be relevant to the comment section that is for my code.
Style. I don't mean "mIRC scripting style", though if it exists, I don't care about that either. I mean the style of your user interface. I've been saying this the whole time: I don't care. If you want to change it, go for it, but why talk about those changes here? I've made it easy enough to change so you don't have to talk about it.
I usually review my script before posting. Things that look like what you posted earlier, gooshie, end up looking more like what is there. I wasn't thinking straight when I put the "return" in at the end, but if you've dealt with the people I've dealt with ("How do I change the style?") you'll try to make some things easier to change than others.
s00p,
Jethro_'s original post, sorta to me, was to point out how to have the channel mode prefix used before the nick name only show the most powerfull mode instead of all modes. It's a subtle improvement we here at Hawkee appreciate.
Sometimes two methods of scripting can be viewed as a stylistic difference and if I had thought this was the case I would not have commented. To be quite honest, using a goto jump instead of an else statement is probably more than just a little wrong and the use of return is unneeded in your original post. It's an often stated 'rule' to never use goto jumps, in any language, when any other method can be used. To date I have found only one way to use goto that actually improves understanding and I have an example posted as my Magic 8ball snippet. The return command is used most often in an alias to return a result as you have done with $tagfilter($1-).
Be advised that if you post code on Hawkee people will view and comment on your code. This really is the point of Hawkee and what keeps many of us coming back and trying, sometimes in an awkward way, to help the original poster. We will hope that when you view one of our post and have an improved method of obtaining the same or better results you will comment.
Thanks,
gooshie