1 | exports.command = {
|
2 | name: "examine",
|
3 | autoload: true,
|
4 | unloadable: true,
|
5 | min_rank: 0,
|
6 | display: "Shows information about a user",
|
7 | help: "Shows information about a user.\r\n" +
|
8 | "Without arguments, it will give you information about yourself.\r\n" +
|
9 | "If you add another user as an argument, it will show you info about him/her " +
|
10 | "instead.",
|
11 | usage: ".examine [<user>]",
|
12 |
|
13 | friendlyTime: function(ms) {
|
14 | if (ms < 1000) {
|
15 | return "" + ms + " ms";
|
16 | } else if (ms < (1000 * 60)) {
|
17 | return "" + Math.floor(ms / 1000) + " s";
|
18 | } else if (ms < (1000 * 60 * 60)) {
|
19 | return "" + Math.floor(ms / 1000 / 60) + " min";
|
20 | } else if (ms < (1000 * 60 * 60 * 24)) {
|
21 | return "" + Math.floor(ms / 1000 / 60 / 60) + " h";
|
22 | } else if (ms < (1000 * 60 * 60 * 24 * 30)) {
|
23 | return "" + Math.floor(ms / 1000 / 60 / 60 / 24) + " d";
|
24 | } else if (ms < (1000 * 60 * 60 * 24 * 365)) {
|
25 | var m = Math.floor(ms / 1000 / 60 / 60 / 24 / 30);
|
26 | if (m > 11) m = 11;
|
27 | return "" + m + " mon";
|
28 | }
|
29 | return "" + Math.floor(ms / 1000 / 60 / 60 / 24 / 365) + " y";
|
30 | },
|
31 |
|
32 |
|
33 | execute: function(socket, command, command_access) {
|
34 | var chalk = require('chalk');
|
35 | var whom = command.split(' ')[0];
|
36 | if (typeof whom === 'undefined' || whom.length < 1) {
|
37 | whom = socket.username;
|
38 | }
|
39 | var wArr = command_access.getAproxUser(whom);
|
40 | if (wArr.length === 0) return socket.write(chalk.red(":: ") + "There's no one called " + chalk.bold(whom) + ".\r\n");
|
41 | if (wArr.length > 1) {
|
42 | var possibilities = "";
|
43 | for (var p = 0; p < wArr.length - 1; p++) {
|
44 | possibilities += chalk.cyan(wArr[p]) + ", ";
|
45 | }
|
46 | possibilities += chalk.cyan(wArr[wArr.length - 1]);
|
47 | return socket.write(chalk.yellow(":: Be more explicit: ") + "whom do you want to examine (" + possibilities + ")?\r\n");
|
48 | }
|
49 | whom = wArr[0];
|
50 | w = command_access.getUser(whom);
|
51 | socket.write(chalk.bold(":: ") + "You examine " + chalk.cyan(whom) + " and you see... \r\n");
|
52 | if (typeof (w.registerTime) === 'undefined') {
|
53 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " was " + chalk.green("registered") + " in an " + chalk.bold("old version") + ".\r\n");
|
54 | } else {
|
55 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " was " + chalk.green("registered") + " at " + chalk.bold(new Date(w.registerTime).toString()) + ".\r\n");
|
56 | }
|
57 | if (typeof (w.totalTime) === 'undefined') {
|
58 |
|
59 |
|
60 | if (command_access.getOnlineUser(whom) !== false) {
|
61 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " is " + chalk.green("online") + " for the " + chalk.bold("first time") + ".\r\n");
|
62 | } else {
|
63 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " hasn't been " + chalk.green("online") + " for a " + chalk.bold("long time") + ".\r\n");
|
64 | }
|
65 | } else {
|
66 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " has been " + chalk.green("online") + " for " + chalk.bold(this.friendlyTime(w.totalTime)) + ".\r\n");
|
67 | }
|
68 | socket.write(
|
69 | chalk.bold(":: ") + chalk.cyan(whom) + " is of rank " + chalk.bold(command_access.ranks.list[w.rank]) +
|
70 | ", and was last seen at " + chalk.yellow(command_access.getUniverse().get(w.where).name) + ".\r\n"
|
71 | );
|
72 | if (typeof w.loginTime !== 'undefined') {
|
73 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " last logged in at " + chalk.bold(new Date(w.loginTime).toString()) + ".\r\n");
|
74 | }
|
75 | if (typeof w.loginCount !== 'undefined') {
|
76 | socket.write(chalk.bold(":: ") + chalk.cyan(whom) + " has logged in " + chalk.bold(w.loginCount) + " times.\r\n");
|
77 | }
|
78 | }
|
79 | }
|