Changeable auto-reply soon

This commit is contained in:
Firepup Sixfifty 2024-05-10 19:43:14 -05:00
parent c90df959d5
commit c69d555e90
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
4 changed files with 18 additions and 7 deletions

View file

@ -41,6 +41,7 @@ class bot:
onJoinCmds: list[str] onJoinCmds: list[str]
onStrtCmds: list[str] onStrtCmds: list[str]
markov: MarkovBot markov: MarkovBot
autoMethod: str
def __init__(self, server: str): ... def __init__(self, server: str): ...

5
bot.py
View file

@ -72,6 +72,11 @@ class bot(bare.bot):
if "onStrtCmds" in conf.servers[server] if "onStrtCmds" in conf.servers[server]
else [] else []
) )
self.autoMethof = (
conf.servers[server]["autoMethod"]
if "autoMethod" in conf.servers[server]
else "QUOTE"
)
self.lastfmLink = conf.lastfmLink self.lastfmLink = conf.lastfmLink
with open("mastermessages.txt") as f: with open("mastermessages.txt") as f:
TMFeed = [] TMFeed = []

View file

@ -45,6 +45,7 @@ servers: dict[str, dict[str, Any]] = {
"admins": ["h-tl"], "admins": ["h-tl"],
"hosts": ["owner.firepi"], "hosts": ["owner.firepi"],
"threads": ["radio"], "threads": ["radio"],
"autoMethod": "MARKOV",
}, },
"backupbox": { "backupbox": {
"address": "127.0.0.1", "address": "127.0.0.1",

View file

@ -139,13 +139,17 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
elif kind == "ACTION ducks": elif kind == "ACTION ducks":
bot.msg("\x01ACTION gets hit by a duck\x01", chan) bot.msg("\x01ACTION gets hit by a duck\x01", chan)
if chan in bot.channels and bot.channels[chan] >= bot.interval: if chan in bot.channels and bot.channels[chan] >= bot.interval:
r.seed() sel = ""
bot.channels[chan] = 0 if bot.autoMethod == "QUOTE":
with open("mastermessages.txt", "r") as mm: r.seed()
sel = conf.decode_escapes( bot.channels[chan] = 0
r.sample(mm.readlines(), 1)[0].replace("\\n", "").replace("\n", "") with open("mastermessages.txt", "r") as mm:
) sel = conf.decode_escapes(
bot.msg(f"[QUOTE] {sel}", chan) r.sample(mm.readlines(), 1)[0].replace("\\n", "").replace("\n", "")
)
else:
sel = "Markov resp"
bot.msg(f"[{bot.autoMethod}] {sel}")
return None, None return None, None