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.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 10:17 am
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"
}
}
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Dec 11, 2021 11:11 am
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)
}
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 11:23 am
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
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 11:24 am
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)
}
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 11:34 am
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
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Dec 11, 2021 11:49 am
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, ...
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 11:57 am
oh yea sorry what i meant was the timer doesnt get set
errors :
Tcl error [stop:announcement]: argument is not a timerID
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Dec 11, 2021 12:10 pm
Code: Select all
set ::ish($target) [timer 1 [list repeat:announcement $chan $target] 0]
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 12:15 pm
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)
}
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 12:15 pm
changed timer to this to test with not to have to wait minutes:
set ::ish($target) [utimer 10 [list repeat:announcement $chan $target] 0] }
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Dec 11, 2021 12:20 pm
fix the spelling @ proc repeat:annoucement
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 12:27 pm
thanks spike^^ that seems to do it
thanks CrazyCat
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Dec 11, 2021 1:37 pm
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^^
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 3:13 pm
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
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Dec 11, 2021 3:40 pm
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)
}
}