| View previous topic :: View next topic |
| Author |
Message |
unb0rn Voice
Joined: 08 Sep 2008 Posts: 26
|
Posted: Fri Aug 07, 2009 7:52 am Post subject: Kick users with idle, only if you use a command |
|
|
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 |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri Aug 07, 2009 2:10 pm Post subject: |
|
|
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 |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri Aug 07, 2009 9:25 pm Post subject: |
|
|
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 |
|
 |
unb0rn Voice
Joined: 08 Sep 2008 Posts: 26
|
Posted: Tue Aug 11, 2009 9:45 am Post subject: |
|
|
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 |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Tue Aug 11, 2009 10:45 am Post subject: |
|
|
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 |
|
 |
unb0rn Voice
Joined: 08 Sep 2008 Posts: 26
|
Posted: Tue Aug 11, 2009 10:47 am Post subject: |
|
|
Will try that one, surely will work.
Thank you |
|
| Back to top |
|
 |
|