Example #1
0
        /// <summary>
        /// Returns the realm, specified by the next word or number, if the Realm could be found, else sends a reply.
        /// </summary>
        /// <param name="trigger"></param>
        /// <returns></returns>
        public static RealmEntry GetRealm(CmdTrigger <AuthServerCmdArgs> trigger)
        {
            var  arg = trigger.Text.Remainder;
            uint no;
            var  count = AuthenticationServer.RealmCount;

            if (count > 0)
            {
                if (uint.TryParse(arg, out no))
                {
                    if (count < no)
                    {
                        trigger.Reply("Invalid Realm Number - Must be between 1 and {0}", count);
                    }
                    else
                    {
                        return(AuthenticationServer.GetRealmByNumber((int)no));
                    }
                }
                else
                {
                    return(AuthenticationServer.GetRealmByName(arg));
                }
            }
            else
            {
                trigger.Reply("There are no registered Realms.");
            }
            return(null);
        }