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.

read .txt from web

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
.
.pt
Halfop
Posts: 71
Joined: Wed Nov 16, 2005 10:14 am

read .txt from web

Post by .pt »

i got a .txt on a website with just 1 line and i want the bot to read that line when i do a command, can someone make that pls


tks in advance, best regards
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

something along this line

Code: Select all

package require http
set url "http://your.site/page.html"
bind pub - !command web:read

proc web:read {n u h c t} {
   ::http::config -useragent "Mozilla/4.75 (X11; U; FreeBSD 6.1; i586; Nav)"
   set http [::http::data [::http::geturl $url]]
   putserv "PRIVMSG $c $http"
}
.
.pt
Halfop
Posts: 71
Joined: Wed Nov 16, 2005 10:14 am

Post by .pt »

i get this error

Tcl error [web:read]: can´t read "url": no suck variable
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

package require http
set weburl "http://your.site/page.html"
bind pub - !command web:read

proc web:read {n u h c t} {
   ::http::config -useragent "Mozilla/4.75 (X11; U; FreeBSD 6.1; i586; Nav)"
   set http [::http::data [::http::geturl $::weburl]]
   putserv "PRIVMSG $c $http"
}
.
.pt
Halfop
Posts: 71
Joined: Wed Nov 16, 2005 10:14 am

Post by .pt »

same thing, my url ends in .txt and not in html.. maybe thats why?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

your url must now be a weburl (check var names) :P.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

you should invoke ::http::cleanup at the end of your proc (check the manual for details)
Have you ever read "The Manual"?
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

If not try this, always worked for me :)

Code: Select all

package require http
bind pub - !test foo
proc foo {n u h c t} {
   set x [::http::geturl http://bar.com/moo.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
   ::http::cleanup $x
} 
www.NT-Hosts.Net - More than just a host
Post Reply