1 | exports.command = {
|
2 | name: "tell",
|
3 | autoload: true,
|
4 | unloadable: false,
|
5 | min_rank: 0,
|
6 | display: "tells someone something, in private.",
|
7 | help: "Tells someone something, in private. Only both of you will know...",
|
8 | usage: ".tell <user> <text>",
|
9 |
|
10 | execute: function(socket, command, command_access) {
|
11 |
|
12 | var chalk = require('chalk');
|
13 | to = command.split(' ')[0];
|
14 | message = command.split(' ').slice(1).join(" ");
|
15 |
|
16 | if ((typeof to === 'undefined') || (typeof message === 'undefined') || to.length < 1 || message.length < 1) {
|
17 | socket.write(chalk.yellow(":: ") + "You have to use it this way:" + chalk.yellow(" .tell someone something\r\n"));
|
18 | } else {
|
19 | var s = command_access.getAproxOnlineUser(to);
|
20 | if (s.length === 1) {
|
21 | if (socket.username.toLowerCase() === s[0].username.toLowerCase()) {
|
22 | return socket.write(chalk.red(":: ") + "Talking to yourself is the first sign of madness.\r\n");
|
23 | }
|
24 | socket.write(chalk.green("You tell ") + s[0].username + chalk.green(": ") + message + "\r\n");
|
25 | s[0].write(socket.username + chalk.green(" tells you: ") + message + "\r\n");
|
26 | } else if (s.length === 0) {
|
27 | socket.write(chalk.red(":: ") + "There is no one of that name logged on.\r\n");
|
28 | } else {
|
29 | var possibilities = "";
|
30 | for (var p = 0; p < s.length - 1; p++) {
|
31 | possibilities += chalk.bold(s[p].username) + ", ";
|
32 | }
|
33 | possibilities += chalk.bold(s[s.length - 1].username);
|
34 | socket.write(chalk.yellow(":: ") + "Be more explicit: whom do you want to talk to ("+possibilities+")?\r\n");
|
35 | }
|
36 | }
|
37 | }
|
38 | }
|