egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

strip duplicate characters in nick and match against badnick
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Nov 10, 2020 2:39 am    Post subject: Reply with quote

You can, by using brackets to encapsulate your regexp:
Code:
set bnick {
    "somenick"
    "badnick"
    {b[ae]dw[o0]rd}
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Nov 10, 2020 10:04 am    Post subject: Reply with quote

tnx crazycat how would the check look like since it doesnt have the regexp in it ?
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Nov 10, 2020 11:12 am    Post subject: Reply with quote

Read how string match works
Quote:
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.

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Nov 10, 2020 2:12 pm    Post subject: Reply with quote

im not sure how to implement that in the code crazycat
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Nov 10, 2020 6:21 pm    Post subject: Reply with quote

It is already implemented...
Your code is:
Code:
 foreach i [string tolower $bnick] {
   if {[string match *$i* [string tolower $nick2]]

or peharps you use the caesar' optimization, but it uses string match
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Nov 11, 2020 1:46 am    Post subject: Reply with quote

Code:

% 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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Nov 11, 2020 8:14 am    Post subject: Reply with quote

it sets a weird ban tho:
Quote:
@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
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Nov 11, 2020 11:48 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Nov 11, 2020 11:56 am    Post subject: Reply with quote

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
Quote:
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
Quote:
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*!*@*
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Nov 12, 2020 2:31 am    Post subject: Reply with quote

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:
Quote:

//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:

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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Thu Nov 12, 2020 7:59 am    Post subject: Reply with quote

how would it look like in the code caesar?
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Nov 12, 2020 9:09 am    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Thu Nov 12, 2020 10:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Nov 12, 2020 1:21 pm    Post subject: Reply with quote

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. Laughing

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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Thu Nov 12, 2020 2:05 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber