示例#1
0
            public override string Parse(ref SwitchboardUser User, string Command)
            {
                string[] CommandSplit = Command.Split(' ');

                switch (CommandSplit[0].ToUpper())
                {
                case "VER":
                    //Return version of this server
                    return(HeadServer.TheForm.Config.ServerName + " [Version " + HeadServer.TheForm.Config.ServerVersion + "]");

                case "SHOWEXTENSIONS":
                    //Show all extensions on this server
                    String AllExtensions = HeadServer.Extensions.Count + " Extension(s)\n\n";
                    foreach (SwitchboardExtension Extension in HeadServer.Extensions)
                    {
                        AllExtensions += Extension.GetName() + " [Version " + Extension.GetVersion() + "]\n";
                    }
                    return(AllExtensions);

                case "HELP":
                    //Show Server Help (Or the help of a specific command)
                    if (CommandSplit.Length == 1)
                    {
                        return(Help());
                    }
                    foreach (SwitchboardExtension Extension in HeadServer.Extensions)
                    {
                        if (Extension.GetName().ToUpper() == CommandSplit[1].ToUpper())
                        {
                            return(Extension.Help());
                        }
                    }
                    return("Could not find extension " + CommandSplit[1]);

                case "SETPASS":
                    //Set the password of the current user
                    if (CommandSplit.Length != 3 || Command.Contains("~"))
                    {
                        return("Could not update password due to invalid characters");
                    }
                    if (User == HeadServer.AnonymousUser)
                    {
                        return("cannot set password if user is not logged in");
                    }

                    if (User.SetPassword(CommandSplit[1], CommandSplit[2]))
                    {
                        HeadServer.SaveUsers();     //Make sure to save all users.
                        return("Successfully updated password!");
                    }

                    return("Server was unable to update your password");

                default:
                    //Return nada because we could not parse it.
                    return(null);
                }
            }