From 99364a27aff3e07ec8e8bc8ac3225aea8a7e4c08 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 6 Apr 2003 11:28:51 +0000 Subject: [PATCH] Changed slashdot to use rssparser and also to remove all stories if the resulting message is too long. --- plugins/Http.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/Http.py b/plugins/Http.py index d9647113f..4030fda67 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -50,6 +50,8 @@ import urllib import urllib2 import xml.dom.minidom +import rssparser + import utils import debug import privmsgs @@ -240,19 +242,13 @@ class Http(callbacks.Privmsg): that Matters. """ if time.time() - self._slashdotTime > 1800: - try: - fd = urllib2.urlopen('http://slashdot.org/slashdot.xml') - slashdotXml = fd.read() - fd.close() - dom = xml.dom.minidom.parseString(slashdotXml) - headlines = [] - for headline in dom.getElementsByTagName('title'): - headlines.append(str(headline.firstChild.data)) + results = rssparser.parse('http://slashdot.org/slashdot.rss') + headlines = [x['title'] for x in results['items']] + self._slashdotResponse = ' :: '.join(headlines) + while len(self._slashdotResponse) > 400: + headlines.pop() self._slashdotResponse = ' :: '.join(headlines) - self._slashdotTime = time.time() - except urllib2.URLError, e: - irc.error(msg, str(e)) - return + self._slashdotTime = time.time() irc.reply(msg, self._slashdotResponse) _geekquotere = re.compile('

(.*?)

')