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.

bind time dosn't work with PRIVMSG

Help for those learning Tcl or writing their own scripts.
Post Reply
h
hlds12
Voice
Posts: 3
Joined: Tue Dec 29, 2009 8:07 pm

bind time dosn't work with PRIVMSG

Post by hlds12 »

I tried this:

Code: Select all

bind pub - !force myproc
bind time - "?0 * * * *" myproc

proc myproc {nick uhost hand chan text} {

	set Something "text here"

	set writeFile [open file.txt w]
	puts $writeFile $Something
	close $writeFile


	putserv "PRIVMSG $chan : TEST TEXT"
}
When I write !force in my irc channel the proc "myproc" is performed. Good.
The funny part: With bind time it doesn't work! When I wait 10 minutes nothing is printed out by PRIVMSG but the text "text here" is written to the file file.txt.

Actually this means, the proc is performed with both "bind pub" and "bind time", but PRIVMSG doesn't work for bind time...

Can somebody please tell me how to use PRIVMSG within bind time...
Thanks!
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

A time bind does not pass a channel to the proc it triggers.

Code: Select all

bind TIME - "?0 * * * *" myproc

proc myproc {minute hour day month year} {
  # code here
}
Each bind passes different arguments to the procs they call. Look them up in tcl-commands.html before using them.
I must have had nothing to do
h
hlds12
Voice
Posts: 3
Joined: Tue Dec 29, 2009 8:07 pm

Post by hlds12 »

arfer wrote:Each bind passes different arguments to the procs they call.
Thanks!
Does this mean that I can't use PRIVMSG at all? I could just do this

Code: Select all

proc myproc {minute hour day month year} {
  # code here
} 
and this

Code: Select all

putserv "PRIVMSG $minute : TEST TEXT" 
but that won't work.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The following code will output a message in the channel named #whatever every 10 minutes (whenever minutes ends with a 0 ie. 00, 10, 20 etc) :-

Code: Select all

# set here the time bind's output channel
set mychan "#whatever"

bind TIME - "?0 * * * *" myproc

proc myproc {minute hour day month year} {
  global mychan
  putserv "PRIVMSG $mychan :time bind triggered"
  return 0
}
Last edited by arfer on Tue Dec 29, 2009 9:46 pm, edited 1 time in total.
I must have had nothing to do
h
hlds12
Voice
Posts: 3
Joined: Tue Dec 29, 2009 8:07 pm

Post by hlds12 »

Thank you very much, at last that occurred to me...
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The following code will output a message in all the bot's channels with a specific channel flag every ten minutes :-

Code: Select all

setudef flag mytime

bind TIME - "?0 * * * *" myproc

proc myproc {minute hour day month year} {
  foreach chan [channels] {
    if {[channel get $chan mytime]} {
      if {[botonchan $chan]} {
        putserv "PRIVMSG $chan :time bind triggered"
      }
    }
  }
  return 0
}
In order to activate the flag for each channel, use (in the partyline) .chanset #channelname +mytime
I must have had nothing to do
Post Reply