tidy up IRCBuffer.find, respect line.deleted there too
This commit is contained in:
parent
5d9bbed0fa
commit
a79f866269
1 changed files with 8 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue