parent $utility_objects
object $motd
var $root dbref 'motd
var $root child_index 0
var $root fertile 0
var $root manager $motd
var $root owned [$motd]
var $root owners [$motd]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $root inited 1
var $root info ["The Message of the Day object. Called by $old_connection and $fingerd.", "This builds a motd from different parameters, called by $motd.build().", "Parameters can be:", "", " 'long -- long title.", " 'short -- short title.", " 'title -- server title.", " 'name -- server name.", " 'notes -- connection notes.", " 'quote -- random quote.", " 'admins -- list of admins.", " 'connected -- currently connected users.", " 'version -- ColdMUD driver version."]
var $motd server_name "a Cold Dark Core World"
var $motd notes []
var $motd server_title "Virtual Environment Server"
method build
arg [args];
var output, out;
output = [];
if (!args)
args = ['long, 'quote];
if ((args[1]) == 'default)
args = ['name, "", 'title, "", "", 'quote, "", 'notes, "", 'admins, 'connected, 'version];
while (args) {
if (type(args[1]) == 'string) {
output = output + [""];
} else {
switch (args[1]) {
case 'long:
args = insert(args, ((args[1]) in args) + 1, 'title);
args = replace(args, (args[1]) in args, 'long_name);
continue;
case 'short:
args = insert(args, ((args[1]) in args) + 1, 'title);
args = replace(args, (args[1]) in args, 'name);
continue;
case 'title:
out = $string.center(server_title, 79);
output = output + [out];
case 'name:
out = $string.center(("+ " + server_name) + " +", 79);
output = output + [out];
case 'notes:
out = $list.center_lines(notes, 79);
output = output + out;
case 'quote:
out = $list.center_lines($code.random_quote(), 79);
output = output + out;
case 'admins:
out = $list.to_english($list.map($sys.admins(), 'namef));
out = $string.center("Administrators: " + out, 79);
output = output + [out];
case 'connected:
out = "Currently Connected users: ";
out = out + tostr(listlen($user_db.connected()));
out = $string.center(out, 79);
output = output + [out];
case 'version:
out = "ColdMUD Version " + ($sys.version());
out = $string.center(out, 79);
output = output + [out];
}
}
args = delete(args, 1);
}
return output;
.
method set_motd
arg what, value;
.perms(sender());
if (!(what in (.parameters())))
throw(~motd, (toliteral(what) + " is not a valid motd parameter, try one of: ") + toliteral(.parameters()));
if (!(type(value) in ['string, 'list]))
throw(~motd, "Value must be sent as a string or a list of strings.");
set_var(what, value);
.
method build_html
arg [args];
var output, out;
output = [("<head><title>" + server_name) + "</title></head>", "<body>"];
if (!args)
args = ['name, 'title, 'quote, "", 'notes, 'admins, 'connected, 'version, 'help];
while (args) {
if (type(args[1]) == 'string) {
output = output + ["<br>"];
} else {
switch (args[1]) {
case 'title:
output = output + ["<h3>", @server_title, "</h3>"];
case 'name:
// output = output + ["<h1>" + server_name + "</h1>"];
output = output + ["<img src=\"http://sticky.usu.edu/~brandon/tCD.gif\" alt=\"The Cold Dark\">"];
case 'notes:
output = (output + notes) + ["<br>"];
case 'quote:
output = output + ["<tt>", @$code.random_quote(), "</tt>"];
case 'admins:
out = $list.to_english($list.map($sys.admins(), 'namef));
output = output + [("Administrators: " + out) + "<br>"];
case 'connected:
out = "<a href=\"/bin/who\">Currently Connected users</a>: ";
out = out + tostr(listlen($user_db.connected()));
output = output + [out + "<br>"];
case 'version:
out = "<a href=\"http://www.declab.usu.edu:8080/ColdMUD/\">ColdMUD</a> Version " + ($list.to_string(version(), "."));
output = output + [out + "<br>"];
case 'help:
out = "</center><hr width=50% align=center><center>Click <a href=\"telnet://recumbent.declab.usu.edu:1138\"><b>here</b></a> to enter <a href=\"telnet://recumbent.declab.usu.edu:1138\">the Cold Dark</a>.";
output = output + [out];
}
}
args = delete(args, 1);
}
return ["<center>", @output, "</center>", "</body>"];
.
method server_name
return server_name;
.
method server_title
return server_title;
.