chainsol

evennia_decryption_lockfunc.py

Mar 6th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. # lockfuncs.py
  2. def decrypt(accessor, target, *args, **kwargs):
  3.     if args: # we've been provided a password
  4.         password = args[0]
  5.         if hasattr(accessor, "db"):
  6.             # first we check if the accessing object has the password for the target
  7.             if type(accessor.db.__channel_passwords) is dict:
  8.                 password_matches = accessor.db.__channel_passwords.get(target) == password
  9.             else:
  10.                 accessor.db.__channel_passwords = {}
  11.                 password_matches = False
  12.             # next we'll see if they pass a skill check
  13.             # assuming Ainneve-style skills - please replace with whatever works
  14.             if not hasattr(accessor, "skills"): # just in case we don't have a skills attribute
  15.                 return password_matches
  16.             return password_matches or accessor.skills.decryption > 5
  17.         else: # we don't have a typeclassed object
  18.             return False
  19.     else: # we don't have a password on this message
  20.         return True
Advertisement
Add Comment
Please, Sign In to add comment