@@ -7,10 +7,10 @@ class BaseCommand(object): | |||||
"""A base class for commands on IRC.""" | """A base class for commands on IRC.""" | ||||
self.connection = connection | self.connection = connection | ||||
def get_hook(self): | |||||
def get_hooks(self): | |||||
"""Hooks are: 'msg', 'msg_private', 'msg_public', and 'join'. Return | """Hooks are: 'msg', 'msg_private', 'msg_public', and 'join'. Return | ||||
the hook you want this command to be called on.""" | |||||
return None | |||||
the hooks you want this command to be called on.""" | |||||
return [] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
"""Return help information for the command, used by !help. return None | """Return help information for the command, used by !help. return None | ||||
@@ -59,7 +59,7 @@ def check(hook, data): | |||||
data.parse_args() # parse command arguments into data.command and data.args | data.parse_args() # parse command arguments into data.command and data.args | ||||
for command in commands: | for command in commands: | ||||
if command.get_hook() == hook: | |||||
if hook in command.get_hooks(): | |||||
if command.check(data): | if command.check(data): | ||||
command.process(data) | command.process(data) | ||||
break | break |
@@ -6,8 +6,8 @@ from irc.base_command import BaseCommand | |||||
from config.irc_config import * | from config.irc_config import * | ||||
class ChanOps(BaseCommand): | class ChanOps(BaseCommand): | ||||
def get_hook(self): | |||||
return "msg" | |||||
def get_hooks(self): | |||||
return ["msg"] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
action = command.capitalize() | action = command.capitalize() | ||||
@@ -8,8 +8,8 @@ from config.irc_config import * | |||||
from irc.base_command import BaseCommand | from irc.base_command import BaseCommand | ||||
class Git(BaseCommand): | class Git(BaseCommand): | ||||
def get_hook(self): | |||||
return "msg" | |||||
def get_hooks(self): | |||||
return ["msg"] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
return "Commands to interface with the bot's git repository; use '!git help' for sub-command list." | return "Commands to interface with the bot's git repository; use '!git help' for sub-command list." | ||||
@@ -7,8 +7,8 @@ from irc.data import Data | |||||
from irc import command_handler | from irc import command_handler | ||||
class Help(BaseCommand): | class Help(BaseCommand): | ||||
def get_hook(self): | |||||
return "msg" | |||||
def get_hooks(self): | |||||
return ["msg"] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
return "Generates help information." | return "Generates help information." | ||||
@@ -7,8 +7,8 @@ import re | |||||
from irc.base_command import BaseCommand | from irc.base_command import BaseCommand | ||||
class Link(BaseCommand): | class Link(BaseCommand): | ||||
def get_hook(self): | |||||
return "msg" | |||||
def get_hooks(self): | |||||
return ["msg"] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
return "Convert a Wikipedia page name into a URL." | return "Convert a Wikipedia page name into a URL." | ||||
@@ -7,8 +7,8 @@ import random | |||||
from irc.base_command import BaseCommand | from irc.base_command import BaseCommand | ||||
class Test(BaseCommand): | class Test(BaseCommand): | ||||
def get_hook(self): | |||||
return "msg" | |||||
def get_hooks(self): | |||||
return ["msg"] | |||||
def get_help(self, command): | def get_help(self, command): | ||||
return "Test the bot!" | return "Test the bot!" | ||||