Added slashdot command (thanks, inkedmn!)

This commit is contained in:
Jeremy Fincher 2003-03-22 07:53:46 +00:00
parent c628d60b8b
commit b6e98a577f

View File

@ -32,9 +32,10 @@
from baseplugin import * from baseplugin import *
import re import re
import time
import urllib2 import urllib2
import threading import threading
#import xml.dom.minidom import xml.dom.minidom
import debug import debug
import privmsgs import privmsgs
@ -209,4 +210,24 @@ class Http(callbacks.Privmsg):
except urllib2.URLError: except urllib2.URLError:
irc.error(msg, 'Couldn\'t open the search page.') irc.error(msg, 'Couldn\'t open the search page.')
_slashdotTime = 0.0
def slashdot(self, irc, msg, args):
"takes no arguments"
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))
self._slashdotResponse = ' :: '.join(headlines)
self._slashdotTime = time.time()
except urllib2.URLError, e:
irc.error(msg, str(e))
return
irc.reply(msg, self._slashdotResponse)
Class = Http Class = Http