mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +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
@ -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 not name:
|
||||||
if 'X-Bender' in fd.headers:
|
if 'X-Bender' in fd.headers:
|
||||||
irc.reply('<Bender> %s' % fd.headers['X-Bender'])
|
return '<Bender> %s' % fd.headers['X-Bender']
|
||||||
elif 'X-Fry' in fd.headers:
|
elif 'X-Fry' in fd.headers:
|
||||||
irc.reply('<Fry> %s' % fd.headers['X-Fry'])
|
return '<Fry> %s' % fd.headers['X-Fry']
|
||||||
else:
|
else:
|
||||||
irc.reply(
|
return 'Slashdot seems to be running low on Futurama ' \
|
||||||
'Slashdot seems to be running low on Futurama quotes.')
|
'quotes.'
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
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