mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-24 03:04:05 +01:00
utils: return the bound function in add_cmd/add_hook
TODO: allow utils.add_cmd/add_hook to be called as a decorator WITH a name argument
This commit is contained in:
parent
cecb7f3800
commit
b3ab604b88
5
utils.py
5
utils.py
@ -104,15 +104,18 @@ class TS6SIDGenerator():
|
|||||||
return sid
|
return sid
|
||||||
|
|
||||||
def add_cmd(func, name=None):
|
def add_cmd(func, name=None):
|
||||||
|
"""Binds a command to the given command name."""
|
||||||
if name is None:
|
if name is None:
|
||||||
name = func.__name__
|
name = func.__name__
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
world.commands[name].append(func)
|
world.commands[name].append(func)
|
||||||
|
return func
|
||||||
|
|
||||||
def add_hook(func, command):
|
def add_hook(func, command):
|
||||||
"""Add a hook <func> for command <command>."""
|
"""Binds a hook function to the given command."""
|
||||||
command = command.upper()
|
command = command.upper()
|
||||||
world.hooks[command].append(func)
|
world.hooks[command].append(func)
|
||||||
|
return func
|
||||||
|
|
||||||
def toLower(irc, text):
|
def toLower(irc, text):
|
||||||
"""Returns a lowercase representation of text based on the IRC object's
|
"""Returns a lowercase representation of text based on the IRC object's
|
||||||
|
Loading…
Reference in New Issue
Block a user