egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Auto announcement every 10 min after nick gets halfop
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 10:17 am    Post subject: Auto announcement every 10 min after nick gets halfop Reply with quote

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:


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"
 }
}
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Dec 11, 2021 11:11 am    Post subject: Reply with quote

Not tested, but may work

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

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 11:23 am    Post subject: Reply with quote

thank you CrazyCat for the swift response i tested it and i get this error:

Quote:

Tcl error [auto:announcement]: invalid command name "repeat:announcement"


also i changed the :

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

to

bind mode - "#% *-*h*" stop:announcement
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 11:24 am    Post subject: Reply with quote

this is what i have so far:

Code:

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

Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 11:34 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Dec 11, 2021 11:49 am    Post subject: Reply with quote

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

Code:
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, ...
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 11:57 am    Post subject: Reply with quote

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

errors :




Quote:

Tcl error [stop:announcement]: argument is not a timerID
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sat Dec 11, 2021 12:10 pm    Post subject: Reply with quote

Code:
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
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 12:15 pm    Post subject: Reply with quote

thanks for the reply Spike^^ i tried that and got error

Quote:
Tcl error in script for 'timer364':
invalid command name "repeat:announcement"



Code:

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)
   }
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 12:15 pm    Post subject: Reply with quote

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


Quote:
set ::ish($target) [utimer 10 [list repeat:announcement $chan $target] 0] }
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sat Dec 11, 2021 12:20 pm    Post subject: Reply with quote

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
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 12:27 pm    Post subject: Reply with quote

thanks spike^^ that seems to do it
thanks CrazyCat
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Dec 11, 2021 1:37 pm    Post subject: Reply with quote

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


Woops, did I add an extra list ? Yes, I did it again Smile

Thanks SpiKe^^ Smile
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 3:13 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Dec 11, 2021 3:40 pm    Post subject: Reply with quote

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

Code:

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

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber