Code: Select all
# try to delete ::is($nick)
catch { unset ::ish($nick) }
# don't care if deleted or not, use it to kill the timer
killutimer $::ish($nick)
# probably an error, no ?
the reason i added is in an ettempt to make sure if if halfopped nick has left channel to have the timer lifted and also to make sure if timer is running and halfopped nick rejoining channel and gets halfop again +h nick not to have a duplicate timer start again while there already was one runningCrazyCat wrote:Why do you add your if {[set thetimer ....} { killtimer xxxxx } in all procs ?
Just keep the if {[info exists ::ish($nick)]} { return } in proc auto:announcement, it will be ok when pple come out and in and regain hop.
And concerning the person out of the chan when timer runs... why catch unset ? The timer is killed if $nick is not on chan OR $nick is not halfop. With your catch, you first unset the "memory" timer ID and then try to use this variable to kill the timer.
I resume your code:Code: Select all
# try to delete ::is($nick) catch { unset ::ish($nick) } # don't care if deleted or not, use it to kill the timer killutimer $::ish($nick) # probably an error, no ?
Code: Select all
if {[info exists ::ish($nick)]} { return }
Code: Select all
bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
if {[info exists ::ish($target)]} { return }
if {($target != $::botnick) && [string equal -nocase $chan "#test"]} {
putserv "PRIVMSG $chan :[colors] $target [end][colors] is on air tune into your radio [end]"
set ::ish($target) [utimer 10 [list repeat:announcement $chan $target] 0] }
}
proc repeat:announcement {chan nick} {
if {![info exists ::ish($nick)]} { return }
if {[onchan $nick $chan] && [ishalfop $nick $chan]} {
putserv "PRIVMSG $chan :[colors] $nick [end][colors] is on air tune into your radio [end]"
} else {
killutimer $::ish($nick)
}
}
bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
if {![info exists ::ish($target)]} { return }
if {($target != $::botnick) && [string equal -nocase $chan "#test"]} {
putserv "PRIVMSG $chan :[colors] $target [end][colors] show is done thank you [end][colors] $target [end][colors]for the nice show [end]"
killutimer $::ish($target)
}
}
Code: Select all
bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
if {[info exists ::ish($target)]} { return }
putserv "PRIVMSG $chan :$target is on air tune in to your radio"
set ::ish($target) [timer 10 [list repeat:announcement $chan $target] 0]
}
proc repeat:announcement {chan nick} {
if {[onchan $nick $chan] && [ishalfop $nick $chan]} {
putserv "PRIVMSG $chan :$nick is on air tune into your radio"
} else {
killtimer $::ish($nick)
unset ::ish($nick)
}
}
bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
if {![info exists ::ish($target)]} { return }
putserv "PRIVMSG $chan :$target show is done thank you $target for the nice show"
killtimer $::ish($target)
unset ::ish($target)
}
Code: Select all
bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
set tglow [string tolower $target]
if {[info exists ::ish($tglow)]} { return }
putserv "PRIVMSG $chan :$target is on air tune in to your radio"
set ::ish($tglow) [timer 10 [list repeat:announcement $chan $target] 0]
}
proc repeat:announcement {chan target} {
if {[onchan $target $chan] && [ishalfop $target $chan]} {
putserv "PRIVMSG $chan :$target is on air tune into your radio"
} else {
set tglow [string tolower $target]
killtimer $::ish($tglow)
unset ::ish($tglow)
}
}
bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
set tglow [string tolower $target]
if {![info exists ::ish($tglow)]} { return }
putserv "PRIVMSG $chan :$target show is done thank you $target for the nice show"
killtimer $::ish($tglow)
unset ::ish($tglow)
}
Code: Select all
bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
set tglow [string tolower $target]
if {[info exists ::ish($tglow)]} { return }
putserv "PRIVMSG $chan :$target is on air tune in to your radio"
#set ::ish($tglow) [timer 10 [list repeat:announcement $chan $target] 0]
set ::ish($tglow) [timer 10 [list repeat:announcement $chan $target]]
}
proc repeat:announcement {chan target} {
##
set tglow [string tolower $target]
if {[onchan $target $chan] && [ishalfop $target $chan]} {
putserv "PRIVMSG $chan :$target is on air tune into your radio"
##
set ::ish($tglow) [timer 10 [list repeat:announcement $chan $target]]
} else {
#killtimer $::ish($tglow)
unset ::ish($tglow)
}
}
bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
if {[isbotnick $target] || ![string equal -nocase $chan "#test"]} { return }
set tglow [string tolower $target]
if {![info exists ::ish($tglow)]} { return }
putserv "PRIVMSG $chan :$target show is done thank you $target for the nice show"
killtimer $::ish($tglow)
unset ::ish($tglow)
}