Added code to preprocess check a command that only requires authentication, not

a permission
This commit is contained in:
jesopo 2018-08-18 18:28:41 +01:00
parent 054a98c0c8
commit 4da8a4ac39

View file

@ -87,6 +87,7 @@ class Module(object):
def preprocess_command(self, event): def preprocess_command(self, event):
permission = event["hook"].kwargs.get("permission", None) permission = event["hook"].kwargs.get("permission", None)
authenticated = event["hook"].kwargs.get("authenticated", False)
if permission: if permission:
identified = event["user"].identified identified = event["user"].identified
user_permissions = event["user"].get_setting("permissions", []) user_permissions = event["user"].get_setting("permissions", [])
@ -94,6 +95,9 @@ class Module(object):
permission in user_permissions or "*" in user_permissions) permission in user_permissions or "*" in user_permissions)
if not identified or not has_permission: if not identified or not has_permission:
return "You do not have permission to do that" return "You do not have permission to do that"
elif authenticated:
if not event["user"].identified:
return "You need to be identified to use that command"
def my_permissions(self, event): def my_permissions(self, event):
permissions = event["user"].get_setting("permissions", []) permissions = event["user"].get_setting("permissions", [])