From 44644dcd56f297ebe97f7dd03ad27bafaf69181e Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 17 Jan 2020 14:19:46 +0000 Subject: [PATCH] allow BufferLines to be marked as deleted --- src/IRCBuffer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index dbd59b3b..a1000f7f 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -14,6 +14,7 @@ class BufferLine(object): method: str notes: typing.Dict[str, str] = dataclasses.field( default_factory=dict) + deleted: bool=False class BufferLineMatch(object): def __init__(self, line: BufferLine, match: str): @@ -30,11 +31,13 @@ class Buffer(object): def add(self, line: BufferLine): self._lines.appendleft(line) - def get(self, index: int=0, **kwargs) -> typing.Optional[BufferLine]: - from_self = kwargs.get("from_self", True) + def get(self, index: int=0, from_self=True, deleted=False + ) -> typing.Optional[BufferLine]: for line in self._lines: if line.from_self and not from_self: continue + if line.deleted and not deleted: + continue return line return None def get_all(self, for_user: typing.Optional[str]=None):