@create $root_class named Channel Utilities:Channel Utilities @prop $channel."help_msg" {} rc ;;$channel.("help_msg") = {"Channels allow one to talk OOCly to people across the MOO. Important commands are detailed below:", "", "@addcom = -- Adds 'channel' with an alias of 'alias'.", " Example: @addcom pub=Public", "@delcom -- Deletes your channel with alias of 'alias'.", " Example: @delcom pub", "@chan*nels -- Lists all your channels.", "---", "Once you have, a channel, following commands work:", " -- Poses 'pose' to the channel stored as 'alias'.", " Example: pub :waves!", " off -- Turns the channel under 'alias' off.", " on -- Turns the channel under 'alias' on.", " who -- Lists everyone on the channel.", "---"} @prop $channel."object_channels" {} rc ;;$channel.("object_channels") = {{"Help Desk", #283}} @prop $channel."nospeak" {} "" @verb $channel:"do_channel" this none this @program $channel:do_channel if (!caller_perms().wizard) return E_PERM; endif {channel, msg} = args; if (msg == "on") this:do_channel_on(channel); elseif (msg == "off") this:do_channel_off(channel); elseif (msg == "who") this:do_channel_who(channel); elseif ((n = $list_utils:iassoc(channel, player.channels, 2)) && (!player.channels[n][3])) player:tell("'", channel, "' is off."); else if (ob = `$list_utils:iassoc(channel, this.object_channels, 1) ! E_PROPNF => 0') this.object_channels[ob][2]:receive_channel(msg); endif msg = this:parse_pose(msg, player, player.channels[n][4]); this:send_channel(channel, msg); endif . @verb $channel:"send_channel" this none this @program $channel:send_channel {channel, msg} = args; if (((caller != #0) && (!$object_utils:isa(caller, $room2))) && (channel in $channel.nospeak)) return; endif channel = $string_utils:capitalize(channel); for lp in (connected_players()) broad = tostr((("[" + channel) + "] ") + msg); if ((n = $list_utils:iassoc(channel, lp.channels, 2)) && lp.channels[n][3]) lp:notify(broad); endif endfor . @verb $channel:"do_channel_who" this none this @program $channel:do_channel_who if (caller != this) return E_PERM; endif channel = args[1]; nlist = {}; for lp in (connected_players()) if (n = $list_utils:iassoc(channel, lp.channels, 2)) if (lp.channels[n][3]) name = ((secs = idle_seconds(lp)) > 300) ? tostr(lp.name, " (", $time_utils:etime(secs), ")") | lp.name; nlist = {@nlist, name}; endif endif endfor player:tell("Players on channel ", channel, ": "); player:tell_lines({"", @$string_utils:columnize(nlist, 3), ""}); player:tell("There are ", $string_utils:english_number(length(nlist)), " players listening."); . @verb $channel:"do_channel_on" this none this @program $channel:do_channel_on if (caller != this) return E_PERM; endif n = $list_utils:iassoc(channel = args[1], player.channels, 2); if (player.channels[n][3]) player:tell("[", channel, "] This channel is already on."); else player:tell("'", channel, "' is being added."); player.channels[n][3] = 1; this:send_channel(channel, player.name + " has joined this channel."); endif . @verb $channel:"do_channel_off" this none this @program $channel:do_channel_off if (caller != this) return E_PERM; endif n = $list_utils:iassoc(channel = args[1], player.channels, 2); if (player.channels[n][3]) this:send_channel(channel, player.name + " has left this channel."); player.channels[n][3] = 0; player:tell("'", channel, "' is removed."); else player:tell("[", channel, "] is already off."); endif . @verb $channel:"parse_pose" this none this @program $channel:parse_pose "Parses the message string into something readable."; {msg, person, ?title = ""} = args; who = tostr(title, title ? " " | "", person:title()); if (msg[1] == ":") if (msg[2] == ":") message = tostr(who, msg[3..$]); else message = tostr(who, " ", msg[2..$]); endif elseif ((msg[1] == "!") && (length(msg) > 1)) message = tostr(msg[2..$], player.wizard ? "" | tostr(" <", player.name, ">")); else message = tostr(who, ": ", msg); endif return message; . @property $player.channel {} "" @verb $player:@addcom any any any @program $player:@addcom if ($object_utils:isa(player, $guest)) player:tell("I'm sorry, guests are not allowed to add channels."); return; endif if (!argstr || !(ep = index(argstr, "="))) player:tell("Usage: @addcom ="); elseif (!(alias = $string_utils:trim(argstr[1..ep - 1])) || !(channel = $string_utils:trim(argstr[ep + 1..$]))) player:tell("Usage: @addcom ="); elseif (n = $list_utils:iassoc(channel, player.channels, 2)) player:tell("You already have channel '", player.channels[n][2], "' with an alias of '", player.channels[n][1], "'."); elseif (channel[1] == "*" && !player.wizard) player:tell("That channel is restricted to Wizards."); elseif (channel in {"Help Desk", "GameStaff"} && !$staff_utils:is_staff(player)) player:tell("That channel is restricted to staff."); else player.channels = {@player.channels, {alias, channel, 0, ""}}; player:tell("Channel [", channel, "] added with alias ", alias, "."); endif . @verb $player:@delcom any any any @program $player:@delcom if ($object_utils:isa(player, $guest)) player:tell("I'm sorry, guests are not allowed to remove channels."); return; endif if (!argstr) player:tell("Usage: @delcom "); elseif (!(n = $list_utils:iassoc(alias = $string_utils:trim(argstr), player.channels, 1))) player:tell("'", alias, "' alias not found."); else if (player.channels[n][3]) $channel:send_channel(player.channels[n][2], player.name + " has left this channel."); endif player.channels = listdelete(player.channels, n); player:tell("Channel deleted."); endif . @verb $player:@chan*nels none none none @program $player:@chan clist = {}; for lp in (player.channels) u = 0; for lp2 in (connected_players()) if (n = $list_utils:iassoc(lp[2], lp2.channels, 2)) if (lp2.channels[n][3]) u = u + 1; endif endif endfor clist = {@clist, $string_utils:left(lp[1], -7) + $string_utils:left(lp[2], -15) + $string_utils:left(lp[3] ? "On" | "Off", -5) + tostr(u)}; $command_utils:suspend_if_needed(0); endfor player:tell_lines($string_utils:columnize({header = $string_utils:left("Alias", -7) + $string_utils:left("Channel Name", -15) + $string_utils:left("On?", -5) + "Users", header}, 2)); player:tell_lines($string_utils:columnize(clist, 2)); . @verb $player2:my_huh tnt @program $player2:my_huh if (pass(@args)) return 1; else verb = args[1]; if ((n = $list_utils:iassoc(verb, this.channels, 1)) && argstr) channel = this.channels[n][2]; argstr = $string_utils:triml(argstr); $channel:do_channel(channel, argstr); return 1; elseif (verb[$] == "?" && (n = $list_utils:iassoc(verb[1..length(verb) - 1], this.channels, 1))) $channel:do_channel(this.channels[n][2], "who"); return 1; endif endif return 0; . "***finished***