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.
Help for those learning Tcl or writing their own scripts.
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 10:50 am
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
nsrafk
Halfop
Posts: 73 Joined: Fri May 11, 2007 12:25 am
Post
by nsrafk » Sun May 13, 2007 11:19 am
why dont u just ban those masks in the egg?
.+ban *!*@*.aol.com etc
...
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 11:40 am
yeah i know +ban command but i wanted to learn tcl how to do this way.
thanks
nsrafk
Halfop
Posts: 73 Joined: Fri May 11, 2007 12:25 am
Post
by nsrafk » Sun May 13, 2007 11:45 am
Heh ok. But seems weird to learn tcl writing a useless script anyway.
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 12:14 pm
is this correct? please help thanks
Code: Select all
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
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun May 13, 2007 1:25 pm
First you need to bind to join
(Read Tcl-commands.doc about the join bind)
Second, you should split the host from $uhost to do the match over.
Code: Select all
set host [lindex [split $uhost @] 1]
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 1:55 pm
ok thank you Sir_Fz. now it should do it
Code: Select all
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..}
}
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 7:40 pm
Hi Sir_fz,
Code: Select all
set host [lindex [split $uhost @] 1]
will extract ip like 24.34.45.56
now in my set list i have the following
Code: Select all
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.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun May 13, 2007 7:42 pm
Your code already does that.
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Sun May 13, 2007 7:56 pm
ok i had the following but it seems it didn't work
Code: Select all
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
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun May 13, 2007 8:03 pm
Code: Select all
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" }
}
}
% 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
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Mon May 14, 2007 12:00 am
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: Select all
[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
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon May 14, 2007 4:53 am
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.
ap
Halfop
Posts: 44 Joined: Fri Jun 09, 2006 12:20 am
Post
by ap » Mon May 14, 2007 9:03 pm
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: Select all
set lamer {
*aol.com*
24.*
81.*
217.*
68.*
211.*
}
thanks
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon May 14, 2007 9:14 pm
Then you should do something like this:
Code: Select all
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..
}