Make logged_in and has_full_access async functions instead of properties

This commit is contained in:
Tulir Asokan
2018-06-22 12:45:19 +03:00
parent 42056b91c5
commit d466060c44
10 changed files with 50 additions and 50 deletions
+7 -7
View File
@@ -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