예제 #1
0
        public override bool Execute(CommandArguments args, IPermissible sender)
        {
            var name = args.NextString();
            if (string.IsNullOrEmpty(name))
                return false;

            if (name.Length < AccountManager.MinNameLength || name.Length > AccountManager.MaxNameLength)
                return false;

            var password = args.NextString();
            if (string.IsNullOrEmpty(password))
                return false;

            if (password.Length < AccountManager.MinPasswordLength || password.Length > AccountManager.MaxPasswordLength)
                return false;

            var email = args.NextString();
            if (string.IsNullOrEmpty(email))
                return false;

            var box = args.NextEnum<ClientBoxLevel>() ?? ClientBoxLevel.Cataclysm;
            var locale = args.NextEnum<ClientLocale>() ?? ClientLocale.English;

            AccountManager.Instance.CreateAccount(name, password, email, box, locale);
            return true;
        }
예제 #2
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var name     = args.NextString();
            var password = args.NextString();
            var email    = args.NextString();
            var box      = args.NextEnum <ClientBoxLevel>(ClientBoxLevel.Cataclysm);
            var locale   = args.NextEnum <ClientLocale>(ClientLocale.English);

            if (string.IsNullOrEmpty(name))
            {
                sender.Respond("No name given.");
                return;
            }

            if (name.Length < Constants.Accounts.MinNameLength || name.Length > Constants.Accounts.MaxNameLength)
            {
                sender.Respond("Name must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinNameLength,
                                                                                               Constants.Accounts.MaxNameLength));
                return;
            }

            if (string.IsNullOrEmpty(password))
            {
                sender.Respond("No password given.");
                return;
            }

            if (password.Length < Constants.Accounts.MinPasswordLength || password.Length > Constants.Accounts.MaxPasswordLength)
            {
                sender.Respond("Password must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinPasswordLength,
                                                                                                   Constants.Accounts.MaxPasswordLength));
                return;
            }

            if (string.IsNullOrEmpty(email))
            {
                sender.Respond("No email given.");
                return;
            }

            AccountManager.Instance.PostAsync(x => x.CreateAccount(name, password, email, box, locale));
        }