X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Fmisc.py;h=e737a287687a784e282b57113dd8797617b0664e;hp=fd4e0ac1c9185453513f00959d731484295394bf;hb=87065461784719196154b37340e6c8f76b4d801f;hpb=c7ee3d6c896f1534d8da46e973700a26b9feb706 diff --git a/mudpy/misc.py b/mudpy/misc.py index fd4e0ac..e737a28 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -184,6 +184,10 @@ class Element: prepend_padding ) + def is_admin(self): + """Boolean check whether an actor is controlled by an admin owner.""" + return(self.owner and self.owner.is_admin()) + def can_run(self, command): """Check if the user can run this command object.""" @@ -192,7 +196,7 @@ class Element: return(False) # avatars of administrators can run any command - if self.owner and self.owner.account.get("administrator"): + if self.is_admin(): return(True) # everyone can run non-administrative commands @@ -995,6 +999,10 @@ class User: avatar, 6) return avatars + def is_admin(self): + """Boolean check whether user's account is an admin.""" + return(self.account.get("administrator", False)) + def broadcast(message, add_prompt=True): """Send a message to all connected users.""" @@ -1049,9 +1057,10 @@ def log(message, level=0): # display to connected administrators for user in universe.userlist: - if user.state == "active" and user.account.get( - "administrator" - ) and user.account.get("loglevel", 0) <= level: + if ( + user.state == "active" + and user.is_admin() + and user.account.get("loglevel", 0) <= level): # iterate over every line in the message full_message = "" for line in lines: