From fe628b0a9d8eec277dcf169251afb58663f113d9 Mon Sep 17 00:00:00 2001 From: Zontreck Date: Tue, 2 Jun 2020 08:32:33 -0700 Subject: [PATCH] Add a source type to not command hooks --- Assembly/ASMInfo.cs | 4 ++-- NonCommands/NotCommand.cs | 4 ++++ NonCommands/nRegistry.cs | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Assembly/ASMInfo.cs b/Assembly/ASMInfo.cs index a849111..36bb7d2 100644 --- a/Assembly/ASMInfo.cs +++ b/Assembly/ASMInfo.cs @@ -6,7 +6,7 @@ using System.Reflection; [assembly: AssemblyCompany("ZNI")] [assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)] [assembly: AssemblyCopyright("© 2020 Tara Piccari")] -[assembly: AssemblyFileVersion("5.1.931")] +[assembly: AssemblyFileVersion("5.1.932")] [assembly: AssemblyDescription("Second Life Bot - BotCore5")] @@ -15,7 +15,7 @@ namespace Bot.Assemble public class ASMInfo { public static string BotName = "ZBotCore"; - public static string BotVer = "5.1.931"; + public static string BotVer = "5.1.932"; public static string GitPassword { get diff --git a/NonCommands/NotCommand.cs b/NonCommands/NotCommand.cs index 1ab508e..567ca78 100644 --- a/NonCommands/NotCommand.cs +++ b/NonCommands/NotCommand.cs @@ -7,6 +7,10 @@ namespace Bot.NonCommands [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public class NotCommand : Attribute { + /// + /// Defaults to all except action + /// + public MessageHandler.Destinations SourceType = MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_CONSOLE_INFO | MessageHandler.Destinations.DEST_DISCORD | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_LOCAL; public NotCommand() { // Not Command, this just marks a class diff --git a/NonCommands/nRegistry.cs b/NonCommands/nRegistry.cs index afdd8b9..ba95ca4 100644 --- a/NonCommands/nRegistry.cs +++ b/NonCommands/nRegistry.cs @@ -24,14 +24,26 @@ namespace Bot.NonCommands NotCommand[] nc = (NotCommand[])mi.GetCustomAttributes(typeof(NotCommand), false); if (nc.Length>0) { - ThreadStart work = delegate + bool OK = false; + foreach(NotCommand nx in nc) + { + if (nx.SourceType.HasFlag(sourceLoc)) + { + OK = true; + } + } + if (OK) { + ThreadStart work = delegate + { - mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator }); - }; - Thread T = new Thread(work); - T.Start(); + + mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator }); + }; + Thread T = new Thread(work); + T.Start(); + } } }