phenny/modules/choose.py

25 lines
713 B
Python
Raw Normal View History

2012-02-22 15:06:32 -05:00
#!/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 <red> <blue> - for when you just can't decide"""
origterm = input.groups()[1]
if not origterm:
return phenny.say(".choose <red> <blue> - for when you just can't decide")
2012-02-22 15:46:45 -05:00
c = re.findall(r'([^,]+)', origterm)
2012-02-22 15:06:32 -05:00
if len(c) == 1:
2012-02-22 15:46:45 -05:00
c = re.findall(r'(\S+)', origterm)
2012-02-22 15:06:32 -05:00
if len(c) == 1:
return phenny.reply("%s" % (c[0].strip()))
2012-02-22 15:06:32 -05:00
fate = random.choice(c).strip()
return phenny.reply("%s" % (fate))
choose.rule = (['choose'], r'(.*)')
if __name__ == '__main__':
print(__doc__.strip())