Make logged_in and has_full_access async functions instead of properties
This commit is contained in:
@@ -26,15 +26,15 @@ command_handlers = {}
|
||||
|
||||
def command_handler(needs_auth=True, management_only=False, needs_admin=False, name=None):
|
||||
def decorator(func):
|
||||
def wrapper(evt):
|
||||
async def wrapper(evt):
|
||||
if management_only and not evt.is_management:
|
||||
return evt.reply(f"`{evt.command}` is a restricted command:"
|
||||
"you may only run it in management rooms.")
|
||||
elif needs_auth and not evt.sender.logged_in:
|
||||
return evt.reply("This command requires you to be logged in.")
|
||||
return await evt.reply(f"`{evt.command}` is a restricted command:"
|
||||
"you may only run it in management rooms.")
|
||||
elif needs_auth and not await evt.sender.is_logged_in():
|
||||
return await evt.reply("This command requires you to be logged in.")
|
||||
elif needs_admin and not evt.sender.is_admin:
|
||||
return evt.reply("This is command requires administrator privileges.")
|
||||
return func(evt)
|
||||
return await evt.reply("This is command requires administrator privileges.")
|
||||
return await func(evt)
|
||||
|
||||
command_handlers[name or func.__name__.replace("_", "-")] = wrapper
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user