Remove legacy argument count requirement for commands
This commit is contained in:
parent
9b4bef87c6
commit
c36ade95c8
11 changed files with 23 additions and 33 deletions
|
@ -6,7 +6,7 @@ using System.Reflection;
|
||||||
[assembly: AssemblyCompany("ZNI")]
|
[assembly: AssemblyCompany("ZNI")]
|
||||||
[assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)]
|
[assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)]
|
||||||
[assembly: AssemblyCopyright("(C) 2020 Tara Piccari")]
|
[assembly: AssemblyCopyright("(C) 2020 Tara Piccari")]
|
||||||
[assembly: AssemblyFileVersion("5.4.394")]
|
[assembly: AssemblyFileVersion("5.4.395")]
|
||||||
[assembly: AssemblyDescription("Second Life Bot - BotCore5")]
|
[assembly: AssemblyDescription("Second Life Bot - BotCore5")]
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace Bot.Assemble
|
||||||
public class ASMInfo
|
public class ASMInfo
|
||||||
{
|
{
|
||||||
public static string BotName = "ZBotCore";
|
public static string BotName = "ZBotCore";
|
||||||
public static string BotVer = "5.4.394";
|
public static string BotVer = "5.4.395";
|
||||||
public static string GitPassword
|
public static string GitPassword
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Bot
|
||||||
/// <param name="registry"></param>
|
/// <param name="registry"></param>
|
||||||
/// <param name="agentKey"></param>
|
/// <param name="agentKey"></param>
|
||||||
/// <param name="agentName"></param>
|
/// <param name="agentName"></param>
|
||||||
[CommandGroup("log_chat", 5, 0, "log_chat - Toggles chat and IM logging", Destinations.DEST_AGENT | Destinations.DEST_LOCAL )]
|
[CommandGroup("log_chat", 5, "log_chat - Toggles chat and IM logging", Destinations.DEST_AGENT | Destinations.DEST_LOCAL )]
|
||||||
public void toggleChatLog(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void toggleChatLog(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
MHE(source, client, "Toggling");
|
MHE(source, client, "Toggling");
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Bot.CommandSystem
|
||||||
|
|
||||||
Final += "<table class='HelpTable'><thead><tr><th>Bot Version</th><th>"+ASMInfo.BotVer+"</th></tr></table><br/>";
|
Final += "<table class='HelpTable'><thead><tr><th>Bot Version</th><th>"+ASMInfo.BotVer+"</th></tr></table><br/>";
|
||||||
|
|
||||||
Final += "<table class='HelpTable'><thead><tr><th>Command</th><th>Minimum Level Required</th><th>Usage</th><th>Allowed Sources</th><th>Number of Arguments required</th></thead><tbody>";
|
Final += "<table class='HelpTable'><thead><tr><th>Command</th><th>Minimum Level Required</th><th>Usage</th><th>Allowed Sources</th></thead><tbody>";
|
||||||
foreach (KeyValuePair<string, CommandGroup> cmd in reg.Cmds)
|
foreach (KeyValuePair<string, CommandGroup> cmd in reg.Cmds)
|
||||||
{
|
{
|
||||||
// Command
|
// Command
|
||||||
|
@ -47,8 +47,6 @@ namespace Bot.CommandSystem
|
||||||
Final += "<td>" + cmd.Value.cmdUsage.RawUsage() + "</td>";
|
Final += "<td>" + cmd.Value.cmdUsage.RawUsage() + "</td>";
|
||||||
// Allowed Sources
|
// Allowed Sources
|
||||||
Final += "<td>" + cmd.Value.CommandSource + "</td>";
|
Final += "<td>" + cmd.Value.CommandSource + "</td>";
|
||||||
// # Arguments
|
|
||||||
Final += "<td>" + cmd.Value.arguments.ToString() + "</td></tr>";
|
|
||||||
}
|
}
|
||||||
Final += "</tbody></table>";
|
Final += "</tbody></table>";
|
||||||
|
|
||||||
|
@ -94,7 +92,7 @@ namespace Bot.CommandSystem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("show_level", 0, 0, "This command shows your current auth level if any.", Destinations.DEST_AGENT | Destinations.DEST_DISCORD | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
[CommandGroup("show_level", 0, "This command shows your current auth level if any.", Destinations.DEST_AGENT | Destinations.DEST_DISCORD | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
||||||
public void show_level(UUID client, int level, string[] additionalArgs,
|
public void show_level(UUID client, int level, string[] additionalArgs,
|
||||||
Destinations source,
|
Destinations source,
|
||||||
UUID agentKey, string agentName)
|
UUID agentKey, string agentName)
|
||||||
|
@ -102,7 +100,7 @@ namespace Bot.CommandSystem
|
||||||
MHE(source, client, "Hi secondlife:///app/agent/" + agentKey.ToString() + "/about !! Your authorization level is " + level.ToString());
|
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", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
[CommandGroup("show_version", 0, "Outputs the bot version", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
||||||
public void show_version(UUID client, int level, string[] additionalArgs,
|
public void show_version(UUID client, int level, string[] additionalArgs,
|
||||||
Destinations source,
|
Destinations source,
|
||||||
UUID agentKey, string agentName)
|
UUID agentKey, string agentName)
|
||||||
|
@ -112,7 +110,7 @@ namespace Bot.CommandSystem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("show_admins", 4, 0, "Outputs all admin users", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
[CommandGroup("show_admins", 4, "Outputs all admin users", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
||||||
public void show_admins(UUID client, int level, string[] additionalArgs, Destinations source,
|
public void show_admins(UUID client, int level, string[] additionalArgs, Destinations source,
|
||||||
UUID agentKey, string agentName)
|
UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
|
@ -124,15 +122,15 @@ namespace Bot.CommandSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("terminate_bot", 5, 0, "", Destinations.DEST_LOCAL | Destinations.DEST_AGENT | Destinations.DEST_DISCORD | Destinations.DEST_GROUP)]
|
[CommandGroup("terminate_bot", 5, "", Destinations.DEST_LOCAL | Destinations.DEST_AGENT | Destinations.DEST_DISCORD | Destinations.DEST_GROUP)]
|
||||||
public void PerformExit(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void PerformExit(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
MHE(source, client, "Bot exit initiated.");
|
MHE(source, client, "Bot exit initiated.");
|
||||||
BotSession.Instance.EnqueueExit = true;
|
BotSession.Instance.EnqueueExit = true;
|
||||||
}
|
}
|
||||||
// !!help
|
// !!help
|
||||||
[CommandGroup("!help", 1, 0, "Prints the entire help registry", Destinations.DEST_AGENT |Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
[CommandGroup("!help", 1, "Prints the entire help registry", Destinations.DEST_AGENT |Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
||||||
[CommandGroup("bot.help", 1, 0, "Alias to !help", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
[CommandGroup("bot.help", 1, "Alias to !help", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
||||||
public void PrintAllHelp(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void PrintAllHelp(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
if (MainConfiguration.Instance.UseSSL)
|
if (MainConfiguration.Instance.UseSSL)
|
||||||
|
@ -141,14 +139,14 @@ namespace Bot.CommandSystem
|
||||||
MHE(source, client, $"All commands viewable at: http://{MainConfiguration.Instance.WebServerIP}:{MainConfiguration.Instance.WebServerPort}/help");
|
MHE(source, client, $"All commands viewable at: http://{MainConfiguration.Instance.WebServerIP}:{MainConfiguration.Instance.WebServerPort}/help");
|
||||||
}
|
}
|
||||||
// !help "command"
|
// !help "command"
|
||||||
[CommandGroup("help", 0, 1, "Prints help for one command", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP )]
|
[CommandGroup("help", 0, "Prints help for one command", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP )]
|
||||||
public void PrintHelp(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void PrintHelp(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
CommandRegistry.Instance.PrintHelp(source, additionalArgs[0], client);
|
CommandRegistry.Instance.PrintHelp(source, additionalArgs[0], client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("disable", 6, 1, "disable [string] - Disables a command", Destinations.DEST_AGENT | Destinations.DEST_GROUP | Destinations.DEST_LOCAL)]
|
[CommandGroup("disable", 6, "disable [string] - Disables a command", Destinations.DEST_AGENT | Destinations.DEST_GROUP | Destinations.DEST_LOCAL)]
|
||||||
public void DisableCmd(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void DisableCmd(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
if (!MainConfiguration.Instance.DisabledCommands.Contains(additionalArgs[0]))
|
if (!MainConfiguration.Instance.DisabledCommands.Contains(additionalArgs[0]))
|
||||||
|
@ -164,7 +162,7 @@ namespace Bot.CommandSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("enable", 6, 1, "enable [string] - Enables a command", Destinations.DEST_AGENT | Destinations.DEST_GROUP | Destinations.DEST_LOCAL)]
|
[CommandGroup("enable", 6, "enable [string] - Enables a command", Destinations.DEST_AGENT | Destinations.DEST_GROUP | Destinations.DEST_LOCAL)]
|
||||||
public void EnableCmd(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void EnableCmd(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
if (MainConfiguration.Instance.DisabledCommands.Contains(additionalArgs[0]))
|
if (MainConfiguration.Instance.DisabledCommands.Contains(additionalArgs[0]))
|
||||||
|
|
|
@ -11,17 +11,15 @@ namespace Bot.CommandSystem
|
||||||
public string Command;
|
public string Command;
|
||||||
public int minLevel;
|
public int minLevel;
|
||||||
public MethodInfo AssignedMethod;
|
public MethodInfo AssignedMethod;
|
||||||
public int arguments = 0;
|
|
||||||
public CommandHelp cmdUsage;
|
public CommandHelp cmdUsage;
|
||||||
public Destinations CommandSource;
|
public Destinations CommandSource;
|
||||||
|
|
||||||
public CommandGroup(string Command, int minLevel, int argCount, string HelpText, Destinations SourceType)
|
public CommandGroup(string Command, int minLevel, string HelpText, Destinations SourceType)
|
||||||
{
|
{
|
||||||
this.Command = Command;
|
this.Command = Command;
|
||||||
this.minLevel = minLevel;
|
this.minLevel = minLevel;
|
||||||
arguments = argCount;
|
|
||||||
CommandSource = SourceType;
|
CommandSource = SourceType;
|
||||||
cmdUsage = new CommandHelp(Command, minLevel, argCount, HelpText, SourceType);
|
cmdUsage = new CommandHelp(Command, minLevel, HelpText, SourceType);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,21 +25,20 @@ namespace Bot.CommandSystem
|
||||||
{
|
{
|
||||||
public string Name;
|
public string Name;
|
||||||
public int minLevel;
|
public int minLevel;
|
||||||
public int args;
|
|
||||||
public string Text;
|
public string Text;
|
||||||
public string sources;
|
public string sources;
|
||||||
public Destinations dests_allowed;
|
public Destinations dests_allowed;
|
||||||
}
|
}
|
||||||
public string GetUsage()
|
public string GetUsage()
|
||||||
{
|
{
|
||||||
return "_\nCommand [" + h.Name + "]\n" + h.sources + "\nMinimum Level Required [" + h.minLevel.ToString() + "]\nTotal Arguments [" + h.args.ToString() + "]\nUsage: " + h.Text;
|
return "_\nCommand [" + h.Name + "]\n" + h.sources + "\nMinimum Level Required [" + h.minLevel.ToString() + "]\nUsage: " + h.Text;
|
||||||
|
|
||||||
}
|
}
|
||||||
public string RawUsage()
|
public string RawUsage()
|
||||||
{
|
{
|
||||||
return "Usage: " + h.Text;
|
return "Usage: " + h.Text;
|
||||||
}
|
}
|
||||||
public CommandHelp(string CmdName, int minLevel, int argCount, string HelpText, Destinations DESTS)
|
public CommandHelp(string CmdName, int minLevel, string HelpText, Destinations DESTS)
|
||||||
{
|
{
|
||||||
h = new Help();
|
h = new Help();
|
||||||
string Applicable = "Command can be used in [";
|
string Applicable = "Command can be used in [";
|
||||||
|
@ -51,7 +50,6 @@ namespace Bot.CommandSystem
|
||||||
if (Applicable.Substring(Applicable.Length - 1, 1) == " ") Applicable = Applicable.Substring(0, Applicable.Length - 2) + "]";
|
if (Applicable.Substring(Applicable.Length - 1, 1) == " ") Applicable = Applicable.Substring(0, Applicable.Length - 2) + "]";
|
||||||
|
|
||||||
h.dests_allowed = DESTS;
|
h.dests_allowed = DESTS;
|
||||||
h.args = argCount;
|
|
||||||
h.Name = CmdName;
|
h.Name = CmdName;
|
||||||
h.minLevel = minLevel;
|
h.minLevel = minLevel;
|
||||||
if (HelpText == "") HelpText = NoAdditionalArguments;
|
if (HelpText == "") HelpText = NoAdditionalArguments;
|
||||||
|
|
|
@ -234,9 +234,9 @@ namespace Bot.CommandSystem
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ovj = Activator.CreateInstance(cgX.AssignedMethod.DeclaringType);
|
var ovj = Activator.CreateInstance(cgX.AssignedMethod.DeclaringType);
|
||||||
string[] additionalArgs = new string[cgX.arguments];
|
string[] additionalArgs = new string[cmdStruct.Length-1]; // no longer use a hardcoded argument length
|
||||||
IgnoreCount = cgX.arguments;
|
IgnoreCount = cgX.arguments;
|
||||||
for (int i = 1; i <= cgX.arguments; i++)
|
for (int i = 1; i <= cmdStruct.Length; i++)
|
||||||
{
|
{
|
||||||
additionalArgs[i - 1] = cmdStruct[pos + i];
|
additionalArgs[i - 1] = cmdStruct[pos + i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace Bot
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BotSession.Instance.grid.Self.RequestJoinGroupChat(groups.Key);
|
BotSession.Instance.grid.Self.RequestJoinGroupChat(groups.Key);
|
||||||
MHE(Destinations.DEST_LOCAL, UUID.Zero, "I lost the group chat session for secondlife:///app/group/" + groups.Key.ToString() + "/about - Attempting to rejoin the group chat");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,6 @@ namespace Bot
|
||||||
|
|
||||||
if (count >= 5)
|
if (count >= 5)
|
||||||
{
|
{
|
||||||
MH(Destinations.DEST_LOCAL, UUID.Zero, "Aborting group refresh attempt. Too many errors - Resetting cache and retrying");
|
|
||||||
GroupsEvent.Reset();
|
GroupsEvent.Reset();
|
||||||
GroupsCache = new Dictionary<UUID, Group>();
|
GroupsCache = new Dictionary<UUID, Group>();
|
||||||
BotSession.Instance.grid.Groups.CurrentGroups -= Groups_CurrentGroups;
|
BotSession.Instance.grid.Groups.CurrentGroups -= Groups_CurrentGroups;
|
||||||
|
@ -154,8 +152,6 @@ namespace Bot
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
MHE(Destinations.DEST_LOCAL, UUID.Zero, $"Plugin [{ProgramName}]: {ProgramVersion} has been initialized");
|
|
||||||
|
|
||||||
BotSession.Instance.grid.Groups.CurrentGroups += Groups_CurrentGroups;
|
BotSession.Instance.grid.Groups.CurrentGroups += Groups_CurrentGroups;
|
||||||
BotSession.Instance.grid.Groups.GroupRoleDataReply += CacheGroupRoles;
|
BotSession.Instance.grid.Groups.GroupRoleDataReply += CacheGroupRoles;
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace Bot
|
||||||
|
|
||||||
private static readonly object _fileRead = new object();
|
private static readonly object _fileRead = new object();
|
||||||
[CommandGroupMaster("Logging")]
|
[CommandGroupMaster("Logging")]
|
||||||
[CommandGroup("search_log", 5, 2, "search_log [groupName] [search_term] - Searches for the search term in all logs relating to the group name (Use a underscore to show where spaces are!). The search term may also include the pipe (|) delimiter to include more than 1 word.", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP | Destinations.DEST_DISCORD)]
|
[CommandGroup("search_log", 5, "search_log [groupName] [search_term] - Searches for the search term in all logs relating to the group name (Use a underscore to show where spaces are!). The search term may also include the pipe (|) delimiter to include more than 1 word.", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP | Destinations.DEST_DISCORD)]
|
||||||
public void search_log(UUID client, int level, string[] additionalArgs,
|
public void search_log(UUID client, int level, string[] additionalArgs,
|
||||||
Destinations source,
|
Destinations source,
|
||||||
UUID agentKey, string agentName)
|
UUID agentKey, string agentName)
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Bot
|
||||||
class Auth : BaseCommands
|
class Auth : BaseCommands
|
||||||
{
|
{
|
||||||
|
|
||||||
[CommandGroup("auth_user", 5, 2, "Authorizes a user to have command access. Arguments are user (UUID), and Level (int)", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
[CommandGroup("auth_user", 5, "Authorizes a user to have command access. Arguments are user (UUID), and Level (int)", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
||||||
public void set_auth(UUID client, int level, string[] additionalArgs,
|
public void set_auth(UUID client, int level, string[] additionalArgs,
|
||||||
Destinations source,
|
Destinations source,
|
||||||
UUID agentKey, string agentName)
|
UUID agentKey, string agentName)
|
||||||
|
|
|
@ -578,7 +578,7 @@ namespace Bot
|
||||||
|
|
||||||
private ManualResetEvent profile_get = new ManualResetEvent(false);
|
private ManualResetEvent profile_get = new ManualResetEvent(false);
|
||||||
private Avatar.AvatarProperties Properties_AV;
|
private Avatar.AvatarProperties Properties_AV;
|
||||||
[CommandGroup("set_profile_text", 75, 1, "set_profile_text [text:Base64] - Sets the profile text", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
[CommandGroup("set_profile_text", 6, "set_profile_text [text:Base64] - Sets the profile text", Destinations.DEST_AGENT | Destinations.DEST_LOCAL)]
|
||||||
public void setProfileText(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void setProfileText(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
MHE(source, client, "Setting...");
|
MHE(source, client, "Setting...");
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Bot.WebHookServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[CommandGroup("webhook_auth", 4, 2, "webhook_auth [github_name] [y/n]", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
[CommandGroup("webhook_auth", 4, "webhook_auth [github_name] [y/n]", Destinations.DEST_AGENT | Destinations.DEST_LOCAL | Destinations.DEST_GROUP)]
|
||||||
public void WebHookAuthMgr(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
public void WebHookAuthMgr(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
|
||||||
{
|
{
|
||||||
MainConfiguration cfg = MainConfiguration.Instance;
|
MainConfiguration cfg = MainConfiguration.Instance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue