From e1e4fbf9bc5acf42419cfee206e504b0bf0bd83d Mon Sep 17 00:00:00 2001 From: jesopo Date: Sat, 26 Jan 2019 15:46:20 +0000 Subject: [PATCH] Add `find_from` to IRCBuffer.Buffer, to find the most recent line from a given user (src/IRCBuffer.py) --- src/IRCBuffer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index dd4d11ae..dee68e3a 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -58,5 +58,13 @@ class Buffer(object): continue return line return None + + def find_from(self, nickname: str) -> typing.Optional[BufferLine]: + nickname_lower = self.server.irc_lower(nickname) + for line in self.lines: + if self.server.irc_lower(line.sender) == nickname_lower: + return line + return None + def skip_next(self): self._skip_next = True