Пример #1
0
        public override void Execute(ServerClient client, string[] args)
        {
            if (client.Muted)
            {
                client.SendMessage("§2You are muted.");
                return;
            }

            if (args.Length < 2)
            {
                SendUsage(client);
                return;
            }

            string recipientUsername = args[0];
            string message           = "";

            for (int i = 1; i < args.Length; i++)
            {
                if (i == args.Length - 1)
                {
                    message += args[i];
                }
                else
                {
                    message += args[i] + " ";
                }
            }

            ServerClient recipient = ClientRepository.Instance.Find(recipientUsername);

            if (recipient == null)
            {
                client.SendMessage("§2No client found by that username.");
                return;
            }

            if (recipient.Equals(client))
            {
                client.SendMessage("§2You cannot send messages to yourself.");
                return;
            }

            recipient.SendMessage("<§1" + client.Username + " -> you§0> " + message);
            client.SendMessage("<§1you -> " + recipient.Username + "§0> " + message);
        }
Пример #2
0
        public override void Execute(ServerClient client, string[] args)
        {
            if (args.Length != 2)
            {
                SendUsage(client);
                return;
            }

            string username = args[0];
            string password = args[1];

            UserAccount account = UserAccount.Attempt(username, password);

            if (account == null)
            {
                client.SendMessage("§2Invalid username/password.");
                return;
            }

            ServerClient foundClient = ClientRepository.Instance.Find(account.Username);

            if (foundClient != null)
            {
                if (!foundClient.Equals(client))
                {
                    foundClient.Disconnect("§2This username has been reclaimed by the account owner.");
                }
            }

            string oldUsername = client.Username;

            client.Account  = account;
            client.Username = account.Username;
            client.SendMessage("§4You are now authenticated as " + account.Username + "!");

            if (client.Channel == null)
            {
                client.JoinChannel(ChannelRepository.Instance.GetLobby());
            }

            if (!oldUsername.Equals("%"))
            {
                client.Channel.BroadcastMessage("§1" + oldUsername + " is now known as " + account.Username);
            }
        }
Пример #3
0
        public override void Execute(ServerClient client, List <string> args)
        {
            if (args.Count < 2)
            {
                client.SendMessage("Usage: -tell <name> <message...>");
                return;
            }

            string person  = args[0];
            string message = "";

            for (int i = 1; i < args.Count; i++)
            {
                if (i == args.Count - 1)
                {
                    message += args[i];
                }
                else
                {
                    message += args[i] + " ";
                }
            }

            ServerClient recipient = ClientRepository.GetInstance().GetClient(person);

            if (recipient == null)
            {
                client.SendMessage("That person is not connected.");
                return;
            }

            if (recipient.Equals(client))
            {
                client.SendMessage("You cannot send messages to yourself!");
                return;
            }

            client.SendMessage($"PRIVATE | [{client._nick} > {recipient._nick}] {message}");
            recipient.SendMessage($"PRIVATE | [{client._nick} > {recipient._nick}] {message}");
        }