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.

Whats wrong in this code :/

Help for those learning Tcl or writing their own scripts.
Post Reply
S
Salik83
Voice
Posts: 6
Joined: Sun Apr 19, 2009 5:12 pm
Location: Pk

Whats wrong in this code :/

Post by Salik83 »

Code: Select all

if {$numversion < 1060200} {
   bind join v|v * join:sv
   proc join:sv {nick host hand chan} { global sv
      utimer [expr [lindex [split $sv(delay) :] 0] + [rand [lindex [split $sv(delay) :] 1]]] [list sv:voice $nick $host $hand
   }
   proc sv:voice {nick host hand chan} {
      if {[botisop $chan]} { global sv
         switch -- "$sv(method)" {
            "1" {
               if {((![isbotnick $nick]) && (![isbotnick [hand2nick $hand $chan]]))} {
                  if {(([onchan $nick $chan]) && ("[getchanhost $nick $chan]" == "$host") && (![isvoice $nick $chan]) && (($sv
                     # They still have the nick they joined with.
                     puthelp "MODE $chan +v $nick"
                  } elseif {((![onchan $nick $chan]) && ([handonchan $hand $chan]) && (![isvoice [hand2nick $hand $chan] $chan
                     # They most likely changed nicks after joining.
                     puthelp "MODE $chan +v [hand2nick $hand $chan]"
                  }
               }
            }
            "2" {
               foreach u "[chanlist $chan]" {
                  if {[string match {*@119.*} [getchanhost $u $chan]]} { return }
                  if {[string match {*@116.*} [getchanhost $u $chan]]} { return }
                  if {((![isvoice $u $chan]) && ([matchattr [nick2hand $u $chan] v|v $chan]) && (![isbotnick $u]) && (($sv(voi
                     pushmode $chan +v $u
                  }
               }
            }
         }
      }
   }

   if {"[info commands isbotnick]" == ""} {
      proc isbotnick {nick} { global botnick
         if {"[string tolower $nick]" == "[string tolower $botnick]"} { set nick 1 } { set nick 0 }
      }
   }
}
i want this script to exempt users from *!*@119.* and *!*@116.* , not to voice them :/

Edit:
Placed the code within proper tags to ease reading.
/NML_375
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It would seem part of the code was cut from the post on the right side.

From what I can see, the code is not coherent, as when $sv(method) is set to 1, the check for 116/119 IP's is not done. Try adding the "string match" checks to the first case, in the beginning.
NML_375
S
Salik83
Voice
Posts: 6
Joined: Sun Apr 19, 2009 5:12 pm
Location: Pk

Post by Salik83 »

Code: Select all

set sv(delay) 60:180

set sv(voiceops) 0

set sv(method) 2


if {$numversion < 1060200} {
   bind join v|v * join:sv
   proc join:sv {nick host hand chan} { global sv
      utimer [expr [lindex [split $sv(delay) :] 0] + [rand [lindex [split $sv(delay) :] 1]]] [list sv:voice $nick $host $hand $chan]
   }
   proc sv:voice {nick host hand chan} {
      if {[botisop $chan]} { global sv
         switch -- "$sv(method)" {
            "1" {
               if {((![isbotnick $nick]) && (![isbotnick [hand2nick $hand $chan]]))} {
                  if {(([onchan $nick $chan]) && ("[getchanhost $nick $chan]" == "$host") && (![isvoice $nick $chan]) && (($sv(voiceops)) || (![isop $nick $chan])))} {
                     # They still have the nick they joined with.
                     puthelp "MODE $chan +v $nick"
                  } elseif {((![onchan $nick $chan]) && ([handonchan $hand $chan]) && (![isvoice [hand2nick $hand $chan] $chan]) && (($sv(voiceops)) || (![isop [hand2nick $hand $chan] $chan])))} {
                     # They most likely changed nicks after joining.
                     puthelp "MODE $chan +v [hand2nick $hand $chan]"
                  }
               }
            }
            "2" {
               foreach u "[chanlist $chan]" {
                  if {((![isvoice $u $chan]) && ([matchattr [nick2hand $u $chan] v|v $chan]) && (![isbotnick $u]) && (($sv(voiceops)) || (![isop $u $chan])))} {
                     pushmode $chan +v $u
                  }
               }
            }
         }
      }
   }

   if {"[info commands isbotnick]" == ""} {
      proc isbotnick {nick} { global botnick
         if {"[string tolower $nick]" == "[string tolower $botnick]"} { set nick 1 } { set nick 0 }
      }
   }

   foreach c "[channels]" { channel set "$c" -autovoice }
   catch { unset $c }
} else {
   putlog "slowvoice.tcl: Your Eggdrop version already supports delayed auto-voiceing."
}

putlog "slowvoice.tcl v1.4 by FireEgl@EFNet <FireEgl@LinuxFan.com> - Loaded."
here is a complete code.. all i want to add *!*@119.* and *!*@116.* ips to ignore by this script. so people matching those ips wont get +v :/.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Quite like your code, but it should do the trick:
Or do you need DNS resolving as well?

Btw, mind if I ask why you are using such an old eggdrop?

Code: Select all

set sv(delay) 60:180

set sv(voiceops) 0

set sv(method) 2


if {$numversion < 1060200} {
   bind join v|v * join:sv
   proc join:sv {nick host hand chan} { global sv
      utimer [expr [lindex [split $sv(delay) :] 0] + [rand [lindex [split $sv(delay) :] 1]]] [list sv:voice $nick $host $hand $chan]
   }
   proc sv:voice {nick host hand chan} {
      if {[botisop $chan]} { global sv
         switch -- "$sv(method)" {
            "1" {
               if {[string match "*@116.*" $host] || [string match "*@119.*" $host]} {return}
               if {((![isbotnick $nick]) && (![isbotnick [hand2nick $hand $chan]]))} {
                  if {(([onchan $nick $chan]) && ("[getchanhost $nick $chan]" == "$host") && (![isvoice $nick $chan]) && (($sv(voiceops)) || (![isop $nick $chan])))} {
                     # They still have the nick they joined with.
                     puthelp "MODE $chan +v $nick"
                  } elseif {((![onchan $nick $chan]) && ([handonchan $hand $chan]) && (![isvoice [hand2nick $hand $chan] $chan]) && (($sv(voiceops)) || (![isop [hand2nick $hand $chan] $chan])))} {
                     # They most likely changed nicks after joining.
                     puthelp "MODE $chan +v [hand2nick $hand $chan]"
                  }
               }
            }
            "2" {
               foreach u "[chanlist $chan]" {
                  set uhost [getchanhost $u]
                  if {[string match "*@116.*" $uhost] || [string match "*@119.*" $uhost]} {continue}

                  if {((![isvoice $u $chan]) && ([matchattr [nick2hand $u $chan] v|v $chan]) && (![isbotnick $u]) && (($sv(voiceops)) || (![isop $u $chan])))} {
                     pushmode $chan +v $u
                  }
               }
            }
         }
      }
   }

   if {"[info commands isbotnick]" == ""} {
      proc isbotnick {nick} { global botnick
         if {"[string tolower $nick]" == "[string tolower $botnick]"} { set nick 1 } { set nick 0 }
      }
   }

   foreach c "[channels]" { channel set "$c" -autovoice }
   catch { unset $c }
} else {
   putlog "slowvoice.tcl: Your Eggdrop version already supports delayed auto-voiceing."
}

putlog "slowvoice.tcl v1.4 by FireEgl@EFNet <FireEgl@LinuxFan.com> - Loaded." 
Edit:
Fixed issue with "string match". Thanks for pointing it out, arfer.
Last edited by nml375 on Thu Apr 23, 2009 10:04 am, edited 1 time in total.
NML_375
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

In a string match the pattern comes first and the string to match it against second. I think you have it the wrong way about.

I do the same thing quite a lot because lsearch for lists is the opposite way. List first and pattern second.

Confusing!
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Darn!
Thanks for pointing it out. I'll update my post in a sec.
NML_375
S
Salik83
Voice
Posts: 6
Joined: Sun Apr 19, 2009 5:12 pm
Location: Pk

Post by Salik83 »

cant use new version, i know it comes with slowvoice feature, have to get some auto voice script so i can add some exemptions, i cant ignore *!*@119.* from bot because most of master are using same ip. thanks nml.. code worked. (F)!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Nice you got it working.

I hope you are aware that there's been numerous bugfixes since 1.6.2, several of them critical.
NML_375
S
Salik83
Voice
Posts: 6
Joined: Sun Apr 19, 2009 5:12 pm
Location: Pk

Post by Salik83 »

yeah, i updated all bug fixers.. thanks :) well +g is for autovoice too i guess, so we need to .adduser for this?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Yup, it'll only voice members having the v userflag.
NML_375
Post Reply