[Turn off line numbering]1: arg template, method, @type; 2: var cmd, types, count, x; 3: 4: (> .perms(sender()) <); 5: [(type ?= 'local)] = type; 6: if ("*" in template) 7: throw(~invcmd, "Invalid command, command templates cannot contain \"*\"!."); 8: cmd = (> $command_lib.validate_command_template(template) <); 9: if (!(type in ['local, 'remote])) 10: throw(~type, "Command types can be either 'local or 'remote"); 11: if ('this in cmd[2].values().slice(1)) 12: type = 'remote; 13: if (type == 'remote) { 14: for x in (cmd[2].values().slice(1)) { 15: if (x == 'this) 16: count++; 17: } 18: if (!count) 19: throw(~add_command, "Command type defined as remote with no <this> argument."); 20: else if (count > 1) 21: throw(~add_command, "More than one <this> argument specified in template."); 22: } 23: if (!get_var(type)) 24: set_var(type, #[]); 25: set_var(type, get_var(type).setadd_elem(cmd[1][1], [@cmd[1], template, method, cmd[2]])); 26: if (type == 'remote) 27: $remote_cache.add_remote_command(cmd[1][1], this()); 28: else if (.command_modules() || filter x in (parents()) where ('general_cache in x.flags())) 29: (| .cache_client_init() |);
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit