[Turn on line numbering]
arg template, method, @type;
var cmd, types, count, x;
(> .perms(sender()) <);
[(type ?= 'local)] = type;
if ("*" in template)
throw(~invcmd, "Invalid command, command templates cannot contain \"*\"!.");
cmd = (> $command_lib.validate_command_template(template) <);
if (!(type in ['local, 'remote]))
throw(~type, "Command types can be either 'local or 'remote");
if ('this in cmd[2].values().slice(1))
type = 'remote;
if (type == 'remote) {
for x in (cmd[2].values().slice(1)) {
if (x == 'this)
count++;
}
if (!count)
throw(~add_command, "Command type defined as remote with no <this> argument.");
else if (count > 1)
throw(~add_command, "More than one <this> argument specified in template.");
}
if (!get_var(type))
set_var(type, #[]);
set_var(type, get_var(type).setadd_elem(cmd[1][1], [@cmd[1], template, method, cmd[2]]));
if (type == 'remote)
$remote_cache.add_remote_command(cmd[1][1], this());
else if (.command_modules() || filter x in (parents()) where ('general_cache in x.flags()))
(| .cache_client_init() |);
// $#Edited: 09 Aug 99 22:54 $brandon
["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]