Code: Select all
set rssfeed "http://sports.espn.go.com/espn/rss/news"
set trigger "!latest"
set channel "#chan"
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "egghttp_example.tcl has not been loaded as a result."
} else {
proc your_callbackproc {sock} {
global rssfeed channel
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
regexp {<title>(.*)</title>} $body - title
regexp {<pubDate>(.*)</pubDate>} $body - date
regexp {<description>(.*)</description>} $body - desc
regexp {<link>(.*)</link>} $body - link
puthelp "PRIVMSG $channel :Latest Top Headline: $title"
puthelp "PRIVMSG $channel :Published: $date"
puthelp "PRIVMSG $channel :Description: $desc"
puthelp "PRIVMSG $channel :Link: $link"
}
bind pub -|* $trigger top:trigger
proc top:trigger {nick host hand chan text} {
global rssfeed
set sock [egghttp:geturl $rssfeed your_callbackproc]
return 1
}
putlog "egghttp_example.tcl has been successfully loaded."
}
I'm new to this, so go easy[9:57pm] <Me> !latest
[9:57pm]«@ Bot» Latest Top Headline: ESPN.com</title>
[9:57pm]«@ Bot» Published: Tue, 15 Nov 2005 16:49:23 PST</pubDate>
[9:57pm]«@ Bot» Description: Latest news from ESPN.com</description>
[9:57pm]«@ Bot» Link: http://espn.go.com/</link> <description>Latest news from ESPN.com</description>
Code: Select all
tag when posting logs, code
withregexp {<title>(.*)</title>} $body - title
regexp {<pubDate>(.*)</pubDate>} $body - date
regexp {<description>(.*)</description>} $body - desc
regexp {<link>(.*)</link>} $body - link
and it got rid of the tags at the end of each line of output, the ones that werent supposed to be there.regexp {<title>(.*?)</title>} $body - title
regexp {<pubDate>(.*?)</pubDate>} $body - date
regexp {<description>(.*?)</description>} $body - desc
regexp {<link>(.*?)</link>} $body - link
instead of...[10:13pm] <Me> !latest
[10:13pm]«@ Bot» Latest Top Headline: ESPN.com
[10:13pm]«@ Bot» Published: Tue, 15 Nov 2005 16:49:23 PST
[10:13pm]«@ Bot» Description: Latest news from ESPN.com
[10:13pm]«@ Bot» Link: http://espn.go.com/
Now I just need to have it get the right ones for Headline, Description and Link... any tips?[9:57pm] <Me> !latest
[9:57pm]«@ Bot» Latest Top Headline: ESPN.com</title>
[9:57pm]«@ Bot» Published: Tue, 15 Nov 2005 16:49:23 PST</pubDate>
[9:57pm]«@ Bot» Description: Latest news from ESPN.com</description>
[9:57pm]«@ Bot» Link: http://espn.go.com/</link> <description>Latest news from ESPN.com</description>
Code: Select all
tag when posting logs, code
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:atom="http://purl.org/atom/ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
- <channel>
<title>ESPN.com</title>
<link>http://espn.go.com/</link>
<description>Latest news from ESPN.com</description>
<language>en-us</language>
<atom:link rel="start" href="http://sports.espn.go.com/espn/rss/news?null" />
<lastBuildDate>Wed, 16 Nov 2005 20:15:52 PST</lastBuildDate>
<docs>http://backend.userland.com/rss</docs>
<managingEditor>webmaster@espn.go.com</managingEditor>
- <image>
<url>http://espn-att.starwave.com/i/tvlistings/tv_espn_original.gif</url>
<title>ESPN logo</title>
<link>http://espn.go.com</link>
<width>84</width>
<height>34</height>
</image>
<ttl>30</ttl>
<dc:rights>Copyright 2005</dc:rights>
<admin:generatorAgent rdf:resource="http://espn.go.com/rss/?v=0.9beta" />
<admin:errorReportsTo rdf:resource="mailto:customer.service@espn.go.com" />
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
- <item>
- <dc:creator>
- <![CDATA[ John Carroll
]]>
</dc:creator>
- <title>
- <![CDATA[ Carroll: Comparing Brown and Jackson and their iffy teams
]]>
</title>
- <description>
- <![CDATA[ L.A. Showdown: Brown, Jackson meet again<br /><br /> by John Carroll<br/><br/>When Phil Jackson and Larry Brown walk onto the Staples Center floor tonight, it will be the first time these two coaches have met since June 16, 2004. That was Game 5 of the NBA Finals and the Detroit Pistons, the team Brown coached, won 100-87, clinching...
]]>
</description>
<pubDate>Wed, 16 Nov 2005 09:24:27 PST</pubDate>
<guid>http://insider.espn.go.com/nba/insider/columns/story?columnist=carroll_john&id=2225946&campaign=rss&source=ESPNHeadlines</guid>
<link>http://insider.espn.go.com/nba/insider/columns/story?columnist=carroll_john&id=2225946&campaign=rss&source=ESPNHeadlines</link>
</item>
Code: Select all
<![CDATA[ Carroll: Comparing Brown and Jackson and their iffy teams ]]>
Code: Select all
<![CDATA[ L.A. Showdown: Brown, Jackson meet again<br /><br /> by John Carroll<br/><br/>When Phil Jackson and Larry Brown walk onto the Staples Center floor tonight, it will be the first time these two coaches have met since June 16, 2004. That was Game 5 of the NBA Finals and the Detroit Pistons, the team Brown coached, won 100-87, clinching... ]]>
Code: Select all
<link>http://insider.espn.go.com/nba/insider/columns/story?columnist=carroll_john&id=2225946&campaign=rss&source=ESPNHeadlines</link>
Code: Select all
tag when posting logs, code
I've read both of those guides and looked over the tcl.commands.doc briefly.If you have some experience writing Tcl scripts and would like to write your own for Eggdrop, have a read through the Beginners Guide to TCL, and be sure to check out tcl-commands.doc in the /doc directory which contains information on all of Eggdrop's built-in Tcl commands. If you're completely new to Tcl, try the excellent Guide to TCL scripting for Eggdrop 1.6. And download yourself a copy of the Tcl Manual for quick reference.
Code: Select all
tag when posting logs, code