<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/4142" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2003-04-15T06:37:14-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/4142</id>

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-15T06:37:14-04:00</updated>

		<published>2003-04-15T06:37:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=19090#p19090</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=19090#p19090"/>
		<title type="html"><![CDATA[XML News grabbing script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=19090#p19090"><![CDATA[
Anyone who knows of a working script that can snatch news from a XML file on a website, and forward it to the IRC channel?<br><br>I've tried ultramode.tcl by Thrill, which seemed to be exactly what I wanted - but it turned out I couldn't get it working.<br><br>Maybe someone know what's wrong with it? I'll post the code here.<br><div class="codebox"><p>Code: </p><pre><code># Ultramode news.tcl V1.0  -- Generic XML version# by Thrill# # All newsheadlines parsed by this script are (C) whatever news site you use :) # # Version History: V1.0 - first public release#                  V1.1 - XML-functionality added# # Remember to change this script before implementing it! Remove/comment the 'die "Ultramode News not changed!"' afterwards.# Change all the variables until DO NOT EDIT to reflect the site you are using. See the included example-scripts for# amiga.org and slashdot.org for reference.## The author takes no responsibility whatsoever for the usage and working of this script !# # E-mail: jmildham59@hotmail.com# default bind command !ultranews, change to your likingset ultracommandname "!xmlnews"# do NOT change this: bind pub - "$ultracommandname" ultranews# change from here again:# set the base URL here if the ultramode.txt only shows a relative path to the newsfile (ie. not 'http://slashdot.org/newsitem' but '/newsitem')# for slashdot this stays empty - for amiga.org this gets 'http://www.amiga.org'set ultrabaseurl ""# set the location of lynx here. Normally this should be ok.set ultralynx "/usr/bin/lynx"# set temporary path hereset ultratemp "/tmp/ultramode.txt"# set the URL of the ultramode.txt here set ultramode "slashdot.org/slashdot.xml"# change this line to what you want to appear as title of the page (single word) set ultratitle "Ultramode"# the url to the page you are pasting the news fromset ultraurl "Slashdot.org"# change this to the number of newsitems to paste to the chan by default when no option is given# do NOT make this larger then the maximum of newsitems than there are in ultramode.txt !set ultraitems 4# change this to the maximum number of newsitems there are in ultramode.txt, by default this is 10set ultramaxitems 20# there is 1 possible changeme below in the output function (clearly noted) to let you change the way# the newsitems are displayed.# comment this line out after change#die "Ultramode $ultratitle News not changed!"#### DO NOT EDIT BELOW - EVERY CHANGE IS ON YOUR OWN RISK AND COULD LEAD THIS SCRIPT TO FAIL! ##################### Function: ultranews# Purpose : public function called by the bind !ultranews, selects user-choice and forwards to 'ultraparse'-functionproc ultranews { nick uhost handle chan arg } {  global ultralynx ultraitems ultramaxitems ultraurl ultramode ultratemp ultrabaseurl ultracommandname   if {[llength $arg]==0} {      # user gave just !ultranews      set f [open "|$ultralynx -core -realm -child -preparsed -nolist -dump $ultramode" r]      set ultratempfile [open "$ultratemp" w]      while { [eof $f] != 1 } {        set templine "[gets $f]"        puts $ultratempfile $templine      }      close $f      close $ultratempfile      putchan $nick "3$ultraurl Headlines \"$ultracommandname help\" for options "      for { set argument 1 } { $argument &lt; $ultraitems+1 } { incr argument } {        ultraparse $nick $uhost $handle $chan $argument      }   } else {      if { [lindex $arg 0] == "help" } {        # user asked for help        putserv "notice $nick :$ultraurl News - www.$ultraurl"        putserv "notice $nick :Usage: $ultracommandname &lt;number&gt;"        putserv "notice $nick :where &lt;number&gt; is from 1 to $ultramaxitems"      } else {          if { ([lindex $arg 0] &lt; $ultramaxitems+1) &amp;&amp; ([lindex $arg 0] &gt; 0) } {           putchan $nick "3$ultraurl Headlines \"$ultracommandname help\" for options "           set f [open "|$ultralynx -core -realm -child -preparsed -nolist -dump $ultramode" r]           set ultratempfile [open "$ultratemp" w]           while { [eof $f] != 1 } {             set templine "[gets $f]"             puts $ultratempfile $templine           }           close $f           close $ultratempfile           set argument "[lindex $arg 0]"           ultraparse $nick $uhost $handle $chan $argument         } else {            putserv "notice $nick :Usage: $ultracommandname &lt;number&gt; where &lt;number&gt; is from 1 to $ultramaxitems"          }                 }         }  }################# Function: ultraparse# Purpose : private function which actually calls lynx to get the website and parses the contents based on the #           selection parameter $arg. First line of the news is red.proc ultraparse { nick uhost handle chan arg } {    global ultralynx ultraitems ultramaxitems ultraurl ultramode ultratemp ultrabaseurl ultracommandname  set f [open "$ultratemp" r]  set templine "[gets $f]"  set countera 0  while {[eof $f] != 1} {    set templine "[gets $f]"    if {[string last "&lt;story&gt;" $templine] != -1} {      incr countera      if { $countera == $arg } {       set templine "[gets $f]"       set temptitle "[getxml $templine title]"       set templine "[gets $f]"       set tempurl "[getxml $templine url]"       #set tempurl $templine       set templine "[gets $f]"       set tempdate "[getxml $templine time]"       #set tempdate $templine## POSSIBLE CHANGEME -&gt; here is the output of the URL, when you leave the variables intact, you could remove the colors## this is the version without any colours (which does look a little blurry alas):##     if {$ultrabaseurl != ""} {##       putchan $chan " [lindex $tempdate 0] $temptitle Click: $ultrabaseurl$tempurl"##     } else {##       putchan $chan " [lindex $tempdate 0] $temptitle Click: $tempurl"##     }############       if {$ultrabaseurl != ""} {         putchan $nick "3 [lindex $tempdate 0] 12$temptitle 5Click: $ultrabaseurl0$tempurl"       } else {         putchan $nick "3 [lindex $tempdate 0] 12$temptitle 5Click: $tempurl"       }       break      }    }  }  close $f}################# Function: getxml# Purpose : private function that returns the entityvalue of a well formatted XML-lineproc getxml { line token } {  set firstindex [expr { [string first "&lt;$token&gt;" $line] + [string length "&lt;$token&gt;"] } ]  set secondindex [ expr { [string last "&lt;\/$token" $line] - 1 } ]  return [string range $line $firstindex $secondindex]}proc putchan {chan msg} { putserv "notice $chan :$msg" }putlog "Ultramode $ultratitle News V1.0 by Thrill - Loaded."</code></pre></div>The ultramode.txt file stay empty at all times, so maybe that's got something to do with it?<br><br>Thanks in advance!<p>Statistics: Posted by Guest — Tue Apr 15, 2003 6:37 am</p><hr />
]]></content>
	</entry>
	</feed>
