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.

What's wrong with this script?

Old posts that have not been replied to for several years.
Locked
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

What's wrong with this script?

Post by z_one »

Ok, this script checks out if the nicks who are joining a channel have ips that match the ones in a predefined list.

If more than 3 ppl have these ips and join ... the bot sets mode +MR

I made 6 clones having the ips 63.1.43.23 and 63.1.43.24 join my channel but I can't get it to work though ! What's wrong with it ?

Code: Select all

set wingateipslist "*!*@63.1.43.23 *!*@63.1.43.24"

foreach chan [channels] {
  set wingatejointimes($chan) 0
  set wingatejoindone($chan) 0
  set wingatejoinbmask($chan) ""
  set wingatejointimer($chan) 0
}

bind join - * wingatepowerjoin

proc wingatepowerjoin {nick uhost hand chan} {
  global wingatejointimes wingatejoindone wingatejoinbmask wingatejointimer

  if {![botisop $chan]} { return 0 }

  set wingatejoinbmask($chan) *!*[string tolower [string range $uhost [string first "@" $uhost] end]]

  
   if {[lsearch -exact $wingateipslist [string tolower $wingatejoinbmask($chan)]] != -1} {

     if {$wingatejointimes($chan) >= 3} {
        if {$wingatejoindone($chan) == 0} {
          putquick "MODE $chan +RM"
          set wingatejoindone($chan) 1
          utimer 10 { set wingatejoindone($chan) 0 }
        }
     } else {
        set wingatejointimes($chan) [expr $wingatejointimes($chan) + 1]
        foreach timr [utimers] {
           if {[lindex $timr 2] == $wingatejointimer($chan)} { 
              killutimer $wingatejointimer($chan) 
              break
           }
        }
        set wingatejointimer($chan) [utimer 2 {set wingatejointimes($chan) 0}]
     }
   }
}
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OK - first off

Code: Select all

set wingateipslist "*!*@63.1.43.23 *!*@63.1.43.24"
This is not a proper list, and as such, may cause problems.

somthing like

Code: Select all

set wingateipslist {}
lappend wingateipslist "*!*@63.1.43.23"
lappend wingateipslist "*!*@63.1.43.24"
Second, use some putlogs, for debugging purposes.

Places them after "if"'s, and other matching systems, so you can see what happens when.

IE, if you put a putlog after the if that checks for a matching IP, then you can see if it matched. If not, then the matching system needs revising.
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

Hi,

Ok I will degub it but about the matching system, I want it to be more global.
Example, say I have:

Code: Select all

set wingateipslist {} 
lappend wingateipslist "*!*@63.1.43.*"
Then I want any matching ip to trigger the code.
So if *!*@63.1.43.23 and *!*@63.1.43.165 and *!*@63.1.43.227 all join I need them to match the list element *!*@63.1.43.*

What "lsearch" option should I use to achieve this, and what's the exact code to do it.
Thanks in advance.

z_one
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

TO do this, it makes things a little simpler.

Remove this line

Code: Select all

set wingatejoinbmask($chan) *!*[string tolower [string range $uhost [string first "@" $uhost] end]]
This is appending to an array, which never gets used for any real purpose.

There is a slighly more overhead in managing arrays, so simply using a temp var would do. Besides that, you over ever use it localy, and is never globaly exported.

Now create a full nick!user@host variable, to match against.

Code: Select all

set temp "${nick}!${uhost}"

Next create a extra proc, to handle the matching.

[proc]
proc maskmatch {list string} {
foreach l $list {
if {[string match $l $string]} { return 1 }
}
return 0
}
[/code]
You can then change the matching if command (lsearch) to

Code: Select all

if {[maskmatch $wingateipslist $temp]} {
Locked