2010-10-13 15 views
2

J'ai ce script, je travaille sur:Flood Anti pour la commande

bind pub ga !kick pub_do_kick 

proc pub_do_kick {nick uhost hand chan arg} { 

    # create a sub-proc to delay 
    proc delay {} { return } 

    # timer already running? 
    if {[utimerexists delay] == ""} { 

     # timer is not active, perform something 
     global botnick 
     set who [lindex $arg 0] 
     set why [lrange $arg 1 end] 
     if {![onchan $who $chan]} { 
      putserv "PRIVMSG $chan :$who isnt on $chan" 
      return 1 
     } 
     if {[string tolower $who] == [string tolower $botnick]} { 
      putserv "KICK $chan $nick :You fail" 
      return 1 
     } 
     if {$who == ""} { 
      putserv "PRIVMSG $chan :Usage: !k <nick to kick>" 
      return 1 
     } 
     if {$who == $nick} { 
      putserv "PRIVMSG $chan :You fail $nick?" 
      return 1 
     } 
     if {[matchattr $who +n]} { 
      putserv "KICK $chan $nick :You fail" 
      return 1 
     } 
     putserv "KICK $chan $who :$why" 
     return 1 

     # starting timer to prevent flooding next time 
     utimer 1200 delay 
    } else { 
     # timer is already active 
     putserv "KICK $chan $nick :You've already kicked someone" 
    } 
} 
putlog "Kick loaded" 

Cependant, il ne commence pas sur le utimer du tout. Les utilisateurs peuvent continuellement renvoyer quelqu'un d'une chaîne. Qu'est ce que j'ai mal fait? J'ai lu: http://tclhelp.net/unb/39 et basé sur le deuxième script.

Merci

Répondre

2

Si nous regardons votre code, nous voyons que le utimer 1200 delay est placé après un appel à return et ainsi est en fait le code inaccessible. Oops! Vous devez résoudre ce problème en déplaçant la minuterie plus tôt (vraisemblablement juste avant la ligne au-dessus). Ainsi ...

# .... blah blah as above .... 
putserv "KICK $chan $who :$why" ;# Do the kick 
utimer 1200 delay     ;# Start the timer 
return 1       ;# *NOW* we're done, not before 
# .... blah blah as above .... 
+0

Tout le reste sur le script semble OK, BTW. Il y a quelques problèmes mineurs de style mais ils ne sont pas le problème; le code inaccessible était ... –