def _ev_quit(caller): callback = caller.db._callback handler = get_event_handler() if not handler or not callback or not all(key in callback for key in ("obj", "name", "number", "valid")): caller.msg("Couldn't save this callback.") return False if (callback["obj"], callback["name"], callback["number"]) in handler.db.locked: handler.db.locked.remove((callback["obj"], callback["name"], callback["number"])) del caller.db._callback caller.msg("Exited the code editor.")
def func(self): """Command body.""" caller = self.caller lock = "perm({}) or perm(events_validating)".format(VALIDATING) validator = caller.locks.check_lockstring(caller, lock) lock = "perm({}) or perm(events_without_validation)".format( WITHOUT_VALIDATION) autovalid = caller.locks.check_lockstring(caller, lock) # First and foremost, get the callback handler and set other variables self.handler = get_event_handler() self.obj = None rhs = self.rhs or "" self.callback_name, sep, self.parameters = rhs.partition(" ") self.callback_name = self.callback_name.lower() self.is_validator = validator self.autovalid = autovalid if self.handler is None: caller.msg("The event handler is not running, can't " \ "access the event system.") return # Before the equal sign, there is an object name or nothing if self.lhs: self.obj = caller.search(self.lhs) if not self.obj: return # Switches are mutually exclusive switch = self.switches and self.switches[0] or "" if switch in ("", "add", "edit", "del") and self.obj is None: caller.msg("Specify an object's name or #ID.") return if switch == "": self.list_callbacks() elif switch == "add": self.add_callback() elif switch == "edit": self.edit_callback() elif switch == "del": self.del_callback() elif switch == "accept" and validator: self.accept_callback() elif switch in ["tasks", "task"]: self.list_tasks() else: caller.msg("Mutually exclusive or invalid switches were " \ "used, cannot proceed.")
def func(self): """Command body.""" caller = self.caller lock = "perm({}) or perm(events_validating)".format(VALIDATING) validator = caller.locks.check_lockstring(caller, lock) lock = "perm({}) or perm(events_without_validation)".format( WITHOUT_VALIDATION) autovalid = caller.locks.check_lockstring(caller, lock) # First and foremost, get the callback handler and set other variables self.handler = get_event_handler() self.obj = None rhs = self.rhs or "" self.callback_name, sep, self.parameters = rhs.partition(" ") self.callback_name = self.callback_name.lower() self.is_validator = validator self.autovalid = autovalid if self.handler is None: caller.msg("The event handler is not running, can't " "access the event system.") return # Before the equal sign, there is an object name or nothing if self.lhs: self.obj = caller.search(self.lhs) if not self.obj: return # Switches are mutually exclusive switch = self.switches and self.switches[0] or "" if switch in ("", "add", "edit", "del") and self.obj is None: caller.msg("Specify an object's name or #ID.") return if switch == "": self.list_callbacks() elif switch == "add": self.add_callback() elif switch == "edit": self.edit_callback() elif switch == "del": self.del_callback() elif switch == "accept" and validator: self.accept_callback() elif switch in ["tasks", "task"]: self.list_tasks() else: caller.msg("Mutually exclusive or invalid switches were " "used, cannot proceed.")
def _ev_quit(caller): callback = caller.db._callback handler = get_event_handler() if not handler or not callback or not all(key in callback for key in \ ("obj", "name", "number", "valid")): caller.msg("Couldn't save this callback.") return False if (callback["obj"], callback["name"], callback["number"]) in handler.db.locked: handler.db.locked.remove( (callback["obj"], callback["name"], callback["number"])) del caller.db._callback caller.msg("Exited the code editor.")
def _ev_save(caller, buf): """Save and add the callback.""" lock = "perm({}) or perm(events_without_validation)".format( WITHOUT_VALIDATION) autovalid = caller.locks.check_lockstring(caller, lock) callback = caller.db._callback handler = get_event_handler() if not handler or not callback or not all(key in callback for key in ("obj", "name", "number", "valid")): caller.msg("Couldn't save this callback.") return False if (callback["obj"], callback["name"], callback["number"]) in handler.db.locked: handler.db.locked.remove((callback["obj"], callback["name"], callback["number"])) handler.edit_callback(callback["obj"], callback["name"], callback["number"], buf, caller, valid=autovalid) return True
def _ev_save(caller, buf): """Save and add the callback.""" lock = "perm({}) or perm(events_without_validation)".format(WITHOUT_VALIDATION) autovalid = caller.locks.check_lockstring(caller, lock) callback = caller.db._callback handler = get_event_handler() if ( not handler or not callback or not all(key in callback for key in ("obj", "name", "number", "valid")) ): caller.msg("Couldn't save this callback.") return False if (callback["obj"], callback["name"], callback["number"]) in handler.db.locked: handler.db.locked.remove((callback["obj"], callback["name"], callback["number"])) handler.edit_callback( callback["obj"], callback["name"], callback["number"], buf, caller, valid=autovalid ) return True