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 Previous  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 3:47 pm    Post subject: Reply with quote

i also found if timer is running and nick is gone from channel it doesnt kill the running timer
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 7:57 pm    Post subject: Reply with quote

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:
# 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 ?

_________________
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
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sun Dec 12, 2021 12:09 am    Post subject: Reply with quote

hi simo

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

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

change it to:
unset -nocomplain -- ::is($nick)
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 9:33 am    Post subject: Reply with quote

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


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Dec 12, 2021 11:55 am    Post subject: Reply with quote

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:
if {[info exists ::ish($nick)]} { return }

It's not $nick but $target
_________________
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: Sun Dec 12, 2021 12:51 pm    Post subject: Reply with quote

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

Code:

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 1:00 pm    Post subject: Reply with quote

now i also get error:

Quote:

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


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

PostPosted: Sun Dec 12, 2021 3:31 pm    Post subject: Reply with quote

Code:

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 3:39 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 3:42 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 3:45 pm    Post subject: Reply with quote

perhaps the halfopped nick can be stored seperate in a var as well to be used by repeat announcement proc
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 3:52 pm    Post subject: Reply with quote

thanks for trying Spike^^ CrazyCat much apreciated
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sun Dec 12, 2021 4:22 pm    Post subject: Reply with quote

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

Code:

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Dec 12, 2021 5:05 pm    Post subject: Reply with quote

tested it same result thanks for the efforts u put into it tho Spike^^ and CrazyCat
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sun Dec 12, 2021 5:51 pm    Post subject: Reply with quote

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:

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
.
Back to top
View user's profile Send private message Visit poster's website
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 Previous  1, 2, 3  Next
Page 2 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