@create __PACKAGE__ named dns-com-vmoo-userlist:dns-com-vmoo-userlist @prop __USERLIST__."multi_tags" {} "" ;;__USERLIST__.("multi_tags") = {} @prop __USERLIST__."friends" {} r ;;__USERLIST__.("friends") = {} @prop __USERLIST__."fields" {} r ;;__USERLIST__.("fields") = {"Object", "Name", "Icon", "FirstConnectTime", "LastConnectTime"} @prop __USERLIST__."awake" {} r ;;__USERLIST__.("awake") = {} @prop __USERLIST__."idles" {} r @prop __USERLIST__."idle_limit" 180 r @prop __USERLIST__."cloaks" {} "" @prop __USERLIST__."aways" {} r @prop __USERLIST__."specials" {} r ;;__USERLIST__.("specials") = {{"cloaks", "("}, {"aways", "["}, {"idles", "<"}} @prop __USERLIST__."icons" {} r ;;__USERLIST__.("icons") = {"Newbie", "Inhabitant", "Inhabitant+", "Schooled", "Key", "Star", "Wizard"} @prop __USERLIST__."menu" {} r ;;__USERLIST__.("menu") = {{"&Look at $(2)", "look $(1)"}, {"&Wave at $(2)", "wave $(1)"}, 0, {"&Join $(2)", "@join $(1)"}, 0, {"W&ho $(2)", "@who$(1)"}} @prop __USERLIST__."iconurl" "" r ;;__USERLIST__.("version_range") = {"1.0", "1.2"} ;;__USERLIST__.("messages_in") = {{"friends", {"friends"}}} ;;__USERLIST__.("messages_out") = {{"", {}}, {{"menu", {"menu"}}}, {"friends", {"friends"}}, {"icon-url", {"url"}}} ;;__USERLIST__.("aliases") = {"dns-com-vmoo-userlist"} ;;__USERLIST__.("object_size") = {13465, 964289442} @verb __USERLIST__:"send_" this none this @program __USERLIST__:send_ if (caller != this) return E_PERM; endif {who, alist} = args; session = $mcp:session_for(who); if (valid(session)) return this:send_multiline(session, alist); endif . @verb __USERLIST__:"handle_friends" this none this rxd __WIZARD__ @program __USERLIST__:handle_friends "Sets session.connection.friends"; {session, friendstr} = args; set_task_perms(con = session.connection); if (caller != this) return E_PERM; endif if (typeof(friends = `$no_one:eval(friendstr)[2] ! ANY => 0') == LIST) try con.friends = friends; except (E_PROPNF) add_property(con, "friends", friends, {con, "rc"}); endtry endif . @verb __USERLIST__:"send_multiline" this none this rxd __WIZARD__ @program __USERLIST__:send_multiline {session, alist} = args; if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif con = session.connection; snoop = `session.connection.MCP_snoop ! E_PROPNF => 0'; if (!session:handles_package(this)) return; elseif (i = session in $list_utils:slice(this.multi_tags, 1)) tag = this.multi_tags[i][2]; else "Something went wrong at login?"; return this:activate_list(session); endif notify(con, line = this:parse_empty_command(session, alist, tag)); if (snoop) notify(con, "S->C: " + line); endif . @verb __USERLIST__:"finalize_connection" this none this @program __USERLIST__:finalize_connection if ($perm_utils:controls(caller_perms(), this)) connection = caller; `this.multi_tags = listdelete(this.multi_tags, connection in $list_utils:slice(this.multi_tags, 1)) ! ANY'; return 0; else return E_PERM; endif . @verb __USERLIST__:"full_list" this none this @program __USERLIST__:full_list if (caller != this) return E_PERM; endif sstr = "={"; for i in (connected_players()) if ((!this:is_cloaked(i)) && valid(session = $mcp:session_for(i))) (sstr[$] == "}") && (sstr = sstr + ", "); sstr = sstr + this:player_info(i); endif endfor return sstr + "}"; . @verb __USERLIST__:"parse_empty_command" this none this @program __USERLIST__:parse_empty_command {session, alist, tag} = args; if (caller != this) return E_PERM; endif return tostr("#$#* ", tag, " d: ", alist[1], alist[2]); . @verb __USERLIST__:"player_info" this none this @program __USERLIST__:player_info if (caller != this) return E_PERM; endif return tostr("{", args[1], ", \"", strsub(args[1].name, "_", " "), "\", ", this:player_status(args[1]), ", ", args[1].first_connect_time, ", ", args[1].last_connect_time, "}"); . @verb __USERLIST__:"player_status" this none this @program __USERLIST__:player_status if (caller == this) who = args[1]; if (who.wizard) return 7; elseif (who.programmer) return 2; else return 1; endif else return E_PERM; endif . @verb __USERLIST__:"user_disconnected user_client_disconnected" this none this @program __USERLIST__:user_disconnected if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif for i in (connected_players()) this:send_(i, {"-", tostr("{", args[1], "}")}); endfor this.awake = setremove(this.awake, args[1]); this.idles = setremove(this.idles, args[1]); this.cloaks = setremove(this.cloaks, args[1]); this.aways = setremove(this.aways, args[1]); . @verb __USERLIST__:"activate_list" this none this rxd __WIZARD__ @program __USERLIST__:activate_list {session} = args; if (caller != this) return E_PERM; endif name = this.name; con = session.connection; auth = session.authentication_key; tag = $mcp.parser:next_datakey(); if (!session:handles_package(this)) return E_INVARG; endif this.multi_tags = {@this.multi_tags, {session, tag}}; lines = {(((("#$#" + name) + "-you ") + auth) + " nr: ") + tostr(con)}; lines = {@lines, (((("#$#" + name) + " ") + auth) + " icons*: \"\" fields*: \"\" d*: \"\" _data-tag: ") + tag}; lines = {@lines, (((("#$#" + name) + "-menu ") + auth) + " menu: ") + toliteral(toliteral(this.menu))}; lines = {@lines, ((((("#$#" + name) + "-friends ") + auth) + " friends: \"") + toliteral(`con.friends ! ANY => this.friends')) + "\""}; this.iconurl && (lines = {@lines, (((("#$#" + name) + "-icon-url ") + auth) + " url: ") + this.iconurl}); lines = {@lines, (("#$#* " + tag) + " fields: ") + toliteral(this.fields)}; lines = {@lines, (("#$#* " + tag) + " icons: ") + toliteral(this.icons)}; lines = {@lines, (("#$#* " + tag) + " d: ") + this:full_list()}; for special in (this.specials) if (this.(special[1])) lines = {@lines, ((("#$#* " + tag) + " d: ") + special[2]) + toliteral(this.(special[1]))}; endif endfor for line in (lines) notify(con, line); endfor if (`con.MCP_snoop ! E_PROPNF => 0') for line in (lines) notify(con, "S->C: " + line); endfor endif . @verb __USERLIST__:"user_connected user_created" this none this @program __USERLIST__:user_connected if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif info = this:player_info(args[1]); for i in (setremove(connected_players(), args[1])) this:send_(i, {"+", info}); endfor this.awake = setadd(this.awake, args[1]); . @verb __USERLIST__:"update_playerstatus" this none this @program __USERLIST__:update_playerstatus if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif info = this:player_info(args[1]); for i in (connected_players()) this:send_(i, {"*", info}); endfor . @verb __USERLIST__:"idlefunc" this none this @program __USERLIST__:idlefunc if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif idles = this.idles; awake = this.awake; new_awake = new_idles = {}; for i in (connected_players()) if (`idle_seconds(i) > this.idle_limit ! ANY => 0') if (!is_member(i, idles)) new_idles = setadd(new_idles, i); endif awake = setremove(awake, i); idles = setadd(idles, i); else if (!is_member(i, awake)) new_awake = setadd(new_awake, i); endif idles = setremove(idles, i); awake = setadd(awake, i); endif endfor this.awake = awake; this.idles = idles; for j in (connected_players()) new_idles && this:send_(j, {"<", toliteral(new_idles)}); new_awake && this:send_(j, {">", toliteral(new_awake)}); endfor . @verb __USERLIST__:"away_on away_off" this none this @program __USERLIST__:away_on if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif if (verb == "away_on") this.aways = setadd(this.aways, args[1]); else this.aways = setremove(this.aways, args[1]); endif for i in (connected_players()) this:send_(i, {(verb == "away_on") ? "[" | "]", tostr("{", args[1], "}")}); endfor . @verb __USERLIST__:"cloak_on cloak_off" this none this @program __USERLIST__:cloak_on if (!$perm_utils:controls(caller_perms(), this)) return E_PERM; endif if (verb == "cloak_on") this.cloaks = setadd(this.cloaks, args[1]); else this.cloaks = setremove(this.cloaks, args[1]); endif for i in (connected_players()) if (verb == "cloak_off") this:send_(i, {"+", this:player_info(args[1])}); endif this:send_(i, {(verb == "cloak_on") ? "(" | ")", tostr("{", args[1], "}")}); endfor . @verb __USERLIST__:"initialize_connection" this none this @program __USERLIST__:initialize_connection "Usage: :initialize_connection()"; ""; {version} = args; session = caller; messages = $list_utils:slice(this.messages_in); session:register_handlers(messages); this:activate_list(session); . @verb __USERLIST__:"init_for_core" this none this @program __USERLIST__:init_for_core if ($perm_utils:controls(caller_perms(), this)) this.multi_tags = this.awake = this.idles = this.cloaks = {}; this.friends = toliteral($wiz_utils:all_wizards()); this.idle_limit = 180; endif . @verb __USERLIST__:"@reset" this none none @program __USERLIST__:@reset if (!$perm_utils:controls(player, this)) return player:tell(tostr(E_PERM)); endif this.awake = this.idles = this.aways = this.cloaks = {}; for i in (connected_players()) if ((session = $mcp:session_for(i)):handles_package(this)) this:send_(i, {"", this:full_list()}); endif endfor for j in (connected_players()) if (this:is_cloaked(j)) this:cloak_on(j); endif if (this:is_away(j)) this:away_on(j); endif endfor this:idlefunc(); player:tell("Userlist has been reset."); . @verb __USERLIST__:"is_cloaked" this none this rxd __WIZARD__ @program __USERLIST__:is_cloaked "Usage: :is_cloaked(speler) -> 0 or 1"; if (caller != this) return E_PERM; endif {who} = args; if (((typeof(who) != OBJ) || (!valid(who))) || (!is_player(who))) return 0; endif return (who.wizard && $object_utils:has_property(who, "cloaked")) && who.cloaked; . @verb __USERLIST__:"is_away" this none this rxd __WIZARD__ @program __USERLIST__:is_away return `args[1].away ! ANY => 0'; . @verb __USERLIST__:"send_icon-url" this none this @program __USERLIST__:send_icon-url if (caller != this) return E_PERM; endif return pass(@args); . "***finished***