]"
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(']*>[^<]+ | [^<]+]*>(\w+)')
def acronym(self, irc, msg, args):
""""""
acronym = privmsgs.getArgs(args)
try:
url = 'http://www.acronymfinder.com/' \
'af-query.asp?String=exact&Acronym=%s' % acronym
fd = urllib2.urlopen(url)
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:
irc.reply(msg, '%s could be %s' % (acronym, ', or '.join(defs)))
Class = Http
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|