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.

timer only goes on once

Old posts that have not been replied to for several years.
Locked
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

timer only goes on once

Post by exs-n0s »

Code: Select all

set i 0
foreach c [channels] { 
   if {[strlwr $c] != [strlwr $basechan]} { 
      utimer $interval [list puthelp "PRIVMSG $c :$msg"]
      incr i
   } 
}

Well, for some reason, the continuous timer isnt working. Only does the timer once, and its killed. I cant seem to find out whats wrong.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Here, use this:

Code: Select all

foreach c [channels] { 
 if {(![string equal -nocase $c $basechan])} { 
  utimer $interval "puthelp \"PRIVMSG $c :$msg\""
  } 
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Post by exs-n0s »

thanks for the reply awyeah.

Code: Select all

foreach c [channels] { 
 if {(![string equal -nocase $c $basechan])} { 
  utimer $interval "puthelp \"PRIVMSG $c :$msg\"" 
  } 
} 
Doesnt seem to work. It seems like its doing the same thing the old code is doing.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

To me logicially it seems correct, don't know why it wouldn't work.
How many channels is your bot on? It must be on more than 1 channel right?

Can I know what value has the variable $basechan been set to?

I don't know why you needed a variable $i and used it in the foreach loop because it merely has no effect on what you are trying todo.

It can be used in perhaps say you want every puthelp message to be delayed say 1sec or 2sec after each other to prevent the bot from getting excess flood, then thats where it can be used effectively. :wink:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Post by exs-n0s »

Yes, the message is being broadcasted to all channels the bot is in. $basechan would be set to a channel where the you can trigger the script, no where else. I have no idea why the $i is there, but i read somewhere on the forums that 'incr' is used to loop timers :s
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yes, the message is being broadcasted to all channels the bot is in.
Yes, thats what the script is supposed to do! To msg all the channels the bot is on (the script is working perfectly!). So how come you are saying the script doesn't seem to work?
*confused*
$basechan would be set to a channel where the you can trigger the script no where else.
Well actually to trigger it on a specific channel, $basechan should be set in the bind pub, pubm which ever you are using it shouldn't be set where it currently is.

if {(![string equal -nocase $c $basechan])} {
#This line means if current channel in channel list loop is *not*
#matching $basechan then it should activate the utimer.
#Hence this will activate for all channels except $basechan itself.

I have no idea why the $i is there, but i read somewhere on the forums that 'incr' is used to loop timers.
You already have looped all the channels where the bot is on so then you don't need a variable to count the number of channels. The variable [channels] is a list itself and will loop each element (channel) in the list.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Post by exs-n0s »

Yes, thats what the script is supposed to do! To msg all the channels the bot is on (the script is working perfectly!). So how come you are saying the script doesn't seem to work?
*confused*
Yeah, the script displays the messages to all channels fine. But my problem here is that the timer doesnt work properlly. The timer is only going off once, then dying, therefore the timer isnt looping itself as its supposed to :S
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

tcl timers dont loop, they run things once. So if you want something to happen every 10min, do something like this

Code: Select all

timer 10 proc:name

proc:name {} {
 # code goes here
 timer 10 proc:name
}
(You also might want to add a check to see if the timer is already running, before adding a new one)
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Post by exs-n0s »

nice, thanks GB, works like a charm now. I decided to bind public command to kill the timer, but not too sure if im doing it right.

Code: Select all

timer 1 scrim:timer 

proc scrim:timer {} {
global basechan msg
foreach c [channels] { 
if {(![string equal -nocase $c $basechan])} { 
puthelp "PRIVMSG $c :$msg" 
timer 1 scrim:timer 
}
}
}
bind pub - !done scrim:killtimer 
proc scrim:killtimer {nick host hand chan arg} {
foreach t [utimers] { if {[lindex $t 1] == "scrim:timer"} { killutimer [lindex $t end] } 
}
And i get this error "[21:56] Tcl error [scrim:killtimer]: invalid command name "scrim:killtimer"". mind me, i really hate doing timers :(
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

This should work

Code: Select all

bind pub -|- !done scrim:killtimer
proc scrim:killtimer {nick host hand chan arg} {
 foreach t [timers] {
   if {[string match "*scrim:timer*" $t]} {
     killtimer [lindex $t 2]
   }
 }
}
Note that timer and utimer is not the same, timer count in minutes, while utimer use seconds, so you dont want to mix those.
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Post by exs-n0s »

gb wrote:This should work

Code: Select all

bind pub -|- !done scrim:killtimer
proc scrim:killtimer {nick host hand chan arg} {
 foreach t [timers] {
   if {[string match "*scrim:timer*" $t]} {
     killtimer [lindex $t 2]
   }
 }
}
Note that timer and utimer is not the same, timer count in minutes, while utimer use seconds, so you dont want to mix those.
Thank you sir for your help!
Locked