From 9118af5e9c9c0e80507fd2bc8bc6cd840fad2c2f Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 2 Oct 2018 21:40:34 +0100 Subject: Support changing command responses from PRIVMSG to NOTICE --- src/IRCBuffer.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/IRCBuffer.py') diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index b3825178..f5e6fa70 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -2,12 +2,13 @@ import re from . import Utils class BufferLine(object): - def __init__(self, sender, message, action, tags, from_self): + def __init__(self, sender, message, action, tags, from_self, method): self.sender = sender self.message = message self.action = action self.tags = tags self.from_self = from_self + self.method = method class Buffer(object): def __init__(self, bot, server): @@ -16,13 +17,19 @@ class Buffer(object): self.lines = [] self.max_lines = 64 self._skip_next = False - def add_line(self, sender, message, action, tags, from_self=False): + + def _add_message(self, sender, message, action, tags, from_self, method): if not self._skip_next: - line = BufferLine(sender, message, action, tags, from_self) + line = BufferLine(sender, message, action, tags, from_self, method) self.lines.insert(0, line) if len(self.lines) > self.max_lines: self.lines.pop() self._skip_next = False + def add_message(self, sender, message, action, tags, from_self=False): + self._add_message(sender, message, action, tags, from_self, "PRIVMSG") + def add_notice(self, sender, message, tags, from_self=False): + self._add_message(sender, message, False, tags, from_self, "NOTICE") + def get(self, index=0, **kwargs): from_self = kwargs.get("from_self", True) for line in self.lines: -- cgit v1.3.1-10-gc9f91