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 urllib2
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
|
import rssparser
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import debug
|
import debug
|
||||||
import privmsgs
|
import privmsgs
|
||||||
|
@ -240,19 +242,13 @@ class Http(callbacks.Privmsg):
|
||||||
that Matters.
|
that Matters.
|
||||||
"""
|
"""
|
||||||
if time.time() - self._slashdotTime > 1800:
|
if time.time() - self._slashdotTime > 1800:
|
||||||
try:
|
results = rssparser.parse('http://slashdot.org/slashdot.rss')
|
||||||
fd = urllib2.urlopen('http://slashdot.org/slashdot.xml')
|
headlines = [x['title'] for x in results['items']]
|
||||||
slashdotXml = fd.read()
|
self._slashdotResponse = ' :: '.join(headlines)
|
||||||
fd.close()
|
while len(self._slashdotResponse) > 400:
|
||||||
dom = xml.dom.minidom.parseString(slashdotXml)
|
headlines.pop()
|
||||||
headlines = []
|
|
||||||
for headline in dom.getElementsByTagName('title'):
|
|
||||||
headlines.append(str(headline.firstChild.data))
|
|
||||||
self._slashdotResponse = ' :: '.join(headlines)
|
self._slashdotResponse = ' :: '.join(headlines)
|
||||||
self._slashdotTime = time.time()
|
self._slashdotTime = time.time()
|
||||||
except urllib2.URLError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
return
|
|
||||||
irc.reply(msg, self._slashdotResponse)
|
irc.reply(msg, self._slashdotResponse)
|
||||||
|
|
||||||
_geekquotere = re.compile('<p class="qt">(.*?)</p>')
|
_geekquotere = re.compile('<p class="qt">(.*?)</p>')
|
||||||
|
|
Loading…
Reference in New Issue