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 

TCL script help - us holiday check

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
dutch1918
Voice


Joined: 30 Jul 2014
Posts: 14

PostPosted: Thu Dec 04, 2014 10:54 am    Post subject: TCL script help - us holiday check Reply with quote

holiday.csv format
date,name,bank holiday,TRUE or FALSE

Code:

proc do_930_post {min hour day month weekday} {
   global stockchan
   if {get date,TRUE/FALSE from holiday.csv and compare to todays date if TRUE then} {
      putserv "privmsg #swingtrader :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED - US HOLIDAY ))) \017"
   } else {
      putserv "privmsg #swingtrader :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
   }
}
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Dec 08, 2014 9:55 am    Post subject: Reply with quote

Can you be more explicit about your need ? And about your .csv (ie date format) ?
_________________
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
dutch1918
Voice


Joined: 30 Jul 2014
Posts: 14

PostPosted: Sun Dec 28, 2014 10:57 am    Post subject: Reply with quote

I finally figured it out with some help... In case someone else is looking the same thing here is the code I came up with:

holiday.csv file
Code:

Dec 25   Christmas          US Holiday   True
Jan 1   New Year's Day   US Holiday   True
Jan 19   Martin Luther King   US Holiday   True
Feb 16   Presidents Day   US Holiday   True
Apr 3   Good Friday          US Holiday   True
May 25   Memorial Day          US Holiday   True
Jul 3    Independance Day   US Holiday   True
Sep 7   Labor Day          US Holiday   True
Nov 26   Thanksgiving Day   US Holiday   True



bind cron script

Code:


proc do_930_post {min hour day month weekday} {
   set holiday_file [open "holiday.csv" r]
   set holidays [list]
   while {[gets $holiday_file line] != -1} {
       lappend holidays [lindex [split $line ,] 0]
   }
   set today [clock format [clock seconds] -timezone :America/New_York -format "%b %d"]
   lset today 1 [scan [lindex $today 1] %d]
   if {[lsearch -exact $holidays $today] > -1} {
       putserv "privmsg #options :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED -   US HOLIDAY ))) \017"
   putserv "privmsg #marketnews :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED -   US HOLIDAY ))) \017"
   } else {
   putserv "privmsg #options :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
   putserv "privmsg #marketnews :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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