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.

Doing stuff weekly

Old posts that have not been replied to for several years.
Locked
F
FreakyComputer
Voice
Posts: 22
Joined: Fri May 10, 2002 8:00 pm
Location: South Africa

Doing stuff weekly

Post by FreakyComputer »

Hi there,

I would like to know if there is a way to do a specific set of commands weekly (eg. Saturdays 12:00) but the TIME bind only supports dates and not days :cry:

If there is anyone that can help, please just give me that bit of code :)

Thanks
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

Here is one way:

Code: Select all

set days "Wednesday Saturday"

proc something {minute hour day month year} {
  global days
  if {[lsearch -exact [split [string tolower $days]] [string tolower [clock format [unixtime] -format %A]]] == -1} {
    return 0
  }
  otherwise do this
}

bind time - "00 12 * * *" something
User avatar
Bucko
Voice
Posts: 10
Joined: Wed Dec 24, 2003 1:32 pm

Post by Bucko »

I tried this method and I didn't have much luck with it.

Here is my script
set days "Wednesday Sunday"

proc meeting {minute hour day month year} {
global days
if {[lsearch -exact [split [string tolower $days]] [string tolower [clock format [unixtime] -format %A]]] == -1} {
return 0
}
otherwise do this
}
set meeting_url "http://mywebpage.com"
bind time - "20 04 * * *" meeting_get
proc meeting_get {nick mask hand chan args} {
global meeting_url
set file [open "|lynx -source $meeting_url" r]
set html "[gets $file]"
regsub "<html><head><title></title></head><body>" $html "" html



putserv "NOTICE $nick $chan :$html "
}
If anyone has any ideas about this I would be happy to try them out. This is not giving me any errors at all. Its just not doing anything.

I know the parsing script works because I tried it our in an onjoin bind earlier.

All I really need this to do is post a few lines of text at these times and not parse an html file, but im new to this and the html thing worked. I didn't want to factor in too many things that could go wrong.

Thanks in advance
Bucko
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Instead of "otherwise do this" add your stuff to do when is one of thouse days from the days variable. Also, I think your regsub won't do what you intend to do, the notice you want to send with the result can have just one destination $chan or $nick and bouth don't have a variable so will fail to *work* .. either set them to something like set nick "somenickhere" or set chan "#somechannel" or put directly a nick or a channel you want to be the destination of the notice.

Edit: Use this regsub instead:

Code: Select all

regsub -all -- {<|>|html|head|title|body|[/]} $html "" html
Last edited by caesar on Sun Dec 28, 2003 2:16 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Bucko
Voice
Posts: 10
Joined: Wed Dec 24, 2003 1:32 pm

Post by Bucko »

ok I'm following you, but lets just focus on the "otherwise do this" portion. So if I wanted to display a message like:

"TCL is fun to learn when you've been up all night drinking coffee"

where the code says otherwise do this i would simply put:
set tclmsg "TCL is fun to learn when you've been up all night drinking coffee"
global tclmsg
putserv #MYCHANNEL :$tclmsg
set the time bind to "45 12 * * *" for 12:45am and wablam automatically I should get my message appearing on Sundays and Wednesdays at 12:45 am.

Or do I need some sort if if statment in front of my set tclmsg... IE: if days = Sunday then blah blah blah

???
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Bucko wrote:set the time bind to "45 12 * * *" for 12:45am and wablam automatically I should get my message appearing on Sundays and Wednesdays at 12:45 am.

Or do I need some sort if if statment in front of my set tclmsg... IE: if days = Sunday then blah blah blah
This bind would work, to make it prettier yo can bind to "45 12 *" instead (* matchs everything with spaces or no spaces)
User avatar
Bucko
Voice
Posts: 10
Joined: Wed Dec 24, 2003 1:32 pm

Post by Bucko »

Im still having problems would sombody be able to check this script.
Im not sure whats not functioning, but I've tested it with various times and I can't seem to even get the message to output.
set days "Sunday Wednesday"

proc something {minute hour day month year} {
global days
if {[lsearch -exact [split [string tolower $days]] [string tolower [clock format [unixtime] -format %A]]] == -1} {
return 0
}
set tclmsg "TCL is fun to learn when you've been up all night drinking coffee"
global tclmsg
putserv #NAChat :$tclmsg


}

bind time - "53 05 *" something
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

putserv "PRIVMSG #NAChat :$tclmsg"
Once the game is over, the king and the pawn go back in the same box.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

And there's no need for 'global tclmsg' since you want use the var elsewhere.
User avatar
Bucko
Voice
Posts: 10
Joined: Wed Dec 24, 2003 1:32 pm

Post by Bucko »

Awesome ok I got it to work, Thank you.

Now if I want to message to be multiple lines how do I go about with this

set meeting_msg {
"TCL is fun to learn when you've been up all night drinking coffee"
"line 2"
"line 3"
}

for each i $meeting_msg putserv "PRIVMSG #NAChat :$meeting_msg :i "
Its coming up with nothing so I think my syntax is incorrect as per usual.
User avatar
Bucko
Voice
Posts: 10
Joined: Wed Dec 24, 2003 1:32 pm

Post by Bucko »

Whoo Hoo

I figured it out sweet!!!!!!!!

Thanks for the help on this one guys. I think I actually might be learning something here. :>
Locked