I would like that my bot check every 1 min a web text file and if it's different as the last check it'll send a notice into the channel with text of the new one. Text in the file it's normally not more than 1 line.
Could somebody help me? What I have to add to my code?
package require http
# For storing old data:
set tempData ""
# Update time (in minutes):
set updTime 1
# Set autodisplay channel(s) [separated by spaces]:
set notChans "#lamest #laamah"
# Killing existing timer (needed if rehashing or restarting):
if {[timerexists updData]!=""} {
killtimer $updTimer
}
# Updating data...
proc updData {} {
global updTimer updTime tempData
set newsfile [::http::geturl http://xxx.xxxx.xxx/xxx.txt]
set data [::http::data $newsfile]
if {$data!=$tempData} {
# data is new, put this data to chans:
notifyChans $data
set tempData $data
putlog "Updating... New data found!"
} else {
putlog "Updating... New data not found!"
}
set updTimer [timer $updTime updData]
}
# Chan notices:
proc notifyChans {data} {
global notChans
foreach _chan $notChans {
if {[botonchan $_chan]} {
putquick "NOTICE $_chan :your text here..."
putquick "NOTICE $_chan :your text here..."
foreach z [split $data \n] {
putquick "NOTICE $_chan :$z"
}
} else {
putlog "I'm not on $_chan"
}
}
}
# Also you can bind command:
bind pub -|- !test performTest
proc performTest {nick host hand chan text} {
global tempData
if {$tempData!=""} {
putquick "NOTICE $chan :last updated data..."
foreach z [split $tempData \n] {
putquick "NOTICE $chan :$z"
}
}
}
# Autoupdating data on start, rehash or restart:
set updTimer [timer $updTime updData]
Thats all. I'm sure there is a lot of bugs , but you can fix them....