]"
multiline = privmsgs.getArgs(args, needed=0, optional=1)
try:
fd = urllib2.urlopen('http://bash.org/?random1')
except urllib2.URLError:
irc.error(msg, 'Error connecting to geekquote server.')
return
html = fd.read()
fd.close()
if multiline:
m = self._geekquotere.search(html, re.M)
else:
m = self._geekquotere.search(html)
if m is None:
irc.error(msg, 'No quote found.')
return
quote = utils.htmlToText(m.group(1))
quote = ' // '.join(quote.splitlines())
irc.reply(msg, quote)
_acronymre = re.compile(r']+>(?:)?([^<]+)(?:)?')
def acronym(self, irc, msg, args):
"""
Displays the first 5 matches from acronymfinder.com"""
acronym = privmsgs.getArgs(args)
try:
url = 'http://www.acronymfinder.com/' \
'af-query.asp?String=exact&Acronym=%s' % acronym
request = urllib2.Request(url, headers={'User-agent':
'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
fd = urllib2.urlopen(request)
except urllib2.URLError:
irc.error(msg, 'Couldn\'t connect to acronymfinder.com')
return
html = fd.read()
fd.close()
defs = self._acronymre.findall(html)
if len(defs) == 0:
irc.reply(msg, 'No definitions found.')
else:
defs=[repr(x.strip()) for x in defs[1:-1]][:5]
irc.reply(msg, '%s could be %s' % (acronym, ', or '.join(defs)))
_netcraftre = re.compile(r'whatos text -->(.*?)"""
hostname = privmsgs.getArgs(args)
url = 'http://uptime.netcraft.com/up/graph/?host=%s' % hostname
fd = urllib2.urlopen(url)
html = fd.read()
fd.close()
m = self._netcraftre.search(html)
if m:
html = m.group(1)
s = utils.htmlToText(html, tagReplace='').strip('\xa0 ')
irc.reply(msg, s[9:]) # Snip off "the site"
elif html.find('We could not get any results') != -1:
irc.reply(msg, 'No results found for %s.' % hostname)
else:
irc.error(msg, 'The format of the was odd.')
Class = Http
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|