From c69d555e90d972df5aebe0af5aa143e9a240a8a6 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Fri, 10 May 2024 19:43:14 -0500 Subject: [PATCH] Changeable auto-reply soon --- bare.py | 1 + bot.py | 5 +++++ config.py | 1 + handlers.py | 18 +++++++++++------- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bare.py b/bare.py index 3f9b65d..180242f 100644 --- a/bare.py +++ b/bare.py @@ -41,6 +41,7 @@ class bot: onJoinCmds: list[str] onStrtCmds: list[str] markov: MarkovBot + autoMethod: str def __init__(self, server: str): ... diff --git a/bot.py b/bot.py index efc781d..1433f68 100644 --- a/bot.py +++ b/bot.py @@ -72,6 +72,11 @@ class bot(bare.bot): if "onStrtCmds" in conf.servers[server] else [] ) + self.autoMethof = ( + conf.servers[server]["autoMethod"] + if "autoMethod" in conf.servers[server] + else "QUOTE" + ) self.lastfmLink = conf.lastfmLink with open("mastermessages.txt") as f: TMFeed = [] diff --git a/config.py b/config.py index 51a2e5f..eaafb98 100644 --- a/config.py +++ b/config.py @@ -45,6 +45,7 @@ servers: dict[str, dict[str, Any]] = { "admins": ["h-tl"], "hosts": ["owner.firepi"], "threads": ["radio"], + "autoMethod": "MARKOV", }, "backupbox": { "address": "127.0.0.1", diff --git a/handlers.py b/handlers.py index 3c07adc..cc6899f 100644 --- a/handlers.py +++ b/handlers.py @@ -139,13 +139,17 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str] elif kind == "ACTION ducks": bot.msg("\x01ACTION gets hit by a duck\x01", chan) if chan in bot.channels and bot.channels[chan] >= bot.interval: - r.seed() - bot.channels[chan] = 0 - with open("mastermessages.txt", "r") as mm: - sel = conf.decode_escapes( - r.sample(mm.readlines(), 1)[0].replace("\\n", "").replace("\n", "") - ) - bot.msg(f"[QUOTE] {sel}", chan) + sel = "" + if bot.autoMethod == "QUOTE": + r.seed() + bot.channels[chan] = 0 + with open("mastermessages.txt", "r") as mm: + sel = conf.decode_escapes( + r.sample(mm.readlines(), 1)[0].replace("\\n", "").replace("\n", "") + ) + else: + sel = "Markov resp" + bot.msg(f"[{bot.autoMethod}] {sel}") return None, None