using Bot.Assemble; using Bot.WebHookServer; using OpenMetaverse; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Reflection; using System.Text; namespace Bot.CommandSystem { class BaseHooks { [WebhookAttribs("/help")] public WebhookRegistry.HTTPResponseData showHelp(List arguments, string body, string method, NameValueCollection headers) { WebhookRegistry.HTTPResponseData httpReply = new WebhookRegistry.HTTPResponseData(); CommandRegistry reg = CommandRegistry.Instance; string Final = ""; Final += "
Bot Version"+ASMInfo.BotVer+"

"; Final += ""; foreach (KeyValuePair cmd in reg.Cmds) { // Command Final += ""; // Level Final += ""; // Usage Final += ""; // Allowed Sources Final += ""; // # Arguments Final += ""; } Final += "
CommandMinimum Level RequiredUsageAllowed SourcesNumber of Arguments required
" + cmd.Value.Command + "" + cmd.Value.minLevel.ToString() + "" + cmd.Value.cmdUsage.RawUsage() + "" + cmd.Value.CommandSource + "" + cmd.Value.arguments.ToString() + "
"; Final += ""; WebhookRegistry regx = WebhookRegistry.Instance; foreach(KeyValuePair hooks in regx.hooks) { Final += ""; } Final += "
Hook Path
" + hooks.Value.Path + "
"; Final += "
"; foreach (Assembly A in AppDomain.CurrentDomain.GetAssemblies()) { Final += ""; int TotalCommandsContained = 0; int TotalClasses = 0; foreach (Type T in A.GetTypes()) { if (T.IsClass) { TotalClasses++; foreach (MethodInfo MI in T.GetMethods()) { CommandGroup[] CG = (CommandGroup[])MI.GetCustomAttributes(typeof(CommandGroup), false); TotalCommandsContained += CG.Length; } } } Final += ""; } Final += "
AssemblyVersion# Of CommandsTotal Classes
" + A.GetName().Name + "" + A.GetName().Version + "" + TotalCommandsContained.ToString() + "" + TotalClasses.ToString() + "
"; httpReply.ReplyString = Final; httpReply.Status = 200; httpReply.ReturnContentType = "text/html"; return httpReply; } [CommandGroup("show_level", 0, 0, "This command shows your current auth level if any.", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP)] public void show_level(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { MHE(source, client, "Hi secondlife:///app/agent/" + agentKey.ToString() + "/about !! Your authorization level is " + level.ToString()); } [CommandGroup("show_version", 0, 0, "Outputs the bot version", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL)] public void show_version(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { MHE(source, client, "Version " + ASMInfo.BotVer.ToString()); } [CommandGroup("show_admins", 4, 0, "Outputs all admin users", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL)] public void show_admins(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { for (int i = 0; i < MainConfiguration.Instance.BotAdmins.Count; i++) { MHE(source, client, "secondlife:///app/agent/" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString() + "/about [" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Value.ToString() + "] " + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString()); } } [CommandGroup("terminate_bot", 5, 0, "", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_CONSOLE_INFO | MessageHandler.Destinations.DEST_DISCORD)] public void PerformExit(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { MHE(source, client, "Bot exit initiated."); MHE(MessageHandler.Destinations.DEST_ACTION, UUID.Zero, "{'type':'exit'}"); } // !!help [CommandGroup("!help", 0, 0, "Prints the entire help registry", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_CONSOLE_INFO)] [CommandGroup("bot.help", 0, 0, "Alias to !help", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP)] public void PrintAllHelp(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { MHE(source, client, "All commands viewable at: https://zontreck.dev:35591/help"); } // !help "command" [CommandGroup("help", 0, 1, "Prints help for one command", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_CONSOLE_INFO)] public void PrintHelp(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) { registry.PrintHelp(source, additionalArgs[0], client); } } }