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.

bot to get a read a txt file depending on the day of week

Help for those learning Tcl or writing their own scripts.
Post Reply
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

bot to get a read a txt file depending on the day of week

Post by NTHosts »

ok heres my thing...

Im currently using this code to get the schedules for my radio station to show in channel...

Code: Select all

package require http

bind pub - !mon*1 monday
bind pub - !tue*1 tuesday
bind pub - !wed*1 wednesday
bind pub - !thu*1 thursday
bind pub - !fri*1 friday
bind pub - !sat*1 saturday
bind pub - !sun*1 sunday

proc monday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/mon.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc tuesday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/tue.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc wednesday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/wed.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc thursday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/thu.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc friday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/fri.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc saturday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/sat.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}

proc sunday {n u h c t} {
   set x [::http::geturl http://lynxfm.com/schedules/bottxt/sun.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
}
but what i also need this to do is know what day it is.. so if i just type !schedule it will know that today is Friday and get the correct txt file.
How would i do this please :)
www.NT-Hosts.Net - More than just a host
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: bot to get a read a txt file depending on the day of wee

Post by user »

Lynxfm wrote:but what i also need this to do is know what day it is.. so if i just type !schedule it will know that today is Friday and get the correct txt file.
How would i do this please :)

Code: Select all

package require http

bind pub - !mon*1 {schedule monday}
bind pub - !tue*1 {schedule tuesday}
bind pub - !wed*1 {schedule wednesday}
bind pub - !thu*1 {schedule thursday}
bind pub - !fri*1 {schedule friday}
bind pub - !sat*1 {schedule saturday}
bind pub - !sun*1 {schedule sunday}
bind pub - !schedule {schedule today}

array set day2url {
	sunday http://lynxfm.com/schedules/bottxt/sun.txt
	monday http://lynxfm.com/schedules/bottxt/mon.txt
	tuesday http://lynxfm.com/schedules/bottxt/tue.txt
	wednesday http://lynxfm.com/schedules/bottxt/wed.txt
	thursday http://lynxfm.com/schedules/bottxt/thu.txt
	friday http://lynxfm.com/schedules/bottxt/fri.txt
	saturday http://lynxfm.com/schedules/bottxt/sun.txt
}

proc schedule {d n u h c a} {
	if {$d=="today"} {
		set d [string tolower [clock format [clock sec] -format %A]]
	}
	set x [::http::geturl $::day2url($d)]
	foreach e [split [::http::data $x] \n] {
		puthelp "privmsg $c :$e"
	}
	::http::cleanup $x 
}
EDIT: forgot to include "package require http" :P
Last edited by user on Fri May 26, 2006 10:19 am, edited 1 time in total.
Have you ever read "The Manual"?
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

yay!

Post by NTHosts »

Works perfect, thanks alot :D
www.NT-Hosts.Net - More than just a host
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: yay!

Post by user »

Lynxfm wrote:Works perfect, thanks alot :D
No it doesn't ;) (check the urls :P)
Have you ever read "The Manual"?
Post Reply