aboutsummaryrefslogtreecommitdiff
path: root/modules/sed.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-08-31 12:55:52 +0100
committerGravatar jesopo2018-08-31 12:55:52 +0100
commit9874f79b498e1f8ae5ebec9a240963e908b645b0 (patch)
treed5d887ac82f3e50f0ea295953981363c1c5e7c5a /modules/sed.py
parentMerge pull request #7 from dngfx/master (diff)
signature
Give modules event objects with "context"s, to facilitate purging all the event
hooks for a module
Diffstat (limited to 'modules/sed.py')
-rw-r--r--modules/sed.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/sed.py b/modules/sed.py
index 5c2d7ea4..c276d4d1 100644
--- a/modules/sed.py
+++ b/modules/sed.py
@@ -5,16 +5,17 @@ REGEX_SPLIT = re.compile("(?<!\\\\)/")
REGEX_SED = re.compile("^s/")
class Module(object):
- def __init__(self, bot):
+ def __init__(self, bot, events):
self.bot = bot
- bot.events.on("received").on("message").on("channel").hook(
+ self.events = events
+ events.on("received").on("message").on("channel").hook(
self.channel_message)
- bot.events.on("postboot").on("configure").on(
+ events.on("postboot").on("configure").on(
"channelset").assure_call(setting="sed",
help="Disable/Enable sed in a channel",
validate=Utils.bool_or_none)
- bot.events.on("postboot").on("configure").on(
+ events.on("postboot").on("configure").on(
"channelset").assure_call(setting="sed-sender-only",
help="Disable/Enable sed only looking at the messages "
"sent by the user", validate=Utils.bool_or_none)
@@ -49,7 +50,7 @@ class Module(object):
pattern = re.compile(sed_split[1], regex_flags)
except:
traceback.print_exc()
- self.bot.events.on("send").on("stderr").call(target=event[
+ self.events.on("send").on("stderr").call(target=event[
"channel"], module_name="Sed", server=event["server"],
message="Invalid regex in pattern")
return
@@ -66,6 +67,6 @@ class Module(object):
prefix = "* %s" % line.sender
else:
prefix = "<%s>" % line.sender
- self.bot.events.on("send").on("stdout").call(target=event[
+ self.events.on("send").on("stdout").call(target=event[
"channel"], module_name="Sed", server=event["server"],
message="%s %s" % (prefix, new_message))