This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Auto announcement every 10 min after nick gets halfop

Help for those learning Tcl or writing their own scripts.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i also found if timer is running and nick is gone from channel it doesnt kill the running timer
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

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 ?
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

hi simo

remove:
catch { unset ::ish($nick) }

and look for this :
killutimer $::ish($nick)

change it to:
unset -nocomplain -- ::is($nick)
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

CrazyCat 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 ?
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 running
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I understand, but it was already managed.
If you want to kill the previous timer and start a new one (to reinit the 10 minutes delay), just unset ::ish($target) if it exists.

Note that in your code (proc auto:announcement), you have an error:

Code: Select all

if {[info exists ::ish($nick)]} { return }
It's not $nick but $target
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh true thanks for the correction this is what i have so far

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)
   }
}
it still seems to not remove timer if halfop nick has left channel
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

now i also get error:
Tcl error [stop:announcement]: invalid timerID
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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)
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ive loaded it and changed to utimer to test with not to have to wait minutes to see results

but when nick is de-halfopped or left channel the timer doesnt get removed tho
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

the repeat announcement doesnt seem to know what nicks to check for as it doesnt get feeded the nick after the first time nick is halfopped

perhaps if the nick is stored to be used by repeat annoucer it can do the checks
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

perhaps the halfopped nick can be stored seperate in a var as well to be used by repeat announcement proc
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for trying Spike^^ CrazyCat much apreciated
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Maybe it's just a case issue with the array element name?
one last try...

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)
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested it same result thanks for the efforts u put into it tho Spike^^ and CrazyCat
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

OK, I bet I know what is going on:)

Let us assume that the recently added, infinitely repeating timer Does Not function as one might Hope and Expect it to....

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)
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply