防洪命令

时间:2010-10-13 11:23:40

标签: tcl eggdrop

我正在处理这个脚本:

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并将其基于第二个脚本。

由于

1 个答案:

答案 0 :(得分: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 ....