mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Let's give the user the option to get only a Bender or Fry quote.
This commit is contained in:
parent
ac27c8e95a
commit
b51f753b11
@ -81,7 +81,7 @@ class FreshmeatException(Exception):
|
|||||||
class Http(callbacks.PrivmsgCommandAndRegexp):
|
class Http(callbacks.PrivmsgCommandAndRegexp):
|
||||||
threaded = True
|
threaded = True
|
||||||
regexps = ['geekSnarfer']
|
regexps = ['geekSnarfer']
|
||||||
|
|
||||||
_titleRe = re.compile(r'<title>(.*?)</title>', re.I | re.S)
|
_titleRe = re.compile(r'<title>(.*?)</title>', re.I | re.S)
|
||||||
|
|
||||||
def callCommand(self, name, irc, msg, *L, **kwargs):
|
def callCommand(self, name, irc, msg, *L, **kwargs):
|
||||||
@ -464,20 +464,29 @@ class Http(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
irc.reply('; '.join(resp))
|
irc.reply('; '.join(resp))
|
||||||
|
|
||||||
def futurama(self, irc, msg, args):
|
def futurama(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""[{bender|fry}]
|
||||||
|
|
||||||
Returns a random Bender or Fry (from Futurama) quote from Slashdot's
|
Returns a random Bender or Fry (from Futurama) quote from Slashdot's
|
||||||
HTTP headers.
|
HTTP headers. If a name is specified, attempts to return a quote
|
||||||
|
specific to that character.
|
||||||
"""
|
"""
|
||||||
|
name = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
fd = webutils.getUrlFd('http://slashdot.org/')
|
fd = webutils.getUrlFd('http://slashdot.org/')
|
||||||
try:
|
try:
|
||||||
if 'X-Bender' in fd.headers:
|
if not name:
|
||||||
irc.reply('<Bender> %s' % fd.headers['X-Bender'])
|
if 'X-Bender' in fd.headers:
|
||||||
elif 'X-Fry' in fd.headers:
|
return '<Bender> %s' % fd.headers['X-Bender']
|
||||||
irc.reply('<Fry> %s' % fd.headers['X-Fry'])
|
elif 'X-Fry' in fd.headers:
|
||||||
|
return '<Fry> %s' % fd.headers['X-Fry']
|
||||||
|
else:
|
||||||
|
return 'Slashdot seems to be running low on Futurama ' \
|
||||||
|
'quotes.'
|
||||||
else:
|
else:
|
||||||
irc.reply(
|
try:
|
||||||
'Slashdot seems to be running low on Futurama quotes.')
|
return '<%s> %s' % (name, fd.headers['X-%s' % name])
|
||||||
|
except KeyError:
|
||||||
|
return 'Slashdot seems to be running low on %s quotes' %\
|
||||||
|
name
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user