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 

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

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


Joined: 10 Oct 2005
Posts: 100
Location: UK

PostPosted: Fri May 26, 2006 9:48 am    Post subject: bot to get a read a txt file depending on the day of week Reply with quote

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 Smile
_________________
www.NT-Hosts.Net - More than just a host
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri May 26, 2006 10:06 am    Post subject: Re: bot to get a read a txt file depending on the day of wee Reply with quote

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 Smile

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" Razz
_________________
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
View user's profile Send private message
NTHosts
Op


Joined: 10 Oct 2005
Posts: 100
Location: UK

PostPosted: Fri May 26, 2006 10:11 am    Post subject: yay! Reply with quote

Works perfect, thanks alot Very Happy
_________________
www.NT-Hosts.Net - More than just a host
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri May 26, 2006 10:24 am    Post subject: Re: yay! Reply with quote

Lynxfm wrote:
Works perfect, thanks alot Very Happy

No it doesn't Wink (check the urls Razz)
_________________
Have you ever read "The Manual"?
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