| View previous topic :: View next topic |
| Author |
Message |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Tue Nov 10, 2020 2:39 am Post subject: |
|
|
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Tue Nov 10, 2020 10:04 am Post subject: |
|
|
| tnx crazycat how would the check look like since it doesnt have the regexp in it ? |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Tue Nov 10, 2020 11:12 am Post subject: |
|
|
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Tue Nov 10, 2020 2:12 pm Post subject: |
|
|
| im not sure how to implement that in the code crazycat |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Tue Nov 10, 2020 6:21 pm Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Nov 11, 2020 1:46 am Post subject: |
|
|
| 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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Nov 11, 2020 8:14 am Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Nov 11, 2020 11:48 am Post subject: |
|
|
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Nov 11, 2020 11:56 am Post subject: |
|
|
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
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Nov 12, 2020 2:31 am Post subject: |
|
|
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Nov 12, 2020 7:59 am Post subject: |
|
|
| how would it look like in the code caesar? |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Thu Nov 12, 2020 9:09 am Post subject: |
|
|
| 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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Nov 12, 2020 10:01 am Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Nov 12, 2020 1:21 pm Post subject: |
|
|
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.
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.
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Nov 12, 2020 2:05 pm Post subject: |
|
|
| 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 |
|
 |
|