tidy up IRCBuffer.find, respect line.deleted there too

This commit is contained in:
jesopo 2020-01-17 14:27:37 +00:00
parent 5d9bbed0fa
commit a79f866269

View file

@ -49,12 +49,13 @@ class Buffer(object):
for line in self._lines:
yield line
def find(self, pattern: typing.Union[str, typing.Pattern[str]], **kwargs
def find(self, pattern: typing.Union[str, typing.Pattern[str]],
not_pattern: typing.Union[str, typing.Pattern[str]],
from_self=True, for_user: str=None, deleted=False
) -> typing.Optional[BufferLineMatch]:
from_self = kwargs.get("from_self", True)
for_user = kwargs.get("for_user", "")
for_user = self.server.irc_lower(for_user) if for_user else None
not_pattern = kwargs.get("not_pattern", None)
if for_user:
for_user = self.server.irc_lower(for_user)
for line in self._lines:
if line.from_self and not from_self:
continue
@ -66,6 +67,8 @@ class Buffer(object):
if for_user and not self.server.irc_lower(line.sender
) == for_user:
continue
if line.deleted and not deleted:
continue
return BufferLineMatch(line, match.group(0))
return None