Prevent chained aliases in chatalias #43
34
chatalias.py
34
chatalias.py
@ -179,8 +179,9 @@ def add(sender, args):
|
|||||||
msg(sender, "&cCould not create alias: Max_limit reached!")
|
msg(sender, "&cCould not create alias: Max_limit reached!")
|
||||||
return True
|
return True
|
||||||
args = [args[0]] + [" ".join(args[1:])]
|
args = [args[0]] + [" ".join(args[1:])]
|
||||||
data[str(uid(sender))][str(args[0])] = args[1]
|
if not add_alias_data(uid(sender), str(args[0]), args[1]):
|
||||||
save_data(uid(sender))
|
msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times"
|
||||||
|
return True
|
||||||
msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
|
msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -203,14 +204,37 @@ def radd(sender, args):
|
|||||||
return True
|
return True
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
args += ["true"]
|
args += ["true"]
|
||||||
data[str(uid(target))][str(args[1])] = str(args[2])
|
if not add_alias_data(uid(target), str(args[1]), str(args[2])):
|
||||||
save_data(uid(target))
|
message = colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times"
|
||||||
|
msg(sender, message)
|
||||||
|
if args[3].lower() == "false":
|
||||||
|
msg(target, message)
|
||||||
|
return True
|
||||||
msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
||||||
if args[3].lower() == "false":
|
if args[3].lower() == "false":
|
||||||
msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def add_alias_data(puuid, aliased, new_alias):
|
||||||
|
prior = data[puuid]
|
||||||
|
|
||||||
|
# prevent 2 -> 3 if there is 1 -> 2
|
||||||
|
if aliased not in prior:
|
||||||
|
for alias in prior.values():
|
||||||
|
if aliased in alias:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# prevent 1 -> 2 if there is 2 -> 3
|
||||||
|
for sequence in prior:
|
||||||
|
if sequence in new alias:
|
||||||
|
return False
|
||||||
|
|
||||||
|
prior[aliased] = new_alias
|
||||||
|
save_data(puuid)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def remove(sender, args):
|
def remove(sender, args):
|
||||||
plugin_header(sender, "Alias")
|
plugin_header(sender, "Alias")
|
||||||
try:
|
try:
|
||||||
@ -334,5 +358,3 @@ remotes = {
|
|||||||
"remove": rremove,
|
"remove": rremove,
|
||||||
"list": rlist_alias,
|
"list": rlist_alias,
|
||||||
}
|
}
|
||||||
Status API Training Shop Blog About
|
|
||||||
© 2016 GitHub, Inc. Terms Privacy Security Contact Help
|
|
Reference in New Issue
Block a user