Method code for $channel_ui.channel_add_lock_cmd()

[Turn off line numbering]
  1: arg cmdstr, cmd, this, prep, str;
  2: var channel, db, lock, mode, modestr;
  3: 
  4: (> .perms(caller(), 'command) <);
  5: if (cmd[2] == "j") {
  6:     mode = 3;
  7:     modestr = "join";
  8: } else if (cmd[2] == "l") {
  9:     mode = 4;
 10:     modestr = "leave";
 11: } else {
 12:     mode = 8;
 13:     modestr = "use";
 14: }
 15: channel = tosym(this.lowercase());
 16: db = (| $channel_db.search(channel) |) || 0;
 17: if (type(db) == 'list) {
 18:     if (!(sender() in db[6]) && !$sys.is_system(sender())) {
 19:         return "Sorry, you're not on the manager list for that channel.";
 20:     } else if (str.length() == 0) {
 21:         $channel_db.value_changed(channel, db.replace(mode, 0));
 22:         return "You un-" + modestr + "lock channel " + db[1] + ".";
 23:     } else {
 24:         catch ~objnf, ~parse {
 25:             lock = $lock_frob.parse(str, sender());
 26:             $channel_db.value_changed(channel, db.replace(mode, lock));
 27:             return "You " + modestr + "lock channel " + db[1] + " with " + lock.lock_name('thing) + ".";
 28:         } with {
 29:             switch (error()) {
 30:                 case ~objnf:
 31:                     return "Object not found in lock string.";
 32:                 case ~parse:
 33:                     return "Invalid lock string.";
 34:             }
 35:         }
 36:     }
 37: } else {
 38:     return "Channel not found, nothing locked.";
 39: }

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

Tlon