From 4b6ebf0f214b6c3f100475379301d266d11a0e56 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Fri, 2 Sep 2011 17:11:12 -0400 Subject: [PATCH] Add magic 8-ball, tweak mylife --- modules/8ball.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++ modules/mylife.py | 6 ++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 modules/8ball.py diff --git a/modules/8ball.py b/modules/8ball.py new file mode 100644 index 0000000..8f43106 --- /dev/null +++ b/modules/8ball.py @@ -0,0 +1,52 @@ +#!/usr/bin/python2 +""" +8ball.py - magic 8-ball +author: mutantmonkey +""" + +import random + +def eightball(phenny, input): + """.8ball - Magic 8-ball.""" + + strong_yes = [ + '45 seconds full throttle', + 'It is certain', + 'It is decidedly so', + 'Without a doubt', + 'Yes--definitely', + 'You may rely on it', + ] + tentative_yes = [ + 'As I see it, yes', + 'Most likely', + 'Outlook good', + 'Signs point to yes', + 'Yes', + ] + negative = [ + 'Your request is not bro enough', + 'Reply hazy, try again', + 'Ask again later', + 'Better not tell you now', + 'Cannot predict now', + 'Concentrate and ask again', + ] + noncommital = [ + 'I am sorry, too high to respond', + "Don't count on it", + 'My reply is no', + 'My sources say no', + 'Outlook not so good', + 'Very doubtful' + ] + + # black magic + quotes = strong_yes + tentative_yes + negative + noncommital + quote = random.choice(quotes) + phenny.reply(quote) +eightball.commands = ['8ball'] + +if __name__ == '__main__': + print __doc__.strip() + diff --git a/modules/mylife.py b/modules/mylife.py index 944a88c..d4937cf 100644 --- a/modules/mylife.py +++ b/modules/mylife.py @@ -2,6 +2,7 @@ """ mylife.py - various commentary on life author: Ramblurr +author: mutantmonkey """ import random @@ -47,10 +48,11 @@ def mliarab(phenny, input): return doc = lxml.html.parse(req) - quote = doc.getroot().find_class('entry')[0][0].text_content() + quotes = doc.getroot().find_class('entry') + quote = random.choice(quotes)[0].text_content() quote = quote.strip() phenny.say(quote) -mliarab.commands = ['mliarab'] +mliarab.commands = ['mliar', 'mliarab'] def mlib(phenny, input): """.mlib - My life is bro."""