This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

strip duplicate characters in nick and match against badnick

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

You can, by using brackets to encapsulate your regexp:

Code: Select all

set bnick {
    "somenick"
    "badnick"
    {b[ae]dw[o0]rd}
}
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx crazycat how would the check look like since it doesnt have the regexp in it ?
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Read how string match works
string match matches interprets a pattern expression and matches a string against that.
For the two strings to match, their contents must be identical except that the following special sequences may appear in pattern:
  • * Matches any sequence of characters in string, including a null string.
  • ? Matches any single character in string.
  • [chars] Matches any character in the set given by chars. If a sequence of the form x-y appears in chars, then any character between x and y, inclusive, will match. When used with -nocase, the end points of the range are converted to lower case first. Whereas {[A-z]} matches '_' when matching case-sensitively ('_' falls between the 'Z' and 'a'), with -nocase this is considered like {[A-Za-z]} (and probably what was meant in the first place).
  • \x Matches the single character x. This provides a way of avoiding the special interpretation of the characters *?[]\ in pattern.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

im not sure how to implement that in the code crazycat
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

It is already implemented...
Your code is:

Code: Select all

 foreach i [string tolower $bnick] {
   if {[string match *$i* [string tolower $nick2]]
or peharps you use the caesar' optimization, but it uses string match
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

% set bnick {
    "somenick"
    "badnick"
    {b[ae]dw[o0]rd}
}

    "somenick"
    "badnick"
    {b[ae]dw[o0]rd}

% set nick "bedw0rd"
bedw0rd
% foreach i $bnick { puts [string match -nocase *$i* $nick] }
0
0
1
seems to work as you wanted.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

it sets a weird ban tho:
@TCL-Tester Sets Mode on #opers to: +b *b[3e]dw[o0]rd*!*@*
while nick is badword or bedw0rd and so on making the ban invalid
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

That was expected since the badpart is what the nick was matched against. Change it and ban nick instead?
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx caesar i saw an msl code (mirc) using regex and it sets ban on the actual bad part it matches against i was hoping this could be done with tcl as well
if ($regex($nick,/(se(x|ks)|(s|f)uck|p(orn|enis)|h[0o]rny)/i)) { mode $chan +b $+ * $regml(1) $+ *!*@* }
as regex matches a range of word paterns making it easier to manage words instead of using a huge list of word paterns
17:14:20   Join :   ds3kss   Mibbit@RifSytes-h21.635.668.037.IP
17:14:20 +[simo] Sets Mode on #opers to: +b *s3ks*!*@*
17:16:01   Join :   dseksq   Mibbit@RifSytes-h21.635.668.037.IP
17:16:01 +[simo] Sets Mode on #opers to: +b *seks*!*@*
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I looked at your example and I don't understand how your match is working. From my limited understanding of regexp it should match se with something in the () but there's no se in the nick to begin with. I opened up a mIRC client and tested:
//echo match for ds3kss: $regex("ds3kss",/(se(x|ks)|(s|f)uck|p(orn|enis)|h[0o]rny)/i)
match for ds3kss: 0
In TCL this would be something like:

Code: Select all

set match [regexp -all {(se(x|ks)|(s|f)uck|p(orn|0rn|enis)|h[0o]rny)} $nick -> bad]
and if $match is 1 then in the $bad variable you got what it matched against.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

how would it look like in the code caesar?
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

simo wrote:how would it look like in the code caesar?
Did you try to implement the part of code ?

I won't speak for caesar or others, but when I help, my intention is to teach something to the asker, not to just do it for him.
You ask a lot of things but seem to not try to understand what is done or how it works.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

its not about not trying since i always try but when u have no clue where to add things or how to integrate something rather than to have random guess and try things that arent proper i asked for how it would look like so i can use as an example for other codes to give me an idea how it would look like in code

thanks.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you intend to drop the foreach loop and rely on the regexp line all you have to do is ... literally remove the foreach loop. :lol:

Oh, before i forget, rename bad to badpart in the regexp line so you won't need have to change it in the match & punish part of the code. :wink:

Edit: If you still use that regsub CrazyCat helped you out wih might be a good idea to adjust the variable in the regexp line so it matches properly.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks caesar could a combination of the two be used ? like to have the words in a variable to go throu the regexp to have freedom to add words in a more managable way
Post Reply