Code: Select all
namespace eval idlemode {
setudef flag idleMode
setudef str idleExempt
setudef int idleTime
bind cron {*/10 * * * *} [namespace current]::idleCron
proc idleCron {minute hour day month weekday} {
foreach chan [channels] {
if {![channel get $chan idleMode]} continue
cronCheck $chan
}
}
proc cronCheck {chan} {
variable idle
switch -- [catch {botisop $chan} err] {
"0" {
if {!$err} {
putlog "idleMode error: I'm not oped in $chan channel."
return
}
}
"1" {
putlog "idleMode error: $chan channel is not valid."
return
}
}
set users [lrange [chanlist $chan] 1 end]
set excempt [channel get $chan idleExempt]
set time [channel get $chan idleTime]
foreach user $users {
if {[lsearch -nocase $excempt $user] != -1} continue
if {[isop $user $chan]} {
lappend checkList $user:1
}
if {[isvoice $user $chan]} {
if {[info exists checkList]} {
set pos [lsearch -nocase $checkList $user:1]
if {$pos == -1} {
lappend checkList $user:2
} else {
set checkList [lreplace $checkList $pos $pos $user:3]
}
} else {
lappend checkList $user:2
}
}
}
foreach ele [split $checkList] {
scan $ele {%[^:]:%s} user count
checkIdle $count $user $chan $time
}
}
proc checkIdle {mode user chan time} {
set idle [getchanidle $user $chan]
if {$idle >= $time} {
switch -- $mode {
"1" {
pushmode $chan -o $user
putlog "idleMode: deoped $user in $chan cos was idle for $idle minutes"
}
"2" {
pushmode $chan -v $user
putlog "idleMode: devoiced $user in $chan cos was idle for $idle minutes"
}
"3" {
puthelp "MODE $chan -ov $user $user"
putlog "idleMode: deoped and devoiced $user in $chan cos was idle for $idle minutes"
}
}
}
}
}
putlog "idlemode.tcl loaded..."
Code: Select all
setudef list idleExempt
Code: Select all
set idle(exempt) [list "user_1" "user_2" "user_3"]
Code: Select all
set excempt [channel get $chan idleExempt]
Code: Select all
if {[lsearch -nocase $excempt $user] != -1} continue
Code: Select all
if {[lsearch -nocase $idle(excempt) $user] != -1} continue
Code: Select all
setudef int idleTime
Code: Select all
set idle(time) "60"
Code: Select all
set time [channel get $chan idleTime]
Code: Select all
if {$idle >= $time} {
Code: Select all
if {$idle >= $idle(time)} {
Code: Select all
[21:28:06] Tcl error in file 'eggdrop.conf':
[21:28:06] invalid type. Must be one of: flag, int, str
while executing
"setudef list idleExempt"
(in namespace eval "::idlemode" script line 3)
invoked from within
"namespace eval idlemode {
setudef flag idleMode
setudef list idleExempt
setudef int idleTime
bind cron {*/10 * * * *} [namespace current]:..."
(file "scripts/idlemode.tcl" line 1)
invoked from within
"source scripts/idlemode.tcl"
(file "eggdrop.conf" line 996)
[21:28:06] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
Code: Select all
setudef list idleExempt
Code: Select all
setudef str idleExempt
it deops voiced users not opers plus it deops normal users which don't have +/@.gasak wrote:What problem Amr? I did use one from BLaCkShaDoW and it works great.
Code: Select all
bind cron {*/10 * * * *} [namespace current]::idleCron
proc idleCron {minute hour day month weekday}
Code: Select all
bind time - {*/10 * * * *} [namespace current]::idleTime
proc idleTime {min hour day month year}
You forgot to change more than just "cron" to "time".caesar wrote:Code: Select all
bind time - {*/10 * * * *} [namespace current]::idleTime proc idleTime {min hour day month year}
Code: Select all
bind time - {?0*} [namespace current]::idleTime
proc idleTime {args} {
Code: Select all
[03:51:00] Tcl error [::idlemode::idleTime]: bad option "-nocase": must be -all, -ascii, -decreasing, -dictionary, -exact, -glob, -increasing, -inline, -integer, -not, -real, -regexp, -sorted, or -start