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 

on join
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 10:50 am    Post subject: on join Reply with quote

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
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Sun May 13, 2007 11:19 am    Post subject: Reply with quote

why dont u just ban those masks in the egg?
.+ban *!*@*.aol.com etc
...
Back to top
View user's profile Send private message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 11:40 am    Post subject: Reply with quote

yeah i know +ban command but i wanted to learn tcl how to do this way.
thanks
Back to top
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Sun May 13, 2007 11:45 am    Post subject: Reply with quote

Heh ok. But seems weird to learn tcl writing a useless script anyway.
Back to top
View user's profile Send private message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 12:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 13, 2007 1:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 1:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 7:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 13, 2007 7:42 pm    Post subject: Reply with quote

Your code already does that.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun May 13, 2007 7:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 13, 2007 8:03 pm    Post subject: Reply with quote

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 Smile
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Mon May 14, 2007 12:00 am    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon May 14, 2007 4:53 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Mon May 14, 2007 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon May 14, 2007 9:14 pm    Post subject: Reply with quote

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

 
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