egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Kick users with idle, only if you use a command

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Fri Aug 07, 2009 7:52 am    Post subject: Kick users with idle, only if you use a command Reply with quote

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".
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Aug 07, 2009 2:10 pm    Post subject: Reply with quote

Untested but I think it's OK

Code:

# 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
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Aug 07, 2009 9:25 pm    Post subject: Reply with quote

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

Corrected below.

Code:

# 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
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Tue Aug 11, 2009 9:45 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Aug 11, 2009 10:45 am    Post subject: Reply with quote

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:

# 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
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Tue Aug 11, 2009 10:47 am    Post subject: Reply with quote

Will try that one, surely will work.

Thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber