minerbot2/plugins/fuckup.py

45 lines
1.6 KiB
Python

"""Fuckup counter - like MumboJumbo's spoon counter but I call them fuckups."""
from random import choice
from dictdata import DictData
from bot import IRCLine
BOT = None
def respond(event,msg,prefix_msg=True):
target = event.target
prefix = ""
if event.target.startswith("#"):
prefix = event.hostmask.nick+": "
else:
target = event.hostmask.nick
if not prefix_msg: prefix=""
BOT.socket.send(IRCLine("PRIVMSG",target,":"+prefix+msg))
fuckups = DictData("fuckups.json",v=["using badger commands in #meta because I thought it was #bots","forgetting how xfnw's bots in #chaos work","sending admin error messages to #meta unconditionally even though realistically it should be wherever the command was ran"])
fuckup_list_masters=["khuxkm!khuxkm@fuckup.club","xfnw!xfnw@foxy.noises"]
def on_fuckups(event):
if event.parts:
if event.parts[0]=="add":
if event.hostmask not in fuckup_list_masters:
respond(event,"You're not allowed to add fuckups to the fuckup counter. (bug k\x02\x03\x02huxkm to add you to the list if you need to be)")
return
fuckups.load(fuckups.filename)
fuckups.value["v"].append(" ".join(event.parts[1:]))
fuckups.save(fuckups.filename)
respond(event,"Added!")
if event.parts[0]=="random":
fuckup = random.choice(list(fuckups))
num = fuckups.index(fuckup)+1
respond(event,f"Fuckup {num!s}: {fuckup}")
return
respond(event,"k\x02\x03\x02huxkm has recorded {} fuckups".format(len(fuckups["v"])))
def privmsg(event): fuckups.save(fuckups.filename)
def register(bot):
global BOT
BOT=bot
bot.event_manager.on("command_fuckups",on_fuckups)
bot.event_manager.on("privmsg",privmsg)