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.

Kick users with idle, only if you use a command

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
u
unb0rn
Voice
Posts: 26
Joined: Mon Sep 08, 2008 8:14 am

Kick users with idle, only if you use a command

Post by unb0rn »

Well, ill try to keep it simple, i already search the site for it, but can't find one like what i want.
I want a tcl that ONLY if a use a command like !idle , it detect's if someone have an idle bigger that, let's say, 1 hour, and kick's them from the channel, and if possible, not kicking users with Global Flag like "o".
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Untested but I think it's OK

Code: Select all

# set here the user flag(s) required to use the command
set vIdleFlag m

# set here the command trigger
set vIdleTrigger !

# set here the user flag required in order to be exempt from a kick/ban
set vIdleExempt o

# set here the mode of operation
# 1 = kick only
# 2 = ban and kick
set vIdleMode 1

# set here the maximum allowed idle time (minutes)
set vIdleTime 60

proc pIdleTrigger {} {
    global vIdleTrigger
    return $vIdleTrigger
}

bind PUB $vIdleFlag [pIdleTrigger]idle pIdleCheck

proc pIdleCheck {nick uhost hand chan text} {
    global vIdleExempt vIdleMode vIdleTime
    if {[botisop $chan]} {
        foreach user [chanlist $chan] {
            if {![matchattr [nick2hand $user] $vIdleExempt $chan]} {
                if {[getchanidle $user $chan] > $vIdleTime} {
                    switch -- $vIdleMode {
                        1 {putkick $chan $user "idle time exceeded"}
                        2 {
                            pushmode $chan +b *!$uhost
                            flushmode $chan
                            utimer 3 [list pIdleKick $chan $user]
                        }
                        default {}
                    }
                }
            }
        }
    }
    return 0
}

proc pIdleKick {chan user} {
    if {[onchan $user $chan]} {
        putkick $chan $user "idle time exceeded"
    }
    return 0
}

# eof
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Sorry I made a blunder. I used the uhost of the public command user instead of the host of the idler.

Corrected below.

Code: Select all

# set here the user flag(s) required to use the command
set vIdleFlag m

# set here the command trigger
set vIdleTrigger !

# set here the user flag required in order to be exempt from a kick/ban
set vIdleExempt o

# set here the mode of operation
# 1 = kick only
# 2 = ban and kick
set vIdleMode 1

# set here the maximum allowed idle time (minutes)
set vIdleTime 60

proc pIdleTrigger {} {
    global vIdleTrigger
    return $vIdleTrigger
}

bind PUB $vIdleFlag [pIdleTrigger]idle pIdleCheck

proc pIdleCheck {nick uhost hand chan text} {
    global vIdleExempt vIdleMode vIdleTime
    if {[botisop $chan]} {
        foreach user [chanlist $chan] {
            if {![matchattr [nick2hand $user] $vIdleExempt $chan]} {
                if {[getchanidle $user $chan] > $vIdleTime} {
                    switch -- $vIdleMode {
                        1 {putkick $chan $user "idle time exceeded"}
                        2 {
                            set host [maskhost [getchanhost $user $chan]]
                            pushmode $chan +b $host
                            flushmode $chan
                            utimer 3 [list pIdleKick $chan $user]
                        }
                        default {}
                    }
                }
            }
        }
    }
    return 0
}

proc pIdleKick {chan user} {
    if {[onchan $user $chan]} {
        putkick $chan $user "idle time exceeded"
    }
    return 0
}

# eof
I must have had nothing to do
u
unb0rn
Voice
Posts: 26
Joined: Mon Sep 08, 2008 8:14 am

Post by unb0rn »

Amazing, thank you very much.
Oh, and by the way, why does the bot always kick's himself, and only then starts to kick the others users?
Last edited by unb0rn on Tue Aug 11, 2009 10:10 am, edited 1 time in total.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Heh! Yes, that was pretty stupid. It is because the bot has been idle too. The following modification should ignore the botnick.

Note to self. Must not code bugs.

Code: Select all

# set here the user flag(s) required to use the command
set vIdleFlag m

# set here the command trigger
set vIdleTrigger !

# set here the user flag required in order to be exempt from a kick/ban
set vIdleExempt o

# set here the mode of operation
# 1 = kick only
# 2 = ban and kick
set vIdleMode 1

# set here the maximum allowed idle time (minutes)
set vIdleTime 60

proc pIdleTrigger {} {
    global vIdleTrigger
    return $vIdleTrigger
}

bind PUB $vIdleFlag [pIdleTrigger]idle pIdleCheck

proc pIdleCheck {nick uhost hand chan text} {
    global vIdleExempt vIdleMode vIdleTime
    if {[botisop $chan]} {
        foreach user [chanlist $chan] {
            if {![isbotnick $user]} {
                if {![matchattr [nick2hand $user] $vIdleExempt $chan]} {
                    if {[getchanidle $user $chan] > $vIdleTime} {
                        switch -- $vIdleMode {
                            1 {putkick $chan $user "idle time exceeded"}
                            2 {
                                set host [maskhost [getchanhost $user $chan]]
                                pushmode $chan +b $host
                                flushmode $chan
                                utimer 3 [list pIdleKick $chan $user]
                            }
                            default {}
                        }
                    }
                }
            }
        }
    }
    return 0
}

proc pIdleKick {chan user} {
    if {[onchan $user $chan]} {
        putkick $chan $user "idle time exceeded"
    }
    return 0
}

# eof
I must have had nothing to do
u
unb0rn
Voice
Posts: 26
Joined: Mon Sep 08, 2008 8:14 am

Post by unb0rn »

Will try that one, surely will work.

Thank you
Post Reply