Definte channel
before trying to use it for event hook constuction
(line_handler.py)
This commit is contained in:
parent
938495fc3a
commit
0e1535a88d
1 changed files with 5 additions and 2 deletions
|
@ -526,6 +526,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
if "prefix" in event:
|
if "prefix" in event:
|
||||||
user = event["server"].get_user(event["prefix"].nickname)
|
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"
|
direction = "send" if from_self else "received"
|
||||||
context = "channel" if channel else "private"
|
context = "channel" if channel else "private"
|
||||||
hook = self.events.on(direction).on("notice").on(context)
|
hook = self.events.on(direction).on("notice").on(context)
|
||||||
|
@ -533,8 +537,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
kwargs = {"message": message, "message_split": message_split,
|
kwargs = {"message": message, "message_split": message_split,
|
||||||
"server": event["server"], "tags": event["tags"]}
|
"server": event["server"], "tags": event["tags"]}
|
||||||
|
|
||||||
if target[0] in event["server"].channel_types:
|
if channel:
|
||||||
channel = event["server"].channels.get(target)
|
|
||||||
hook.call(user=user, channel=channel, **kwargs)
|
hook.call(user=user, channel=channel, **kwargs)
|
||||||
channel.buffer.add_notice(user.nickname, message, event["tags"],
|
channel.buffer.add_notice(user.nickname, message, event["tags"],
|
||||||
user==None)
|
user==None)
|
||||||
|
|
Loading…
Reference in a new issue