diff options
| author | 2019-02-12 16:50:11 +0000 | |
|---|---|---|
| committer | 2019-02-12 16:50:11 +0000 | |
| commit | 0e1535a88d6def52fe4a6b6f46c909883063a21d (patch) | |
| tree | 519dd360fa82c3b9dd94a8b6f869a4cb673cc3f8 /modules/line_handler.py | |
| parent | Refactor how CTCPs are sent through events (diff) | |
| signature | ||
Definte `channel` before trying to use it for event hook constuction
(line_handler.py)
Diffstat (limited to 'modules/line_handler.py')
| -rw-r--r-- | modules/line_handler.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/line_handler.py b/modules/line_handler.py index 4706e367..8cf6f20d 100644 --- a/modules/line_handler.py +++ b/modules/line_handler.py @@ -526,6 +526,10 @@ class Module(ModuleManager.BaseModule): if "prefix" in event: user = event["server"].get_user(event["prefix"].nickname) + channel = None + if target[0] in event["server"].channel_types: + channel = event["server"].channels.get(target) + direction = "send" if from_self else "received" context = "channel" if channel else "private" hook = self.events.on(direction).on("notice").on(context) @@ -533,8 +537,7 @@ class Module(ModuleManager.BaseModule): kwargs = {"message": message, "message_split": message_split, "server": event["server"], "tags": event["tags"]} - if target[0] in event["server"].channel_types: - channel = event["server"].channels.get(target) + if channel: hook.call(user=user, channel=channel, **kwargs) channel.buffer.add_notice(user.nickname, message, event["tags"], user==None) |
