summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixelSergey <sergey.ichtchenko@gmail.com>2015-10-16 23:32:19 +0300
committerPixelSergey <sergey.ichtchenko@gmail.com>2015-10-16 23:32:19 +0300
commitb8ab9a2fc7a828fafb3f4009ae31355dbdaaa8d0 (patch)
tree77a8bf0e6231e330c7d95b631664eccc3a6b4e72
parent28da124088ac754354d4353054003702734d4ff7 (diff)
Added permission check, fixed negative setting
-rwxr-xr-xchatalias.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/chatalias.py b/chatalias.py
index ddc45e9..9eb8037 100755
--- a/chatalias.py
+++ b/chatalias.py
@@ -10,7 +10,7 @@
# file named "aliases". The
# file is generated if not
# present. Set values to -1
-# for unlimited values.
+# for "unlimited" setting.
from helpers import *
@@ -25,9 +25,14 @@ def safe_open_json():
@hook.command("alias", usage = "/<command> [to_alias] [alias...]", desc = "Aliases words in chat")
def on_alias_command(sender, cmd, label, args):
+
if not is_player(sender):
msg(sender, "Sorry, Console cannot alias words")
- return False
+ return True
+
+ if not sender.hasPermission("utils.alias.allowed"):
+ plugin_header(recipient = sender, name = "Chat Alias")
+ noperm(sender)
if len(args) == 0:
plugin_header(recipient = sender, name = "Chat Alias")
@@ -67,12 +72,12 @@ def on_alias_command(sender, cmd, label, args):
data = safe_open_json()
alias = " ".join(args[1:])
try:
- if len(alias) > int(data["gnl"]["max_len"]) and data["gnl"]["max_len"] > 0:
+ if len(alias) > int(data["gnl"]["max_len"]) and int(data["gnl"]["max_len"]) >= 0:
plugin_header(recipient = sender, name = "Chat Alias")
msg(sender, "Please do not alias long words/sentences.")
return True
- if len(data[str(sender.getUniqueId())]) >= int(data["gnl"]["max_entries"]) and data["gnl"]["max_entries"] > 0:
+ if len(data[str(sender.getUniqueId())]) >= int(data["gnl"]["max_entries"]) and int(data["gnl"]["max_entries"]) >= 0:
plugin_header(recipient = sender, name = "Chat Alias")
msg(sender, "You have reached the maximum amount of alias entries! Sorry!")
return True