Permalink
Browse files

Hamper, tell me about your plugins.

  • Loading branch information...
1 parent 9f773bd commit d4c9d2cd1b1cd4d77f5cd88cf5f680e7dd72459f @mythmon mythmon committed Jul 16, 2011
Showing with 30 additions and 10 deletions.
  1. +1 −10 hamper/plugins/commands.py
  2. +29 −0 hamper/plugins/plugins.py
View
@@ -18,9 +18,8 @@ class Command(object):
def __call__(self, commander, options):
return True
-class FriendlyCommand(Command):
- implements(ICommand)
+class FriendlyCommand(Command):
name = 'Friendly'
regex = 'hi'
@@ -31,8 +30,6 @@ def __call__(self, commander, options):
class QuitCommand(Command):
- implements(ICommand)
-
name = 'Quit'
regex = 'go away'
@@ -43,8 +40,6 @@ def __call__(self, commander, options):
class OmgPonies(Command):
- implements(ICommand)
-
name = 'OMG!!! Ponies!!!'
regex = r'.*pon(y|ies).*'
onlyDirected = False
@@ -54,8 +49,6 @@ def __call__(self, commander, options):
class Sed(Command):
- implements(ICommand)
-
name = 'sed'
regex = r'^!s/(.*)/(.*)/(g?i?)'
onlyDirected = False
@@ -76,8 +69,6 @@ def __call__(self, commander, options):
class LetMeGoogleThatForYou(Command):
- implements(ICommand)
-
name = 'lmgtfy'
regex = '.*lmgtfy\s+(.*)'
onlyDirected = False
View
@@ -0,0 +1,29 @@
+from zope.interface import implements, Interface, Attribute
+
+from hamper.plugins.commands import Command
+
+
+class PluginUtils(Command):
+
+ names = 'Plugin Utils'
+ regex = '^plugins?(.*)$'
+
+ def __call__(self, commander, options):
+
+ args = options['groups'][0].split(' ')
+ args = [a.strip() for a in args]
+ args = [a for a in args if a]
+ commander.say('args: ' + repr(args))
+
+ dispatch = {
+ 'list': self.listPlugins,
+ }
+
+ dispatch[args[0]](commander, args[1:])
+
+ def listPlugins(self, commander, args):
+ """Reply with a list of all currently loaded plugins."""
+ commander.say('Loaded Plugins: {0}.'.format(
+ ', '.join([c.name for c in commander.factory.commands])))
+
+plugin_utils = PluginUtils()

0 comments on commit d4c9d2c

Please sign in to comment.