2012-02-29 08:31:42 +01:00
|
|
|
from util import hook
|
|
|
|
import re
|
|
|
|
import random
|
|
|
|
|
2012-04-16 04:12:32 +02:00
|
|
|
nick_re = re.compile(r"^[A-Za-z0-9_|\.\-\]\[]*$")
|
2012-03-06 19:14:26 +01:00
|
|
|
|
|
|
|
|
2012-03-26 07:32:20 +02:00
|
|
|
with open("plugins/data/larts.txt") as f:
|
2012-05-09 21:54:30 +02:00
|
|
|
larts = [line.strip() for line in f.readlines()
|
|
|
|
if not line.startswith("//")]
|
2012-03-26 07:32:20 +02:00
|
|
|
|
2012-03-26 06:28:22 +02:00
|
|
|
with open("plugins/data/slaps.txt") as f:
|
2012-05-09 21:54:30 +02:00
|
|
|
slaps = [line.strip() for line in f.readlines()
|
2012-05-09 23:18:51 +02:00
|
|
|
if not line.startswith("//")]
|
2012-03-26 06:28:22 +02:00
|
|
|
|
|
|
|
with open("plugins/data/slap_items.txt") as f:
|
2012-05-09 23:18:51 +02:00
|
|
|
items = [line.strip() for line in f.readlines()
|
|
|
|
if not line.startswith("//")]
|
2012-03-06 19:14:26 +01:00
|
|
|
|
2012-03-26 07:32:20 +02:00
|
|
|
with open("plugins/data/kills.txt") as f:
|
2012-05-09 21:54:30 +02:00
|
|
|
kills = [line.strip() for line in f.readlines()
|
|
|
|
if not line.startswith("//")]
|
2012-03-26 07:32:20 +02:00
|
|
|
|
|
|
|
with open("plugins/data/kill_bodyparts.txt") as f:
|
2012-05-09 23:18:51 +02:00
|
|
|
parts = [line.strip() for line in f.readlines()
|
|
|
|
if not line.startswith("//")]
|
2012-03-06 19:14:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
@hook.command
|
2012-03-26 07:11:22 +02:00
|
|
|
def slap(inp, me=None, nick=None, conn=None, notice=None):
|
2012-05-16 05:07:27 +02:00
|
|
|
"slap <user> -- Makes the bot slap <user>."
|
2012-03-26 07:11:22 +02:00
|
|
|
target = inp.lower()
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
if not re.match(nick_re, target):
|
2012-03-06 19:14:26 +01:00
|
|
|
notice("Invalid username!")
|
|
|
|
return
|
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
# if the user is trying to make the bot slap itself, slap them
|
|
|
|
if target == conn.nick.lower() or target == "itself":
|
|
|
|
target = nick
|
2012-03-06 19:14:26 +01:00
|
|
|
else:
|
2012-03-26 07:11:22 +02:00
|
|
|
target = inp
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
out = random.choice(slaps)
|
|
|
|
out = out.replace('<who>', target)
|
2012-05-09 23:18:51 +02:00
|
|
|
out = out.replace('<item>', random.choice(items))
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
# act out the message
|
|
|
|
me(out)
|
2012-03-06 19:14:26 +01:00
|
|
|
|
|
|
|
|
2012-02-29 08:31:42 +01:00
|
|
|
@hook.command
|
2012-03-26 07:11:22 +02:00
|
|
|
def lart(inp, me=None, nick=None, conn=None, notice=None):
|
2012-05-16 05:07:27 +02:00
|
|
|
"lart <user> -- LARTs <user>."
|
2012-03-26 07:11:22 +02:00
|
|
|
target = inp.lower()
|
2012-02-29 08:31:42 +01:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
if not re.match(nick_re, target):
|
2012-02-29 08:31:42 +01:00
|
|
|
notice("Invalid username!")
|
|
|
|
return
|
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
if target == conn.nick.lower() or target == "itself":
|
2012-03-06 05:53:45 +01:00
|
|
|
target = nick
|
2012-02-29 08:31:42 +01:00
|
|
|
else:
|
2012-03-06 05:53:45 +01:00
|
|
|
target = inp
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
out = random.choice(larts)
|
|
|
|
out = out.replace('<who>', target)
|
2012-05-09 23:18:51 +02:00
|
|
|
out = out.replace('<item>', random.choice(items))
|
2012-03-26 07:11:22 +02:00
|
|
|
me(out)
|
2012-03-06 19:14:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
@hook.command
|
2012-03-26 07:11:22 +02:00
|
|
|
def kill(inp, me=None, nick=None, conn=None, notice=None):
|
2012-05-16 05:07:27 +02:00
|
|
|
"kill <user> -- Makes the bot kill <user>."
|
2012-03-26 07:11:22 +02:00
|
|
|
target = inp.lower()
|
2012-03-06 19:14:26 +01:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
if not re.match(nick_re, target):
|
2012-03-06 19:14:26 +01:00
|
|
|
notice("Invalid username!")
|
|
|
|
return
|
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
if target == conn.nick.lower() or target == "itself":
|
2012-03-06 19:14:26 +01:00
|
|
|
target = nick
|
2012-03-06 19:17:49 +01:00
|
|
|
else:
|
|
|
|
target = inp
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-03-26 07:11:22 +02:00
|
|
|
out = random.choice(kills)
|
|
|
|
out = out.replace('<who>', target)
|
2012-05-09 23:18:51 +02:00
|
|
|
out = out.replace('<body>', random.choice(parts))
|
2012-03-26 07:11:22 +02:00
|
|
|
me(out)
|