From 43146d733d2dad20a0da5e8c3eb17438dc0204d3 Mon Sep 17 00:00:00 2001 From: Zontreck Date: Tue, 7 Jul 2020 00:36:29 -0700 Subject: [PATCH] Make a few minor changes to allow discord commands to execute --- Assembly/ASMInfo.cs | 6 +++--- CommandSystem/BaseHooks.cs | 2 +- CommandSystem/CommandRegistry.cs | 4 +++- MessageHandler.cs | 20 ++++++++++++++++---- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Assembly/ASMInfo.cs b/Assembly/ASMInfo.cs index d3c3a3f..3cf0c85 100644 --- a/Assembly/ASMInfo.cs +++ b/Assembly/ASMInfo.cs @@ -5,8 +5,8 @@ using System.Reflection; [assembly: AssemblyCompany("ZNI")] [assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)] -[assembly: AssemblyCopyright("� 2020 Tara Piccari")] -[assembly: AssemblyFileVersion("5.3.916")] +[assembly: AssemblyCopyright("(C) 2020 Tara Piccari")] +[assembly: AssemblyFileVersion("5.3.921")] [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.3.916"; + public static string BotVer = "5.3.921"; public static string GitPassword { get diff --git a/CommandSystem/BaseHooks.cs b/CommandSystem/BaseHooks.cs index 935c9a7..40b0d39 100644 --- a/CommandSystem/BaseHooks.cs +++ b/CommandSystem/BaseHooks.cs @@ -124,7 +124,7 @@ namespace Bot.CommandSystem } - [CommandGroup("terminate_bot", 5, 0, "", Destinations.DEST_LOCAL | Destinations.DEST_AGENT | Destinations.DEST_DISCORD)] + [CommandGroup("terminate_bot", 5, 0, "", 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) { MHE(source, client, "Bot exit initiated."); diff --git a/CommandSystem/CommandRegistry.cs b/CommandSystem/CommandRegistry.cs index 14cfe4a..1743e83 100644 --- a/CommandSystem/CommandRegistry.cs +++ b/CommandSystem/CommandRegistry.cs @@ -219,6 +219,7 @@ namespace Bot.CommandSystem if ((dests & Destinations.DEST_AGENT) == source) Allowed = true; if ((dests & Destinations.DEST_GROUP) == source) Allowed = true; if ((dests & Destinations.DEST_LOCAL) == source) Allowed = true; + if ((dests & Destinations.DEST_DISCORD) == source) Allowed = true; if (!Allowed) { @@ -248,7 +249,8 @@ namespace Bot.CommandSystem cgX.AssignedMethod.Invoke(ovj, new object[] { user,level,additionalArgs, source,agentKey, agentName }); }catch(Exception e) { - MessageFactory.Post(Destinations.DEST_LOCAL, "Exception caught when executing a command\n" + e.Message + "\nStacktrace: " + e.StackTrace, UUID.Zero); + BotSession.Instance.grid.Self.Chat("Exception caught when executing a command\n" + e.Message + "\nStacktrace: " + e.StackTrace, 0, ChatType.Shout); + //MessageFactory.Post(Destinations.DEST_LOCAL, "Exception caught when executing a command\n" + e.Message + "\nStacktrace: " + e.StackTrace, UUID.Zero); } }); CMDThread.Start(); diff --git a/MessageHandler.cs b/MessageHandler.cs index 3d47942..e768f57 100644 --- a/MessageHandler.cs +++ b/MessageHandler.cs @@ -113,13 +113,24 @@ namespace Bot GroupID = ID; } } - + public class DiscordMiscDataPacket + { + public ulong ServerID; + public ulong ChannelID; + public bool originateFromDiscord { get; set; } = false; + public string DiscordUserName; + public ulong DiscordMessageID; + } public class DiscordMessage : Message { private string Msg; public string ServerName; public string ChannelName; private UUID SenderID; + /// + /// This is used to store misc data that could be identifying to where the data should go + /// + public DiscordMiscDataPacket PKT; public override int GetChannel() { @@ -166,12 +177,13 @@ namespace Bot SenderID = Sender; } - public DiscordMessage(string Msg, string Server, string Channel, UUID Sender) + public DiscordMessage(string Msg, string Server, string Channel, UUID Sender,DiscordMiscDataPacket pkt) { this.Msg = Msg; ServerName = Server; ChannelName = Channel; SenderID = Sender; + PKT = pkt; } } @@ -179,7 +191,7 @@ namespace Bot public class MessageFactory { - public static void Post(Destinations dest, string Msg, UUID destID, int chn = 0,string ServerName="MAP_NOT_KNOWN", string ChannelName="MAP_NOT_KNOWN") + public static void Post(Destinations dest, string Msg, UUID destID, int chn = 0,string ServerName="MAP_NOT_KNOWN", string ChannelName="MAP_NOT_KNOWN",DiscordMiscDataPacket packet=null) { Message m = null; @@ -190,7 +202,7 @@ namespace Bot m = new GroupMessage(destID); break; case Destinations.DEST_DISCORD: - m = new DiscordMessage(Msg,ServerName, ChannelName,destID); + m = new DiscordMessage(Msg,ServerName, ChannelName,destID,packet); break; default: m = new ChatMessage(destID);