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.

Web text to channel if file is different. Please help me ;)

Old posts that have not been replied to for several years.
Locked
P
Prestige

Web text to channel if file is different. Please help me ;)

Post by Prestige »

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?

Thxxx a l8t!!!!!
Prestige

Code: Select all

package require http

proc check_news {nick uhost hand chan text} {
set dataoggi [clock format [clock seconds] -format "%d/%m/%y"]

putquick "NOTICE $chan :News - Update date $tdate
$tdate"
putquick "NOTICE $chan :."
set newsfile [::http::geturl http://xxx.xxxx.xxx/xxx.txt]
set data [::http::data $newsfile]
foreach z [split $data \n] {
putquick "NOTICE $chan :$z"
  }

}
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

make a global variable containing the old data, then match it against the new data, if it's not matching set the global varaiable to the new data..
Elen sila lúmenn' omentielvo
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I would actualy recomend using some form of hash of the data. IE, use a MD5 hash.

This way, no matter how large the page is, you are not storing vast information, for no purpose.
P
Prestige

Post by Prestige »

Thax a lot for the suggestions but i don't know really how to do it ;p
p
pollar
Voice
Posts: 18
Joined: Thu Jan 09, 2003 12:20 pm
Location: Lithuania

My answer

Post by pollar »

I haven't tested it, but it should work (I think :wink: )

Code: Select all

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 :evil: , but you can fix them.... :)
P
Prestige

Post by Prestige »

Yesss it's perfect!! Thanksssss a l8t!!
I'll credit you :pp


thx!! :wink:
Locked