Method code for $channel_ui.channel_add_lock_cmd()

[Turn on line numbering]
arg cmdstr, cmd, this, prep, str;
var channel, db, lock, mode, modestr;

(> .perms(caller(), 'command) <);
if (cmd[2] == "j") {
    mode = 3;
    modestr = "join";
} else if (cmd[2] == "l") {
    mode = 4;
    modestr = "leave";
} else {
    mode = 8;
    modestr = "use";
}
channel = tosym(this.lowercase());
db = (| $channel_db.search(channel) |) || 0;
if (type(db) == 'list) {
    if (!(sender() in db[6]) && !$sys.is_system(sender())) {
        return "Sorry, you're not on the manager list for that channel.";
    } else if (str.length() == 0) {
        $channel_db.value_changed(channel, db.replace(mode, 0));
        return "You un-" + modestr + "lock channel " + db[1] + ".";
    } else {
        catch ~objnf, ~parse {
            lock = $lock_frob.parse(str, sender());
            $channel_db.value_changed(channel, db.replace(mode, lock));
            return "You " + modestr + "lock channel " + db[1] + " with " + lock.lock_name('thing) + ".";
        } with {
            switch (error()) {
                case ~objnf:
                    return "Object not found in lock string.";
                case ~parse:
                    return "Invalid lock string.";
            }
        }
    }
} else {
    return "Channel not found, nothing locked.";
}

// Created 24-Jul-1996 as a part of ColdCore, see: @help Credit

Tlon