2010-10-13 51 views
2

我有這樣的劇本我的工作:反洪水命令

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" 

但是,它不就utimer在所有啓動。用戶可以不斷地從某個頻道中踢人。我做錯了什麼?

我已閱讀這個:http://tclhelp.net/unb/39並基於它的第二個腳本。

感謝

回答

2

如果我們看一下你的代碼,我們看到utimer 1200 delay被放置到return通話後,因此實際上是無法訪問的代碼。哎呀!你需要通過提前移動定時器來解決這個問題(大概就在它上面的那一行之前)。因此...

# .... 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

有關腳本的其他內容看起來OK,順便說一句。有一些小的風格問題,但他們不是問題;無法訪問的代碼是... – 2010-10-13 12:41:10