aboutsummaryrefslogtreecommitdiff
path: root/modules/to.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-09-26 18:27:17 +0100
committerGravatar jesopo2018-09-26 18:27:17 +0100
commit51a52e2b0e54031cce5876f54d1d48c268b5441c (patch)
treea4c0e8e86c55aa701b06297d5b5a2ceebeaab60d /modules/to.py
parentAlso use docstrings to check if a command has help available, allow one-string (diff)
signature
Switch to using @Utils.hook and docstrings for event hooks
Diffstat (limited to 'modules/to.py')
-rw-r--r--modules/to.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/modules/to.py b/modules/to.py
index 8ff51ffe..2bfe410d 100644
--- a/modules/to.py
+++ b/modules/to.py
@@ -1,14 +1,7 @@
-from src import EventManager
-
-class Module(object):
- def __init__(self, bot, events, exports):
- events.on("received.message.channel").hook(self.channel_message,
- priority=EventManager.PRIORITY_HIGH)
- events.on("received.command.to").hook(self.to, min_args=2,
- help=("Relay a message to a user the next time they talk "
- "in this channel"), channel_only=True,
- usage="<username> <message>")
+from src import EventManager, ModuleManager, Utils
+class Module(ModuleManager.BaseModule):
+ @Utils.hook("received.message.channel", priority=EventManager.PRIORITY_HIGH)
def channel_message(self, event):
messages = event["channel"].get_user_setting(event["user"].get_id(),
"to", [])
@@ -18,7 +11,12 @@ class Module(object):
if messages:
event["channel"].del_user_setting(event["user"].get_id(), "to")
+ @Utils.hook("received.command.to", min_args=2, channel_only=True,
+ usage="<username> <message>")
def to(self, event):
+ """
+ Relay a message to a user the next time they talk in this channel"
+ """
target_user = event["server"].get_user(event["args_split"][0])
messages = event["target"].get_user_setting(target_user.get_id(),
"to", [])