diff --git a/modules/commands/__init__.py b/modules/commands/__init__.py index 71013c38..5a750a9b 100644 --- a/modules/commands/__init__.py +++ b/modules/commands/__init__.py @@ -315,7 +315,8 @@ class Module(ModuleManager.BaseModule): self.command(event["server"], event["channel"], event["target_str"], True, event["user"], command, args_split, event["line"], hook, - command_prefix=command_prefix) + command_prefix=command_prefix, + buffer_line=event["buffer_line"]) else: self.events.on("unknown.command").call(server=event["server"], target=event["channel"], user=event["user"], @@ -336,7 +337,8 @@ class Module(ModuleManager.BaseModule): event["target_str"], True, event["user"], command, "", event["line"], hook, match=match, message=event["message"], command_prefix="", - action=event["action"]) + action=event["action"], + buffer_line=event["buffer_line"]) if res: break @@ -365,7 +367,8 @@ class Module(ModuleManager.BaseModule): if hook: self.command(event["server"], event["user"], event["user"].nickname, False, event["user"], command, - args_split, event["line"], hook, command_prefix="") + args_split, event["line"], hook, command_prefix="", + buffer_line=event["buffer_line"]) else: self.events.on("unknown.command").call(server=event["server"], target=event["user"], user=event["user"], command=command, diff --git a/modules/line_handler/message.py b/modules/line_handler/message.py index f0053866..ae16a1f6 100644 --- a/modules/line_handler/message.py +++ b/modules/line_handler/message.py @@ -91,17 +91,20 @@ def message(events, event): hook = events.on(direction).on(event_type).on(context) if is_channel: - hook.call(channel=target_obj, **kwargs) + buffer_line = None if message: - target_obj.buffer.add_message(user.nickname, message, action, - event["line"].tags, from_self) + buffer_line = target_obj.buffer.add_message(user.nickname, message, + action, event["line"].tags, from_self) + hook.call(channel=target_obj, buffer_line=buffer_line, **kwargs) else: - hook.call(**kwargs) buffer_obj = target_obj if not from_self: buffer_obj = user + buffer_line = None if message: - buffer_obj.buffer.add_message(user.nickname, message, action, - event["line"].tags, from_self) + buffer_line = buffer_obj.buffer.add_message(user.nickname, message, + action, event["line"].tags, from_self) + + hook.call(buffer_line=buffer_line, **kwargs) diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index f30b13ca..f1ad0888 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -24,20 +24,20 @@ class Buffer(object): self.server = server self._lines = collections.deque(maxlen=MAX_LINES ) # type: typing.Deque[BufferLine] - self._skip_next = False def _add_message(self, sender: str, message: str, action: bool, tags: dict, - from_self: bool, method: str): - if not self._skip_next: - line = BufferLine(sender, message, action, tags, from_self, method) - self._lines.appendleft(line) - self._skip_next = False + from_self: bool, method: str) -> BufferLine: + line = BufferLine(sender, message, action, tags, from_self, method) + self._lines.appendleft(line) + return line def add_message(self, sender: str, message: str, action: bool, tags: dict, - from_self: bool=False): - self._add_message(sender, message, action, tags, from_self, "PRIVMSG") + from_self: bool=False) -> BufferLine: + return self._add_message(sender, message, action, tags, from_self, + "PRIVMSG") def add_notice(self, sender: str, message: str, tags: dict, from_self: bool=False): - self._add_message(sender, message, False, tags, from_self, "NOTICE") + return self._add_message(sender, message, False, tags, from_self, + "NOTICE") def get(self, index: int=0, **kwargs) -> typing.Optional[BufferLine]: from_self = kwargs.get("from_self", True) @@ -83,6 +83,3 @@ class Buffer(object): if len(found_lines) == max: break return found_lines - - def skip_next(self): - self._skip_next = True