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.

Website grap text script

Old posts that have not been replied to for several years.
Locked
t
trinitykln

Website grap text script

Post by trinitykln »

Okey kinda an followup to my earlier post, I have this code
and the eggdrop starts fine no error, and no error when the pub command
is written... nothing in log what so ever but nothing happens...

Code: Select all

set ccdrift_url "http://www.cstv.dk/ccdrift/index.php"

bind pub - !ccdrift ccdrift_topic 

proc ccdrift_topic {nick host hand chan args} {
     global ccdrift_url
     set file [open "|lynx -source $ccdrift_url" r] 
     set html "[gets $file]"      
     set html "[string trimleft $html "<h1>"]" 
     set html "[string trimright $html "</h1>"]" 
     putserv "TOPIC $chan :$html"
   
} 
Anyone seeing faults or an reason why nothing happens
have tried removing the two string trim
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

first of, I would use the http package provided by tcl, dunno if it's better but it's easier to work with :) ....in my opinion ;)

now to your problem, you are opening the file(url) for reading, which is correct, but then you use gets, this will take one line of the file and puts that in topic, now if you check the source of that file you will notice that first line of the source is empty :)
so what you need to do is to add a while loop in your code, something like this:

Code: Select all

set ccdrift_url "http://www.cstv.dk/ccdrift/index.php" 

bind pub - !ccdrift ccdrift_topic 

proc ccdrift_topic {nick host hand chan args} { 
     global ccdrift_url 
     set file [open "|lynx -source $ccdrift_url" r]
     while {![eof $file]} {
          gets $file html
          if {$html == {}} {continue}
          set html [string trimleft $html "<h1>"]
          set html [string trimright $html "</h1>"]
     } 
     putserv "TOPIC $chan :$html" 
    
}
Elen sila lúmenn' omentielvo
t
trinitykln

Post by trinitykln »

oh thanks my bad did'nt notice that the first line was empty!
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The string tims probably do stuff you don't expect them to. Check the manual for details :)
http://tcl.tk/man/tcl8.4/TclCmd/string.htm#M46
Locked