Quellcode durchsuchen

commands now support multiple hooks

tags/v0.1
Ben Kurtovic vor 13 Jahren
Ursprung
Commit
eee571879c
7 geänderte Dateien mit 14 neuen und 14 gelöschten Zeilen
  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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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!"


Laden…
Abbrechen
Speichern