Преглед на файлове

!trout command, plus an indent fix

tags/v0.1^2
Ben Kurtovic преди 12 години
родител
ревизия
71ac38ea89
променени са 3 файла, в които са добавени 49 реда и са изтрити 23 реда
  1. +0
    -22
      earwigbot/commands/_old.py
  2. +1
    -1
      earwigbot/commands/afc_pending.py
  3. +48
    -0
      earwigbot/commands/trout.py

+ 0
- 22
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]


+ 1
- 1
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)

+ 48
- 0
earwigbot/commands/trout.py Целия файл

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2012 by Ben Kurtovic <ben.kurtovic@verizon.net>
#
# 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))

Зареждане…
Отказ
Запис