From 1afa10cbc5b14d3ecb265a943eb0c17d539db3c4 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 4 Jul 2012 02:12:44 -0400 Subject: [PATCH] Refactor actual praises out of praise; fix replag --- earwigbot/commands/praise.py | 34 ++++++++++++++++++---------------- earwigbot/commands/replag.py | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/earwigbot/commands/praise.py b/earwigbot/commands/praise.py index bb60801..86ece33 100644 --- a/earwigbot/commands/praise.py +++ b/earwigbot/commands/praise.py @@ -25,22 +25,24 @@ from earwigbot.commands import BaseCommand class Command(BaseCommand): """Praise people!""" name = "praise" - commands = ["praise", "earwig", "leonard", "leonard^bloom", "groove", - "groovedog"] + + def setup(self): + try: + self.praises = self.config.commands[self.name]["praises"] + except KeyError: + self.praises = [] + + def check(self, data): + check = data.command == "praise" or data.command in self.praises + return data.is_command and check def process(self, data): - if data.command == "earwig": - msg = "\x02Earwig\x0F is the bestest Python programmer ever!" - elif data.command in ["leonard", "leonard^bloom"]: - msg = "\x02Leonard^Bloom\x0F is the biggest slacker ever!" - elif data.command in ["groove", "groovedog"]: - msg = "\x02GrooveDog\x0F is the bestest heh evar!" - else: - if not data.args: - msg = "You use this command to praise certain people. Who they are is a secret." - else: - msg = "You're doing it wrong." - self.reply(data, msg) + if data.command in self.praises: + msg = self.praises[data.command] + self.say(data.chan, msg) return - - self.say(data.chan, msg) + if not data.args: + msg = "You use this command to praise certain people. Who they are is a secret." + else: + msg = "you're doing it wrong." + self.reply(data, msg) diff --git a/earwigbot/commands/replag.py b/earwigbot/commands/replag.py index b8899bc..91e0f9f 100644 --- a/earwigbot/commands/replag.py +++ b/earwigbot/commands/replag.py @@ -32,7 +32,7 @@ class Command(BaseCommand): def setup(self): try: - self.key = self.config.commands[self.name]["default"] + self.default = self.config.commands[self.name]["default"] except KeyError: self.default = None