mirror of https://github.com/Mikaela/Limnoria.git
Changed slashdot to use rssparser and also to remove all stories if the resulting message is too long.
This commit is contained in:
parent
1e353f7f12
commit
99364a27af
|
@ -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
|
||||
irc.reply(msg, self._slashdotResponse)
|
||||
|
||||
_geekquotere = re.compile('<p class="qt">(.*?)</p>')
|
||||
|
|
Loading…
Reference in New Issue