From ae9d3cdd30f5834b0c88a226726281a7ce79912e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 17 Oct 2012 11:38:59 +1300 Subject: [PATCH] New slap command, I will update the rest later --- plugins/violence.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/violence.py b/plugins/violence.py index 48ad088..30c3758 100755 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -29,24 +29,22 @@ with open("plugins/data/kill_bodyparts.txt") as f: @hook.command def slap(inp, me=None, nick=None, conn=None, notice=None): "slap -- Makes the bot slap ." - target = inp.lower() - if not re.match(nick_re, target): + target = inp.strip() + + if " " in target: notice("Invalid username!") return # if the user is trying to make the bot slap itself, slap them - if target == conn.nick.lower() or target == "itself": + if target.lower() == conn.nick.lower() or target.lower() == "itself": target = nick - else: - target = inp - out = random.choice(slaps) - out = out.replace('', target) - out = out.replace('', random.choice(items)) + values = {"item": random.choice(items), "user": target} + phrase = random.choice(slaps) # act out the message - me(out) + me(phrase.format(**values)) @hook.command