From ce53be53d28a27a45930b2ac36d67e130cd41f1a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 8 Jun 2012 11:42:30 +1200 Subject: [PATCH] Moved the colour code to only run when first loading the plugin --- plugins/8ball.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/8ball.py b/plugins/8ball.py index 6aeea04..59ddc35 100755 --- a/plugins/8ball.py +++ b/plugins/8ball.py @@ -8,6 +8,8 @@ color_codes = { } with open("plugins/data/8ball_responses.txt") as f: + for code in color_codes: + f = f.replace(code, color_codes[code]) responses = [line.strip() for line in f.readlines() if not line.startswith("//")] @@ -17,7 +19,6 @@ def eightball(input, me=None): "8ball -- The all knowing magic eight ball, " \ "in electronic form. Ask and it shall be answered!" - out = random.choice(responses) - for code in color_codes: - out = out.replace(code, color_codes[code]) - me("shakes the magic 8 ball... %s" % out) + # here we use voodoo magic to tell the future + magic = random.choice(responses) + me("shakes the magic 8 ball... %s" % magic)