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.

msg once a day by bind time

Help for those learning Tcl or writing their own scripts.
Post Reply
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

msg once a day by bind time

Post by cache »

Code: Select all

bind time - "33 15 *" BREAKTIME
################
proc BREAKTIME {nick uhost hand chan arg} {
  putquick "PRIVMSG $chan :something....." 
  return 0
}
Am trying to make the bot say something once a day, but what am I doing wrong? I kept getting errors untill I made it "nick uhost hand chan arg" but doesn't display the message or show any error.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Please read the documentation for the Time binding (quoted below). As you can see, the arguments passed to the proc are minute, hour, day, month, and year, not nickname, userhost, handle, channel, and text. As such, you first need to make sure your proc takes the appropriate number of parameters (5). This is why it started working when you added "arg" at the end of the list. That, however, does not mean "chan" will hold a channel name, but rather the current month (as a number 01-12). As such, I would recommend that you use some other names for those variables, as to avoid confusion.

Secondly, you'll need to alter your PRIVMSG commandline to take a valid destination, either by hardcoding this into the script, or using some global variable.

Code: Select all

    (37) TIME (stackable)
         bind time <flags> <mask> <proc>
         proc-name <minute> <hour> <day> <month> <year>

         Description: allows you to schedule procedure calls at certain
           times. mask matches 5 space separated integers of the form:
           "minute hour day month year". minute, hour, day, month have a
           zero padding so they are exactly two characters long; year is
           four characters. Flags are ignored.
         Module: core
NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: msg once a day by bind time

Post by speechles »

cache wrote:

Code: Select all

bind time - "33 15 *" BREAKTIME
################
proc BREAKTIME {nick uhost hand chan arg} {
  putquick "PRIVMSG $chan :something....." 
  return 0
}
Am trying to make the bot say something once a day, but what am I doing wrong? I kept getting errors untill I made it "nick uhost hand chan arg" but doesn't display the message or show any error.
Your not naming your variables correctly, but you kept the 5 expected by a bind to time. You may want to use "minutes hours day month year" instead. Then you can see the next issue you will have. A bind to time doesn't give you any $chan argument to use no matter where you place it. You need to place the message staticly:
putquick "PRIVMSG #chan :something....."

Edit: Nml375 beat me to it.. haw ;)
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

so the $chan part has to be static? No way to make this work in all rooms it is in?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

cache wrote:so the $chan part has to be static? No way to make this work in all rooms it is in?

Code: Select all

# Sure, you just change this:
putquick "PRIVMSG #chan :something....." 

# To this:
foreach chan [channels] {
  putquick "PRIVMSG $chan :something....."
}
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

speechles wrote:
cache wrote:so the $chan part has to be static? No way to make this work in all rooms it is in?

Code: Select all

# Sure, you just change this:
putquick "PRIVMSG #chan :something....." 

# To this:
foreach chan [channels] {
  putquick "PRIVMSG $chan :something....."
}
I have it like this now and it works

Code: Select all

##########
bind time - "33 15 *" BREAKTIME 
proc BREAKTIME {nick uhost hand chan arg} { 
foreach chan [channels] { 
  putquick "PRIVMSG $chan :something....." 
}
  return 0 
}
##########
Just want to make sure it is done right, thanks
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

It is something of a coincidence that this code now functions as expected.

A TIME bind returns {minute hour day month year} to the proc it calls and not {nick uhost hand chan arg}. However, since you are permitted to call the arguments anything you like as they are received by the proc AND there happens to be five of them, it does work.

This is why you couldn't use $chan to send a channel output message to the IRCD in your original code. A TIME bind is not directly associated with an IRC channel.
I must have had nothing to do
Post Reply