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 <alekratz@gmail.com>
This commit is contained in:
@@ -104,7 +104,10 @@ class Markov(Plugin):
|
|||||||
self.handle_command(conn, channel, who, parts)
|
self.handle_command(conn, channel, who, parts)
|
||||||
elif line[0] != "!":
|
elif line[0] != "!":
|
||||||
# ignore other commands
|
# 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(
|
def handle_command(
|
||||||
self, conn: IrcProtocol, channel: str, who: Prefix, parts: Sequence[str]
|
self, conn: IrcProtocol, channel: str, who: Prefix, parts: Sequence[str]
|
||||||
|
|||||||
@@ -37,5 +37,5 @@ if __name__ == "__main__":
|
|||||||
if mat := LINE_RE.search(line):
|
if mat := LINE_RE.search(line):
|
||||||
name = mat["name"]
|
name = mat["name"]
|
||||||
message = mat["message"]
|
message = mat["message"]
|
||||||
plugin.chains[channel][name].add(message)
|
plugin.add(channel, name, message)
|
||||||
plugin.save()
|
plugin.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user