Esempio n. 1
0
        public void Kick(ServerClient client, string reason = null)
        {
            if (!(this is LobbyChannel))
            {
                LobbyChannel lobby = ChannelRepository.Instance.GetLobby();
                if (lobby == null)
                {
                    return;
                }

                if (client.Channel.Equals(lobby))
                {
                    return;
                }

                TalkyChannel oldChannel = client.Channel;
                client.JoinChannel(lobby, false);

                if (reason != null)
                {
                    oldChannel.BroadcastMessage(client.Username + " was kicked from the channel (" + reason + ").");
                }
                oldChannel.BroadcastMessage(client.Username + " was kicked from the channel.");
            }
        }
Esempio n. 2
0
        public override void Execute(ServerClient client, string[] args)
        {
            if (args.Length != 1)
            {
                SendUsage(client);
                return;
            }

            string desiredChannel = args[0];

            if (!desiredChannel.StartsWith("+"))
            {
                desiredChannel = "+" + desiredChannel;
            }

            TalkyChannel channel = ChannelRepository.Instance.Get(desiredChannel);
            if (channel == null)
            {
                client.SendMessage("§2That channel does not exist.");
                client.SendMessage("§2Use /clist to see a list of channels.");
                client.SendMessage("§2Use /cc to create a temporary channel.");
                return;
            }

            if (client.Channel.Equals(channel))
            {
                client.SendMessage("§2You are already in that channel!");
                return;
            }

            client.JoinChannel(channel);
        }
Esempio n. 3
0
        public override void Execute(ServerClient client, string[] args)
        {
            if (args.Length != 1)
            {
                SendUsage(client);
                return;
            }

            string desiredChannel = args[0];

            if (!desiredChannel.StartsWith("++"))
            {
                desiredChannel = "++" + desiredChannel;
            }

            if (desiredChannel.Length > 16 || desiredChannel.Substring(2).Contains("+") || desiredChannel.Contains("%") || desiredChannel.Contains("/") || desiredChannel.Contains("@") || desiredChannel.Contains("\\") || desiredChannel.Contains(";"))
            {
                client.SendMessage("§2Invalid Channel name. Channel names may not contain +, %, /, @, ; or \\. Channel names also have a maximum length of 16 characters.");
                return;
            }

            TalkyChannel channel = ChannelRepository.Instance.Get(desiredChannel);
            if (channel != null)
            {
                client.SendMessage("§2That channel already exists.");
                return;
            }

            ClientChannel chan = new ClientChannel(desiredChannel);
            ChannelRepository.Instance.Store(chan);
            client.SendMessage("§4Your channel has been created.");
            client.JoinChannel(chan);
        }
Esempio n. 4
0
        public override void Execute(ServerClient client, string[] args)
        {
            if (args.Length != 1)
            {
                SendUsage(client);
                return;
            }

            string desiredUsername = args[0];

            if (desiredUsername.Length > 16 || desiredUsername.Contains("%") || desiredUsername.Contains("/") || desiredUsername.Contains("@") || desiredUsername.Contains("\\") || desiredUsername.Contains(";"))
            {
                client.SendMessage("§2Invalid username. Usernames may not contain %, /, @, ; or \\. Usernames also have a maximum length of 16 characters.");
                return;
            }

            if (ClientRepository.Instance.Exists(desiredUsername))
            {
                client.SendMessage("§2That username is already in use.");
                return;
            }

            if (UserAccount.Find(desiredUsername) != null)
            {
                client.SendMessage("§2That username is linked to an account.");
                client.SendMessage("§2If you are the account holder, use /auth to login and claim the username.");
                return;
            }

            if (client.Account != null)
            {
                client.SendMessage("§2Authenticated clients may not change their username.");
                return;
            }

            string oldUsername = client.Username;
            client.Username = desiredUsername;
            client.SendMessage("§4You are now known as " + desiredUsername + ".");

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

            if (!oldUsername.Equals("%"))
            {
                client.Channel.BroadcastMessage("§1" + oldUsername + " is now known as " + desiredUsername);
            }
        }
Esempio n. 5
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);
            }
        }