this script i made is getting on my nerves, i can't figure out what's wrong,
if anyone can take an outside look maybe you'll catch a bug that am missing.
the purpose of the script is to deop/devoice inactive users on a chan (not idle, cause they can be active in other chans, so they wouldn't be idle)
here's the code:
Code: Select all
bind pubm - * update_timers
bind mode - "*+*o*" nick_got_oped
bind mode - "*+*v*" nick_got_voiced
bind mode - "*-*o*" nick_got_Doped
bind mode - "*-*v*" nick_got_Dvoiced
set list_of_chans "#aub"
set check_interval 2
set op_allowed_time 180
set vo_allowed_time 60
global time_op time_vo
proc update_timers {nick uhost hand chan text } {
# global time_op time_vo
if {[isop $nick $chan]} {
set time_op($chan,$nick) [unixtime]
putlog "timer updated for $nick (+o for another 40 min) - timer is now $time_op($chan,$nick)"
}
if {[isvoice $nick $chan]} {
set time_vo($chan,$nick) [unixtime]
putlog "timer updated for $nick (+v for another 6 min)"
}
}
proc nick_got_oped {nick uhost hand chan mode target} {
# global time_op
set time_op($chan,$target) [unixtime]
putlog "$target just got oped , starting timer: $time_op($chan,$target)"
}
proc nick_got_voiced {nick uhost hand chan mode target} {
# global time_vo
set time_vo($chan,$target) [unixtime]
putlog "$target just got voiced , starting timer: $time_vo($chan,$target)"
}
proc nick_got_Doped {nick uhost hand chan mode target} {
# global time_op
if {[info exists time_op($chan,$target)]} { unset time_op($chan,$target) }
putlog "removed timer for $target (-o)"
}
proc nick_got_Dvoiced {nick uhost hand chan mode target} {
# global time_vo
if {[info exists time_vo($chan,$target)]} { unset time_vo($chan,$target) }
putlog "removed timer for $target (-v)"
}
proc run_checking_timer { } {
global list_of_chans check_interval
# time_vo time_op
foreach check_chan [split $list_of_chans] {
putlog "Checking for inactive: \002$check_chan\002"
inactive_checker $check_chan
}
timer $check_interval run_checking_timer
}
proc inactive_checker { chan } {
global check_interval op_allowed_time vo_allowed_time botnick
# time_vo time_op
foreach usernick [chanlist $chan] {
if {[isop $usernick $chan] && $usernick != $botnick } {
if {![info exists time_op($chan,$usernick)]} {
set time_op($chan,$usernick) [unixtime]
putlog "info for OP $usernick doesn't exist , setting time to $time_op($chan,$usernick)"
}
set inactivity_time [expr [unixtime] - $time_op($chan,$usernick)]
putlog "$usernick: $inactivity_time = [unixtime] - $time_op($chan,$usernick)"
if { $inactivity_time > $op_allowed_time } {
putlog "Inactive OP: $usernick - time: [expr $inactivity_time / 60] mins."
pushmode $chan -o $usernick
unset time_op($chan,$usernick)
}
}
if {[isvoice $usernick $chan] && $usernick != $botnick } {
if {![info exists time_vo($chan,$usernick)]} {set time_vo($chan,$usernick) [unixtime] }
set inactivity_time [expr [unixtime] - $time_vo($chan,$usernick)]
if { $inactivity_time > $vo_allowed_time } {
putlog "Inactive VO: $usernick - time: [expr $inactivity_time / 60] mins."
pushmode $chan -v $usernick
unset time_vo($chan,$usernick)
}
}
}
}
timer $check_interval run_checking_timer
putlog "\[LOADED\] Inactive op/voice control - by SaPrOuZy."
thanks for your help...[23:49] <)Profanity> [16:49] Checking for inactive: #aub
[23:49] <)Profanity> [16:49] info for OP Dilemma doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] Dilemma: 0 = 1124311740 - 1124311740
[23:49] <)Profanity> [16:49] info for OP SaPrOuZy doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] SaPrOuZy: 0 = 1124311740 - 1124311740
[23:49] <)Profanity> [16:49] info for OP Algorithm doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] Algorithm: 0 = 1124311740 - 1124311740
[23:51] <)Profanity> [16:51] Checking for inactive: #aub
[23:51] <)Profanity> [16:51] Dilemma: 120 = 1124311860 - 1124311740
[23:51] <)Profanity> [16:51] SaPrOuZy: 120 = 1124311860 - 1124311740
[23:51] <)Profanity> [16:51] Algorithm: 120 = 1124311860 - 1124311740
[23:53] <)Profanity> [16:53] Checking for inactive: #aub
[23:53] <)Profanity> [16:53] Dilemma: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: Dilemma - time: 4 mins.
[23:53] <)Profanity> [16:53] SaPrOuZy: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: SaPrOuZy - time: 4 mins.
[23:53] <)Profanity> [16:53] Algorithm: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: Algorithm - time: 4 mins.
[23:53] <)Profanity> [16:53] removed timer for Dilemma (-o)
[23:53] <)Profanity> [16:53] removed timer for SaPrOuZy (-o)
[23:53] <)Profanity> [16:53] removed timer for Algorithm (-o)
[23:53] <)Profanity> [16:53] SaPrOuZy just got oped , starting timer: 1124311982 <---------- it was just set here
[23:55] <)Profanity> [16:55] Checking for inactive: #aub
[23:55] <)Profanity> [16:55] info for OP SaPrOuZy doesn't exist , setting time to 1124312100 <----------- here it can't read it
[23:55] <)Profanity> [16:55] SaPrOuZy: 0 = 1124312100 - 1124312100