Still buggy, will fix soon (need to go out)
This commit is contained in:
parent
b725d49c33
commit
18b90a2b2a
|
@ -2,6 +2,7 @@ from util import hook
|
||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
nick_re = re.compile(r"^[A-Za-z0-9_|.-\]\[]*$")
|
||||||
|
|
||||||
slaps = []
|
slaps = []
|
||||||
slap_items = []
|
slap_items = []
|
||||||
|
@ -16,7 +17,7 @@ with open("plugins/data/slap_items.txt") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.startswith("//"):
|
if line.startswith("//"):
|
||||||
continue
|
continue
|
||||||
items.append(line)
|
slap_items.append(line)
|
||||||
|
|
||||||
larts = ["swaps <who>'s shampoo with glue.",
|
larts = ["swaps <who>'s shampoo with glue.",
|
||||||
"installs Windows on <who>'s computer.",
|
"installs Windows on <who>'s computer.",
|
||||||
|
@ -163,7 +164,7 @@ def slap(inp, me=None, nick=None, input=None, notice=None):
|
||||||
".slap <user> -- Makes the bot slap <user>."
|
".slap <user> -- Makes the bot slap <user>."
|
||||||
inp = inp.strip()
|
inp = inp.strip()
|
||||||
|
|
||||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
if not re.match(nick_re, inp.lower()):
|
||||||
notice("Invalid username!")
|
notice("Invalid username!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ def slap(inp, me=None, nick=None, input=None, notice=None):
|
||||||
target = re.sub ('<who>', nick, random.choice(slaps))
|
target = re.sub ('<who>', nick, random.choice(slaps))
|
||||||
else:
|
else:
|
||||||
target = re.sub ('<who>', inp, random.choice(slaps))
|
target = re.sub ('<who>', inp, random.choice(slaps))
|
||||||
msg = re.sub ('<item>', random.choice(items), target)
|
msg = re.sub ('<item>', random.choice(slap_items), target)
|
||||||
me(msg)
|
me(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,7 +182,7 @@ def lart(inp, me=None, nick=None, input=None, notice=None):
|
||||||
".lart <user> -- Makes the bot LART <user>."
|
".lart <user> -- Makes the bot LART <user>."
|
||||||
inp = inp.strip()
|
inp = inp.strip()
|
||||||
|
|
||||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
if not re.match(nick_re, inp.lower()):
|
||||||
notice("Invalid username!")
|
notice("Invalid username!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ def kill(inp, me=None, nick=None, input=None, notice=None):
|
||||||
".kill <user> -- Makes the bot kill <user>."
|
".kill <user> -- Makes the bot kill <user>."
|
||||||
inp = inp.strip()
|
inp = inp.strip()
|
||||||
|
|
||||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
if not re.match(nick_re, inp.lower()):
|
||||||
notice("Invalid username!")
|
notice("Invalid username!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Reference in a new issue