| View previous topic :: View next topic |
| Author |
Message |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 10:50 am Post subject: on join |
|
|
Hi,
I wanted to check the list of ips/host on join, with my list to see if they match and if match then i want to ban them them
set my-lists {24.34.45.*
*.aol.com
82.167.*
222.*}
thanks |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Sun May 13, 2007 11:19 am Post subject: |
|
|
why dont u just ban those masks in the egg?
.+ban *!*@*.aol.com etc
... |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 11:40 am Post subject: |
|
|
yeah i know +ban command but i wanted to learn tcl how to do this way.
thanks |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Sun May 13, 2007 11:45 am Post subject: |
|
|
| Heh ok. But seems weird to learn tcl writing a useless script anyway. |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 12:14 pm Post subject: |
|
|
is this correct? please help thanks
| Code: | set ips {24.*
*.aol.com
82.167.*
222.*}
proc check {nick uhost hand chan} {
global ips
foreach pattern $ips {
if {[string match $pattern $uhost ]} { ..do here..}
}
|
how do i check if ip starts with 24.* so when user ip 24.34.56.67 should match but not 34.45.24.56 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 13, 2007 1:25 pm Post subject: |
|
|
First you need to bind to join
| Code: | | bind join - * check |
(Read Tcl-commands.doc about the join bind)
Second, you should split the host from $uhost to do the match over.
| Code: | | set host [lindex [split $uhost @] 1] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 1:55 pm Post subject: |
|
|
ok thank you Sir_Fz. now it should do it
| Code: | set ips {24.*
*.aol.com
82.167.*
222.*
}
bind join - * check
proc check {nick uhost hand chan} {
global ips
set host [lindex [split $uhost @] 1]
foreach pattern $ips {
if {[string match $pattern $host ]} { ..do here..}
} |
|
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 7:40 pm Post subject: |
|
|
Hi Sir_fz,
| Code: | | set host [lindex [split $uhost @] 1] | will extract ip like 24.34.45.56
now in my set list i have the following
| Code: | set ips {24.*
*.aol.com
82.167.*
222.*
} |
when user joins the channel and has ip 24.34.45.56 or 24.56.78.89 if starts before first dot (.) is 24 then it should match my set list ecause my list has 24.* and same way i have 222.* in my list so it should math if person ip starts 222.34.56.78 or 222.67.89.56 etc if it starts with 222.
how to accomplish this? i would appreciate your help
Last edited by ap on Sun May 13, 2007 7:43 pm; edited 1 time in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun May 13, 2007 7:56 pm Post subject: |
|
|
ok i had the following but it seems it didn't work
| Code: | set ips {24.*
222.*
}
bind join - * check
proc check {nick uhost hand chan} {
global ips
set host [lindex [split $uhost @] 1]
foreach pattern $ips {
if {[string match $pattern $host]} {
putlog "matched"
} else { putlog "no macth" }
} |
and person joined nick!ident@24.91.187.99 and it didn't match, i don't know why. I thought 24.* is in my list so this should of matched.
but this shouldn't matched nick!ident@72.20.49.24 because 24 is at the end, i want it to match only if it starts with 24.8 or 222.*
thanks |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 13, 2007 8:03 pm Post subject: |
|
|
| Code: | set ips {
24.*
222.*
}
proc check {nick uhost hand chan} {
global ips
set host [lindex [split $uhost @] 1]
foreach pattern $ips {
if {[string match $pattern $host]} {
puts "$pattern matched $host"
} { puts "$pattern DOES NOT match $host" }
}
} |
| Quote: | % check nick ident@24.91.187.99 * #chan
24.* matched 24.91.187.99
222.* DOES NOT match 24.91.187.99
% |
Apparently it does work  _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Mon May 14, 2007 12:00 am Post subject: |
|
|
Thanks again Sir_fz.
Now i'm trying to use these codes in MC_8's dns bans scripts because i like to check only lamers ip/hosts for dns so i'm just pasting his onjoin procedure which i have modified it and it doesn't work. Bold ones are my changes.
| Code: | [b]set lamer {
*aol.com*
24.*
81.*
217.*
68.*
}[/b]
bind join - * mc:dnsb:join
proc mc:dnsb:join {nick uhost handle channel} {
return [mc:dnsb:errchk mc:dnsb:join_ $nick $uhost $handle $channel]
}
proc mc:dnsb:join_ {nick uhost handle channel} {
global coke
if {![channel get $channel mc.dns_bans] ||
[isbotnick $nick] ||
[matchban $nick!$uhost $channel] ||
[mc:dnsb:matchchanban $nick!$uhost $channel]} {return 0}
[b]set host [lindex [split $uhost @] 1]
foreach pattern $lamer {
if {![string match $pattern $host]} { return }
} [/b]
set cache(exempt:flags) [channel get $channel mc.dns_bans.exempt.flags]
if {($cache(exempt:flags) != "") &&
[matchattr $handle $cache(exempt:flags) $channel]} {return 0}
regexp -- (.*)@(.*) $uhost dummy ident host
if {$::numversion >= "1061600"} {
dnslookup $host mc:dnsb:dnsreturn $host $nick $ident $handle $channel
} else {
dnslookup [list $host] mc:dnsb:dnsreturn [list $host $nick $ident $handle $channel]
}
} |
thanks again |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon May 14, 2007 4:53 am Post subject: |
|
|
What exactly is your change supposed to do? The condition always succeeds since not all the elements in the list are going to match the joining host. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Mon May 14, 2007 9:03 pm Post subject: |
|
|
Well i want to check for dns only if person is in the list, if person is not in the list then i want to ignore it.
| Code: | set lamer {
*aol.com*
24.*
81.*
217.*
68.*
211.*
} |
thanks |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon May 14, 2007 9:14 pm Post subject: |
|
|
Then you should do something like this:
| Code: | set found 0
set host [lindex [split $uhost @] 1]
foreach pattern $lamer {
if {[string match $pattern $host]} {
set found 1
break
}
}
if {$found} {
# Do your stuff here..
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|