Fix bug, set no-idle locks on bots

This commit is contained in:
Griatch 2017-08-20 23:36:36 +02:00
parent 72e3498785
commit ea87eef218
3 changed files with 14 additions and 15 deletions

View file

@ -565,8 +565,7 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
"""
# A basic security setup
lockstring = "examine:perm(Admin);edit:perm(Admin);" \
"delete:perm(Admin);boot:perm(Admin);msg:all();" \
"noidletimeout:perm(Builder) or perm(noidletimeout)"
"delete:perm(Admin);boot:perm(Admin);msg:all()"
self.locks.add(lockstring)
# The ooc account cmdset
@ -582,7 +581,8 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
"""
# set an (empty) attribute holding the characters this account has
lockstring = "attrread:perm(Admins);attredit:perm(Admins);" \
"attrcreate:perm(Admins)"
"attrcreate:perm(Admins);" \
"noidletimeout:perm(Builder) or perm(noidletimeout)"
self.attributes.add("_playable_characters", [], lockstring=lockstring)
self.attributes.add("_saved_protocol_flags", {}, lockstring=lockstring)

View file

@ -38,10 +38,6 @@ class BotStarter(DefaultScript):
self.desc = "bot start/keepalive"
self.persistent = True
self.db.started = False
if _IDLE_TIMEOUT > 0:
# call before idle_timeout triggers
self.interval = int(max(60, _IDLE_TIMEOUT * 0.90))
self.start_delay = True
def at_start(self):
"""
@ -101,8 +97,9 @@ class Bot(DefaultAccount):
"""
# the text encoding to use.
self.db.encoding = "utf-8"
# A basic security setup
lockstring = "examine:perm(Admin);edit:perm(Admin);delete:perm(Admin);boot:perm(Admin);msg:false()"
# A basic security setup (also avoid idle disconnects)
lockstring = "examine:perm(Admin);edit:perm(Admin);delete:perm(Admin);" \
"boot:perm(Admin);msg:false();noidletimeout:true()"
self.locks.add(lockstring)
# set the basics of being a bot
script_key = "%s" % self.key

View file

@ -1779,12 +1779,13 @@ class CmdLock(ObjManipCommand):
if '/' in self.lhs:
# call on the form @lock obj/access_type
objname, access_type = [p.strip() for p in self.lhs.split('/', 1)]
obj = None
if objname.startswith("*"):
obj = caller.search_account(objname.lstrip('*'))
if not obj:
obj = caller.search(objname)
if not obj:
obj = caller.search(objname)
if not obj:
return
return
if not (obj.access(caller, 'control') or obj.access(caller, "edit")):
caller.msg("You are not allowed to do that.")
return
@ -1811,12 +1812,13 @@ class CmdLock(ObjManipCommand):
return
objname, lockdef = self.lhs, self.rhs
obj = None
if objname.startswith("*"):
obj = caller.search_account(objname.lstrip('*'))
if not obj:
obj = caller.search(objname)
if not obj:
obj = caller.search(objname)
if not obj:
return
return
if not (obj.access(caller, 'control') or obj.access(caller, "edit")):
caller.msg("You are not allowed to do that.")
return