This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/disabled_stuff/eightball.py

24 lines
596 B
Python
Raw Permalink Normal View History

2011-11-20 22:23:31 +13:00
import random
2014-02-14 16:36:57 +13:00
2013-09-04 18:30:04 +08:00
from util import hook, text
2011-11-20 22:23:31 +13:00
2014-02-14 16:36:57 +13:00
color_codes = {
"<r>": "\x02\x0305",
"<g>": "\x02\x0303",
"<y>": "\x02"
}
2011-11-20 22:23:31 +13:00
with open("plugins/data/8ball_responses.txt") as f:
responses = [line.strip() for line in
2013-09-04 18:30:04 +08:00
f.readlines() if not line.startswith("//")]
2011-11-20 22:23:31 +13:00
2012-02-28 21:09:40 -08:00
2011-11-20 22:23:31 +13:00
@hook.command('8ball')
2014-02-13 14:34:50 +13:00
def eightball(inp, action=None):
2013-09-04 18:30:04 +08:00
"""8ball <question> -- The all knowing magic eight ball,
in electronic form. Ask and it shall be answered!"""
2013-08-02 12:05:44 +12:00
magic = text.multiword_replace(random.choice(responses), color_codes)
2013-10-01 15:41:54 +13:00
action("shakes the magic 8 ball... {}".format(magic))