From 85d48d368ce8e5b0d2e0d6e2180d40a920658372 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Wed, 25 May 2022 19:18:37 -0700 Subject: [PATCH] Add Markov.add function This is basically just a shorthand, but also abstracts away adding a line to a markov chain Signed-off-by: Alek Ratzloff --- plugins/markov.py | 5 ++++- tools/markov_import.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/markov.py b/plugins/markov.py index 71f3c96..ae6fc53 100644 --- a/plugins/markov.py +++ b/plugins/markov.py @@ -104,7 +104,10 @@ class Markov(Plugin): self.handle_command(conn, channel, who, parts) elif line[0] != "!": # ignore other commands - self.chains[channel][who.nick].add(line) + self.add(channel, who.nick, line) + + def add(self, channel: str, who: str, line: str): + self.chains[channel][who].add(line) def handle_command( self, conn: IrcProtocol, channel: str, who: Prefix, parts: Sequence[str] diff --git a/tools/markov_import.py b/tools/markov_import.py index 2515194..5e9a192 100644 --- a/tools/markov_import.py +++ b/tools/markov_import.py @@ -37,5 +37,5 @@ if __name__ == "__main__": if mat := LINE_RE.search(line): name = mat["name"] message = mat["message"] - plugin.chains[channel][name].add(message) + plugin.add(channel, name, message) plugin.save()