瀏覽代碼

commands now support multiple hooks

tags/v0.1
Ben Kurtovic 13 年之前
父節點
當前提交
eee571879c
共有 7 個文件被更改,包括 14 次插入14 次删除
  1. +3
    -3
      irc/base_command.py
  2. +1
    -1
      irc/command_handler.py
  3. +2
    -2
      irc/commands/chanops.py
  4. +2
    -2
      irc/commands/git.py
  5. +2
    -2
      irc/commands/help.py
  6. +2
    -2
      irc/commands/link.py
  7. +2
    -2
      irc/commands/test.py

+ 3
- 3
irc/base_command.py 查看文件

@@ -7,10 +7,10 @@ class BaseCommand(object):
"""A base class for commands on IRC."""
self.connection = connection

def get_hook(self):
def get_hooks(self):
"""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):
"""Return help information for the command, used by !help. return None


+ 1
- 1
irc/command_handler.py 查看文件

@@ -59,7 +59,7 @@ def check(hook, data):
data.parse_args() # parse command arguments into data.command and data.args

for command in commands:
if command.get_hook() == hook:
if hook in command.get_hooks():
if command.check(data):
command.process(data)
break

+ 2
- 2
irc/commands/chanops.py 查看文件

@@ -6,8 +6,8 @@ from irc.base_command import BaseCommand
from config.irc_config import *

class ChanOps(BaseCommand):
def get_hook(self):
return "msg"
def get_hooks(self):
return ["msg"]

def get_help(self, command):
action = command.capitalize()


+ 2
- 2
irc/commands/git.py 查看文件

@@ -8,8 +8,8 @@ from config.irc_config import *
from irc.base_command import BaseCommand

class Git(BaseCommand):
def get_hook(self):
return "msg"
def get_hooks(self):
return ["msg"]

def get_help(self, command):
return "Commands to interface with the bot's git repository; use '!git help' for sub-command list."


+ 2
- 2
irc/commands/help.py 查看文件

@@ -7,8 +7,8 @@ from irc.data import Data
from irc import command_handler

class Help(BaseCommand):
def get_hook(self):
return "msg"
def get_hooks(self):
return ["msg"]

def get_help(self, command):
return "Generates help information."


+ 2
- 2
irc/commands/link.py 查看文件

@@ -7,8 +7,8 @@ import re
from irc.base_command import BaseCommand

class Link(BaseCommand):
def get_hook(self):
return "msg"
def get_hooks(self):
return ["msg"]

def get_help(self, command):
return "Convert a Wikipedia page name into a URL."


+ 2
- 2
irc/commands/test.py 查看文件

@@ -7,8 +7,8 @@ import random
from irc.base_command import BaseCommand

class Test(BaseCommand):
def get_hook(self):
return "msg"
def get_hooks(self):
return ["msg"]

def get_help(self, command):
return "Test the bot!"


Loading…
取消
儲存