This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/disabled_stuff/kill.py

34 lines
845 B
Python
Raw Normal View History

2013-09-18 05:44:04 +02:00
import json
2014-02-14 04:36:57 +01:00
from util import hook, textgen
2013-09-18 05:44:04 +02:00
def get_generator(_json, variables):
data = json.loads(_json)
return textgen.TextGenerator(data["templates"],
data["parts"], variables=variables)
@hook.command
2013-10-01 04:41:54 +02:00
def kill(inp, action=None, nick=None, conn=None, notice=None):
2013-09-18 05:44:04 +02:00
"""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 = {
2013-11-12 07:06:06 +01:00
"user": target
2013-09-18 05:44:04 +02:00
}
with open("plugins/data/kills.json") as f:
generator = get_generator(f.read(), variables)
# act out the message
2013-11-12 07:06:06 +01:00
action(generator.generate_string())