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.
Maybe someone know what's wrong with it? I'll post the code here.
Code: Select all
# 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 liking
set 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 here
set 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 from
set 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 10
set 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'-function
proc 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 < $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 <number>"
putserv "notice $nick :where <number> is from 1 to $ultramaxitems"
} else {
if { ([lindex $arg 0] < $ultramaxitems+1) && ([lindex $arg 0] > 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 <number> where <number> 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 "<story>" $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 -> 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-line
proc getxml { line token } {
set firstindex [expr { [string first "<$token>" $line] + [string length "<$token>"] } ]
set secondindex [ expr { [string last "<\/$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."
Thanks in advance!