Cleaned up flirt, kill, lart, and slap.py

This commit is contained in:
neersighted 2012-03-05 20:53:45 -08:00
parent fb304bf970
commit 59628292c1
4 changed files with 24 additions and 21 deletions

View file

@ -47,9 +47,16 @@ flirts = ["I bet your name's Mickey, 'cause you're so fine.",
@hook.command(autohelp=False)
def flirt(inp, nick=None, me=None, input=None):
".flirt <user> -- Make the bot flirt with <user>."
msg = "flirts with " + nick + "... \"" + random.choice(flirts) + "\""
if re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()) and inp != "":
msg = "flirts with " + inp + "... \"" + random.choice(flirts) + "\""
inp = inp.strip()
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
notice("Invalid username!")
return
target = nick
if inp.lower() and inp != "":
target = inp
if inp == input.conn.nick.lower() or inp == "itself":
msg = "flirts with itself... \"" + random.choice(flirts) + "\""
target = "itself"
msg = "flirts with " + target + "... \"" + random.choice(flirts) + "\""
me(msg)

View file

@ -42,12 +42,12 @@ def kill(inp, me=None, nick=None, input=None, notice=None):
return
if inp == input.conn.nick.lower() or inp == "itself":
kill = random.choice(kills)
kill = re.sub ('<who>', nick, kill)
msg = re.sub ('<body>', random.choice(body), kill)
target = random.choice(kills)
target = re.sub ('<who>', nick, target)
target = re.sub ('<body>', random.choice(body), target)
else:
kill = random.choice(kills)
kill = re.sub ('<who>', inp, kill)
msg = re.sub ('<body>', random.choice(body), kill)
target = random.choice(kills)
target = re.sub ('<who>', inp, target)
target = re.sub ('<body>', random.choice(body), target)
msg = target
me(msg)

View file

@ -119,8 +119,8 @@ def lart(inp, me=None, nick=None, input=None, notice=None):
return
if inp == input.conn.nick.lower() or inp == "itself":
msg = re.sub ('<who>', nick, random.choice(larts))
target = nick
else:
msg = re.sub ('<who>', inp, random.choice(larts))
target = inp
msg = re.sub ('<who>', target, random.choice(larts))
me(msg)

View file

@ -45,12 +45,8 @@ def slap(inp, me=None, nick=None, input=None, notice=None):
return
if inp == input.conn.nick.lower() or inp == "itself":
slap = random.choice(slaps)
slap = re.sub ('<who>', nick, slap)
msg = re.sub ('<item>', random.choice(items), slap)
target = re.sub ('<who>', nick, random.choice(slaps))
else:
slap = random.choice(slaps)
slap = re.sub ('<who>', inp, slap)
msg = re.sub ('<item>', random.choice(items), slap)
target = re.sub ('<who>', inp, random.choice(slaps))
msg = re.sub ('<item>', random.choice(items), target)
me(msg)