Browse files

Call them plugins, not commands.

  • Loading branch information...
1 parent d4c9d2c commit 3821cb775c8b70abe39f1ff3225c216540913a72 @mythmon mythmon committed Jul 16, 2011
Showing with 23 additions and 23 deletions.
  1. +11 −11 hamper/commander.py
  2. +10 −10 hamper/plugins/commands.py
  3. +2 −2 hamper/plugins/{plugins.py → plugin_utils.py}
View
22 hamper/commander.py
@@ -8,7 +8,7 @@
from bravo.plugin import retrieve_plugins
-from hamper.IHamper import ICommand
+from hamper.IHamper import IPlugin
class CommanderProtocol(irc.IRCClient):
@@ -54,7 +54,7 @@ def privmsg(self, user, channel, msg):
'channel': channel,
}
- for cmd in self.factory.commands:
+ for cmd in self.factory.plugins:
match = cmd.regex.match(msg)
if match and (directed or (not cmd.onlyDirected)):
comm.update({'groups': match.groups()})
@@ -82,20 +82,20 @@ def __init__(self, channel, nickname):
self.history = {}
- self.commands = set()
- for _, plugin in retrieve_plugins(ICommand, 'hamper.plugins').items():
- self.registerCommand(plugin)
+ self.plugins = set()
+ for _, plugin in retrieve_plugins(IPlugin, 'hamper.plugins').items():
+ self.registerPlugin(plugin)
def clientConnectionLost(self, connector, reason):
print "Lost connection (%s)." % (reason)
def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)
- def registerCommand(self, command):
- """Register a command. To be used as a decorator."""
- options = re.I if not command.caseSensitive else None
- command.regex = re.compile(command.regex, options)
+ def registerPlugin(self, plugin):
+ """Register a plugin. To be used as a decorator."""
+ options = re.I if not plugin.caseSensitive else None
+ plugin.regex = re.compile(plugin.regex, options)
- self.commands.add(command)
- print 'registered', command
+ self.plugin.add(plugin)
+ print 'registered', plugin.name
View
20 hamper/plugins/commands.py
@@ -2,14 +2,14 @@
from zope.interface import implements, Interface, Attribute
-from hamper.IHamper import ICommand
+from hamper.IHamper import IPlugin
-class Command(object):
+class Plugin(object):
- implements(ICommand)
+ implements(IPlugin)
- name = 'Generic Command'
+ name = 'Generic Plugin'
onlyDirected = True
caseSensitive = False
regex = ''
@@ -19,7 +19,7 @@ def __call__(self, commander, options):
return True
-class FriendlyCommand(Command):
+class Friendly(Plugin):
name = 'Friendly'
regex = 'hi'
@@ -28,7 +28,7 @@ def __call__(self, commander, options):
commander.say('Hello {0[user]}'.format(options))
-class QuitCommand(Command):
+class QuitCommand(Plugin):
name = 'Quit'
regex = 'go away'
@@ -38,7 +38,7 @@ def __call__(self, commander, options):
commander.quit()
-class OmgPonies(Command):
+class OmgPonies(Plugin):
name = 'OMG!!! Ponies!!!'
regex = r'.*pon(y|ies).*'
@@ -47,7 +47,7 @@ class OmgPonies(Command):
def __call__(self, commander, options):
commander.say('OMG!!! PONIES!!!')
-class Sed(Command):
+class Sed(Plugin):
name = 'sed'
regex = r'^!s/(.*)/(.*)/(g?i?)'
@@ -67,7 +67,7 @@ def __call__(self, commander, options):
.format(comm['user'], new_msg))
break;
-class LetMeGoogleThatForYou(Command):
+class LetMeGoogleThatForYou(Plugin):
name = 'lmgtfy'
regex = '.*lmgtfy\s+(.*)'
@@ -83,4 +83,4 @@ def __call__(self, commander, options):
sed = Sed()
omgponies = OmgPonies()
quit = QuitCommand()
-hi = FriendlyCommand()
+hi = Friendly()
View
4 hamper/plugins/plugins.py → hamper/plugins/plugin_utils.py
@@ -1,9 +1,9 @@
from zope.interface import implements, Interface, Attribute
-from hamper.plugins.commands import Command
+from hamper.plugins.commands import Plugin
-class PluginUtils(Command):
+class PluginUtils(Plugin):
names = 'Plugin Utils'
regex = '^plugins?(.*)$'

0 comments on commit 3821cb7

Please sign in to comment.