I'm a fucking idiot

This commit is contained in:
Luke Rogers 2013-09-18 15:44:04 +12:00
parent 5b1258f544
commit 348de62f17

32
plugins/kill.py Normal file
View file

@ -0,0 +1,32 @@
from util import hook, textgen
import json
def get_generator(_json, variables):
data = json.loads(_json)
return textgen.TextGenerator(data["templates"],
data["parts"], variables=variables)
@hook.command
def kill(inp, me=None, nick=None, conn=None, notice=None):
"""kill <user> -- Makes the bot kill <user>."""
target = inp.strip()
if " " in target:
notice("Invalid username!")
return
# if the user is trying to make the bot kill itself, kill them
if target.lower() == conn.nick.lower() or target.lower() == "itself":
target = nick
variables = {
"user": target
}
with open("plugins/data/kills.json") as f:
generator = get_generator(f.read(), variables)
# act out the message
me(generator.generate_string())