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: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Auto announcement every 10 min after nick gets halfop

Post by simo »

anyway to have this code announce a message after a nick gets halfopped +h
nick on channel and have every 10 min check if that nick is still halfop and if so to announce again and if nick gets dropped as halfop -h nick to stop the every 10 minute check

not sure if a bind cron is best or bind time or a timer for this and after nick is dehalfopped -h nick to unbind the bind cron / bind time or kill specific timer

Code: Select all


bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
 if {($target != $::botnick) && [string equal -nocase $chan "#channel"]} {
   putserv "privmsg $chan :$target is on air tune in to your radio"
 }
}


bind mode - "#% *-*h*" StopAuto:announcement
proc StopAuto:announcement {nick uhost handle chan mode target} {
 if {($target != $::botnick) && [string equal -nocase $chan "#channel"]} {
   putserv "privmsg $chan :$target show is done thank you $target for the nice show"
 }
}
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Not tested, but may work

Code: Select all

bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
   if {($target != $::botnick) && [string equal -nocase $chan "#channel"]} {
      putserv "PRIVMSG $chan :$target is on air tune in to your radio"
      set ::ish($target) [list timer 10 [repeat:announcement $chan $target] 0]
   }
}

proc repeat:annoucement {chan nick} {
   if {![info exists ::ish($nick)]} { return }
   if {[onchan $nick $chan] && [ishalfop $nick $chan]} {
      putserv "PRIVMSG $chan :$nick is alway on air tune into your radio"
   } else {
      killtimer $::ish($nick)
   }
}

bind mode - "#% *+*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
   if {![info exists ::ish($nick)]} { return }
   if {($target != $::botnick) && [string equal -nocase $chan "#channel"]} {
      putserv "PRIVMSG $chan :$target show is done thank you $target for the nice show"
      killtimer $::ish($nick)
   }
}
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thank you CrazyCat for the swift response i tested it and i get this error:
Tcl error [auto:announcement]: invalid command name "repeat:announcement"
also i changed the :

bind mode - "#% *+*h*" stop:announcement

to

bind mode - "#% *-*h*" stop:announcement
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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 {($target != $::botnick) && [string equal -nocase $chan "#test"]} {
      putserv "PRIVMSG $chan :$target is on air tune in to your radio"
      set ::ish($target) [list timer 1 [repeat:announcement $chan $target] 0]
   }
}

proc repeat:annoucement {chan nick} {
   if {![info exists ::ish($nick)]} { return }
   if {[onchan $nick $chan] && [ishalfop $nick $chan]} {
      putserv "PRIVMSG $chan :$nick is alway on air tune into your radio"
   } else {
      killtimer $::ish($nick)
   }
}

bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
   if {![info exists ::ish($nick)]} { return }
   if {($target != $::botnick) && [string equal -nocase $chan "#test"]} {
      putserv "PRIVMSG $chan :$target show is done thank you $target for the nice show"
      killtimer $::ish($nick)
   }
}

s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i changed the :

set ::ish($target) [list timer 1 [repeat:announcement $chan $target] 0]

into

set ::ish($target) [list timer 1 [list repeat:announcement $chan $target] 0]

but it didnt seem to work as well
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Well, there is 2 errors in my proc stop:announcement, I use "$nick" when I've to use "$target"

Code: Select all

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 :$target show is done thank you $target for the nice show"
      killtimer $::ish($target)
   }
}
Now, "it didnt seem to work as well" is not enough to help you. What is working, what is not working, show the logs and errors, add debug log, ...
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh yea sorry what i meant was the timer doesnt get set

errors :



Tcl error [stop:announcement]: argument is not a 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

set ::ish($target) [timer 1 [list repeat:announcement $chan $target] 0]
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: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for the reply Spike^^ i tried that and got error
Tcl error in script for 'timer364':
invalid command name "repeat:announcement"


Code: Select all

bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
   if {($target != $::botnick) && [string equal -nocase $chan "#test"]} {
      putserv "PRIVMSG $chan :$target is on air tune in to your radio"
      set ::ish($target) [utimer 10 [list repeat:announcement $chan $target] 0]   }
}

proc repeat:annoucement {chan nick} {
   if {![info exists ::ish($nick)]} { return }
   if {[onchan $nick $chan] && [ishalfop $nick $chan]} {
      putserv "PRIVMSG $chan :$nick is on air tune into your radio"
   } else {
      killtimer $::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 :$target show is done thank you $target for the nice show"
      killtimer $::ish($target)
   }
}
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

changed timer to this to test with not to have to wait minutes:

set ::ish($target) [utimer 10 [list repeat:announcement $chan $target] 0] }
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

fix the spelling @ proc repeat:annoucement
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: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks spike^^ that seems to do it
thanks CrazyCat
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

SpiKe^^ wrote:

Code: Select all

set ::ish($target) [timer 1 [list repeat:announcement $chan $target] 0]
Woops, did I add an extra list ? Yes, I did it again :)

Thanks SpiKe^^ :)
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

after using the code i found if the halfopped nick leaves channel for whatever reason and joins channel back and gets halfopped again +h nick
it basically sets 2 timers doing the same thing it doests check for timer already existing to prevent duplicate timers set
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

from a similar code Spike^^ wrote i tried this wich seems to work altho not sure if proper:

Code: Select all

bind mode - "#% *+*h*" auto:announcement
proc auto:announcement {nick uhost handle chan mode target} {
   if {[set thetimerzq [timerexists "repeat:annoucement $chan $target"]]!=""} { killtimer $thetimerzq }
   if {[info exists ::ish($nick)]} { 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) [timer 15 [list repeat:annoucement $chan $target] 0]   }
}

proc repeat:annoucement {chan nick} {
   if {[set thetimerq [timerexists "repeat:annoucement $chan $nick"]]!=""} { killtimer $thetimerq }
   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 {
      catch { unset ::ish($nick) }
      killutimer $::ish($nick)
   }
}

bind mode - "#% *-*h*" stop:announcement
proc stop:announcement {nick uhost handle chan mode target} {
   if {[set thetimerXXz [timerexists "repeat:annoucement $chan $target"]]!=""} { killtimer $thetimerXXz }
   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]"
      killtimer $::ish($target)
   }
}

Post Reply