diff --git a/earwigbot/commands/_old.py b/earwigbot/commands/_old.py index 8681b8b..bc58ee2 100644 --- a/earwigbot/commands/_old.py +++ b/earwigbot/commands/_old.py @@ -128,28 +128,6 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): return - if command == "trout": - try: - user = line2[4] - user = ' '.join(line2[4:]) - except Exception: - reply("Hahahahahahahaha...", chan, nick) - return - normal = unicodedata.normalize('NFKD', unicode(string.lower(user))) - if "itself" in normal: - reply("I'm not that stupid ;)", chan, nick) - return - elif "earwigbot" in normal: - reply("I'm not that stupid ;)", chan, nick) - elif "earwig" not in normal and "ear wig" not in normal: - text = 'slaps %s around a bit with a large trout.' % user - msg = '\x01ACTION %s\x01' % text - say(msg, chan) - else: - reply("I refuse to hurt anything with \"Earwig\" in its name :P", chan, nick) - return - - if command == "notes" or command == "note" or command == "about" or command == "data" or command == "database": try: action = line2[4] diff --git a/earwigbot/commands/afc_pending.py b/earwigbot/commands/afc_pending.py index 98b4dfb..6a2fec0 100644 --- a/earwigbot/commands/afc_pending.py +++ b/earwigbot/commands/afc_pending.py @@ -31,4 +31,4 @@ class Command(BaseCommand): msg1 = "pending submissions status page: http://enwp.org/WP:AFC/ST" msg2 = "pending submissions category: http://enwp.org/CAT:PEND" self.reply(data, msg1) - self.reply(data, msg2) + self.reply(data, msg2) diff --git a/earwigbot/commands/trout.py b/earwigbot/commands/trout.py new file mode 100644 index 0000000..6449d62 --- /dev/null +++ b/earwigbot/commands/trout.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2009-2012 by Ben Kurtovic +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from unicodedata import normalize + +from earwigbot.commands import Command + +__all__ = ["Trout"] + +class Trout(Command): + """Slap someone with a trout, or related fish.""" + name = "trout" + commands = ["trout", "whale"] + + def setup(self): + try: + self.exceptions = self.config.commands[self.name]["exceptions"] + except KeyError: + self.exceptions = {} + + def process(self, data): + animal = data.command + target = " ".join(data.args) or data.nick + normal = normalize("NFKD", target.decode("utf8")).lower() + if normal in self.exceptions: + self.reply(data, self.exceptions["normal"]) + else: + msg = "slaps {0} around a bit with a large {1}." + self.action(data.chan, msg.format(target, animal))