From ea87eef218eadb30c3f6f3dbb2ec150f4e61cc8e Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 20 Aug 2017 23:36:36 +0200 Subject: [PATCH] Fix bug, set no-idle locks on bots --- evennia/accounts/accounts.py | 6 +++--- evennia/accounts/bots.py | 9 +++------ evennia/commands/default/building.py | 14 ++++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index 4fe654a965..028b517d98 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -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) diff --git a/evennia/accounts/bots.py b/evennia/accounts/bots.py index 642673bef9..817b6e2f17 100644 --- a/evennia/accounts/bots.py +++ b/evennia/accounts/bots.py @@ -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 diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 06da867ced..33c217e6b7 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -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