From 7bdff8297119bdf48ff9e975fea1e36d20331f26 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 5 Jul 2012 01:44:15 -0400 Subject: [PATCH] Fix broken commands, manager, and Data. --- earwigbot/commands/afc_pending.py | 6 ++++-- earwigbot/commands/geolocate.py | 6 ++++-- earwigbot/commands/langcode.py | 6 ++++-- earwigbot/commands/time.py | 6 ++++-- earwigbot/irc/data.py | 4 ++-- earwigbot/managers.py | 6 ++++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/earwigbot/commands/afc_pending.py b/earwigbot/commands/afc_pending.py index 6a2fec0..7c6c72f 100644 --- a/earwigbot/commands/afc_pending.py +++ b/earwigbot/commands/afc_pending.py @@ -20,9 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from earwigbot.commands import BaseCommand +from earwigbot.commands import Command -class Command(BaseCommand): +__all__ = ["AFCPending"] + +class AFCPending(Command): """Link the user to the pending AFC submissions page and category.""" name = "pending" commands = ["pending", "pend"] diff --git a/earwigbot/commands/geolocate.py b/earwigbot/commands/geolocate.py index 371e73c..589786b 100644 --- a/earwigbot/commands/geolocate.py +++ b/earwigbot/commands/geolocate.py @@ -23,9 +23,11 @@ import json import urllib2 -from earwigbot.commands import BaseCommand +from earwigbot.commands import Command -class Command(BaseCommand): +__all__ = ["Geolocate"] + +class Geolocate(Command): """Geolocate an IP address (via http://ipinfodb.com/).""" name = "geolocate" commands = ["geolocate", "locate", "geo", "ip"] diff --git a/earwigbot/commands/langcode.py b/earwigbot/commands/langcode.py index 434e72b..885b66e 100644 --- a/earwigbot/commands/langcode.py +++ b/earwigbot/commands/langcode.py @@ -20,9 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from earwigbot.commands import BaseCommand +from earwigbot.commands import Command -class Command(BaseCommand): +__all__ = ["Langcode"] + +class Langcode(Command): """Convert a language code into its name and a list of WMF sites in that language.""" name = "langcode" diff --git a/earwigbot/commands/time.py b/earwigbot/commands/time.py index 53dafe8..78eed82 100644 --- a/earwigbot/commands/time.py +++ b/earwigbot/commands/time.py @@ -29,9 +29,11 @@ try: except ImportError: pytz = None -from earwigbot.commands import BaseCommand +from earwigbot.commands import Command -class Command(BaseCommand): +__all__ = ["Time"] + +class Time(Command): """Report the current time in any timezone (UTC default), or in beats.""" name = "time" commands = ["time", "beats", "swatch"] diff --git a/earwigbot/irc/data.py b/earwigbot/irc/data.py index e5e5186..3e46e60 100644 --- a/earwigbot/irc/data.py +++ b/earwigbot/irc/data.py @@ -41,7 +41,7 @@ class Data(object): def _parse(self, msgtype): """Parse a line from IRC into its components as instance attributes.""" - sender = re.findall(":(.*?)!(.*?)@(.*?)\Z", line[0])[0] + sender = re.findall(":(.*?)!(.*?)@(.*?)\Z", self.line[0])[0] self._nick, self._ident, self._host = sender self._chan = self.line[2] @@ -51,7 +51,7 @@ class Data(object): # sender instead of the 'channel', which is ourselves: self._chan = self._nick self._is_private = True - self._msg = " ".join(line[3:])[1:] + self._msg = " ".join(self.line[3:])[1:] self._parse_args() self._parse_kwargs() diff --git a/earwigbot/managers.py b/earwigbot/managers.py index 6abbba2..975fe62 100644 --- a/earwigbot/managers.py +++ b/earwigbot/managers.py @@ -95,8 +95,10 @@ class _ResourceManager(object): f.close() for obj in vars(module).values(): - if type(obj) is type and isinstance(obj, self._resource_base): - self._load_resource(name, path, obj) + if type(obj) is type: + isresource = issubclass(obj, self._resource_base) + if isresource and not obj is self._resource_base: + self._load_resource(name, path, obj) def _load_directory(self, dir): """Load all valid resources in a given directory."""