开发者

Anti Flood for command

I have this script I'm working on:

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]} {
            p开发者_JAVA百科utserv "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"

However, it doesnt start on the utimer at all. Users can continually kick someone from a channel. What have I done wrong?

I've read through this: http://tclhelp.net/unb/39 and based it on the second script.

Thanks


If we look at your code, we see that the utimer 1200 delay is placed after a call to return and so is actually unreachable code. Oops! You need to fix this by moving the timer earlier (presumably just before the line above it). Thus…

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜