mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 09:34:05 +01:00
Update Http.acronym to match the changes in the website. Remove the headers
since we include those by default. Set __parent.
This commit is contained in:
parent
7c019b3893
commit
68844cda3a
@ -66,9 +66,13 @@ class FreshmeatException(Exception):
|
|||||||
class Http(callbacks.Privmsg):
|
class Http(callbacks.Privmsg):
|
||||||
threaded = True
|
threaded = True
|
||||||
_titleRe = re.compile(r'<title>(.*?)</title>', re.I | re.S)
|
_titleRe = re.compile(r'<title>(.*?)</title>', re.I | re.S)
|
||||||
|
def __init__(self):
|
||||||
|
self.__parent = super(Http, self)
|
||||||
|
self.__parent.__init__()
|
||||||
|
|
||||||
def callCommand(self, name, irc, msg, *L, **kwargs):
|
def callCommand(self, name, irc, msg, *L, **kwargs):
|
||||||
try:
|
try:
|
||||||
super(Http, self).callCommand(name, irc, msg, *L, **kwargs)
|
self.__parent.callCommand(name, irc, msg, *L, **kwargs)
|
||||||
except webutils.WebError, e:
|
except webutils.WebError, e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
|
|
||||||
@ -233,9 +237,7 @@ class Http(callbacks.Privmsg):
|
|||||||
acronym = privmsgs.getArgs(args)
|
acronym = privmsgs.getArgs(args)
|
||||||
url = 'http://www.acronymfinder.com/' \
|
url = 'http://www.acronymfinder.com/' \
|
||||||
'af-query.asp?String=exact&Acronym=%s' % urllib.quote(acronym)
|
'af-query.asp?String=exact&Acronym=%s' % urllib.quote(acronym)
|
||||||
request = webutils.Request(url, headers={'User-agent':
|
html = webutils.getUrl(url)
|
||||||
'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
|
|
||||||
html = webutils.getUrl(request)
|
|
||||||
if 'daily limit' in html:
|
if 'daily limit' in html:
|
||||||
s = 'Acronymfinder.com says I\'ve reached my daily limit. Sorry.'
|
s = 'Acronymfinder.com says I\'ve reached my daily limit. Sorry.'
|
||||||
irc.error(s)
|
irc.error(s)
|
||||||
@ -245,7 +247,7 @@ class Http(callbacks.Privmsg):
|
|||||||
utils.sortBy(lambda s: not s.startswith('[not an acronym]'), defs)
|
utils.sortBy(lambda s: not s.startswith('[not an acronym]'), defs)
|
||||||
for (i, s) in enumerate(defs):
|
for (i, s) in enumerate(defs):
|
||||||
if s.startswith('[not an acronym]'):
|
if s.startswith('[not an acronym]'):
|
||||||
defs[i] = s.split('is ', 1)[1]
|
defs[i] = s.split('] ', 1)[1].strip()
|
||||||
if len(defs) == 0:
|
if len(defs) == 0:
|
||||||
irc.reply('No definitions found.')
|
irc.reply('No definitions found.')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user