| View previous topic :: View next topic |
| Author |
Message |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Fri May 26, 2006 9:48 am Post subject: bot to get a read a txt file depending on the day of week |
|
|
ok heres my thing...
Im currently using this code to get the schedules for my radio station to show in channel...
| Code: |
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 |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri May 26, 2006 10:06 am Post subject: Re: bot to get a read a txt file depending on the day of wee |
|
|
| 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: |
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"  _________________ Have you ever read "The Manual"?
Last edited by user on Fri May 26, 2006 10:19 am; edited 1 time in total |
|
| Back to top |
|
 |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Fri May 26, 2006 10:11 am Post subject: yay! |
|
|
Works perfect, thanks alot  _________________ www.NT-Hosts.Net - More than just a host |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri May 26, 2006 10:24 am Post subject: Re: yay! |
|
|
| Lynxfm wrote: | Works perfect, thanks alot  |
No it doesn't (check the urls ) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
|