From ebf5a57d6f31f74aba4682e7a99b883dccdaf82c Mon Sep 17 00:00:00 2001 From: Rebecca Elena Stewart Date: Wed, 22 Feb 2012 15:06:32 -0500 Subject: [PATCH] added choose module --- modules/choose.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modules/choose.py diff --git a/modules/choose.py b/modules/choose.py new file mode 100644 index 0000000..b079346 --- /dev/null +++ b/modules/choose.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +choose.py - sometimes you just can't decide, a phenny module +""" + +import re, random + +def choose(phenny, input): + """.choose - for when you just can't decide""" + origterm = input.groups()[1] + if not origterm: + return phenny.say(".choose - for when you just can't decide") + origterm = origterm + c = re.findall(r'([^,]+)', input) + if len(c) == 1: + c = re.findall(r'(\S+)', input) + if len(c) == 1: + return phenny.reply("%s" % (c)) + fate = random.choice(c).strip() + return phenny.reply("%s" % (fate)) +choose.rule = (['choose'], r'(.*)') + +if __name__ == '__main__': + print(__doc__.strip())