From 587750fded897eba291b98bbd2e1935db93df84f Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:01:10 +0000 Subject: [PATCH] tweak command logging --- SecondBotEvents/Services/CommandsService.cs | 14 ++++++++------ SecondBotEvents/Services/CustomCommandsService.cs | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index ec946ce..f3f0970 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -197,8 +197,7 @@ namespace SecondBotEvents.Services { return new KeyValuePair(false, "Not accepted via signing"); } - KeyValuePair reply = RunCommand(C, viaCustomCommand); - CommandNotice(C.command, source, String.Join("@@@", C.args), reply.Key); + KeyValuePair reply = RunCommand(C, viaCustomCommand, source); return reply; } @@ -263,7 +262,7 @@ namespace SecondBotEvents.Services } protected HttpClient HTTPclient = new HttpClient(); - protected KeyValuePair RunBaseCommand(SignedCommand C) + protected KeyValuePair RunBaseCommand(SignedCommand C, string source) { try { @@ -290,13 +289,16 @@ namespace SecondBotEvents.Services { reply = JsonConvert.SerializeObject(processed); } + CommandNotice(C.command, source, String.Join("@@@", C.args), true); return new KeyValuePair(status, reply); } catch (Exception e) { + CommandNotice(C.command, source+" ~~ Failure: "+e.Message, String.Join("@@@", C.args), false); return new KeyValuePair(false, e.Message); } } + CommandNotice(C.command, source + " ~~ Failure: incorrect number of args", String.Join("@@@", C.args), false); return new KeyValuePair(status, reply); } return new KeyValuePair(false, "theMethod is null"); @@ -306,7 +308,7 @@ namespace SecondBotEvents.Services return new KeyValuePair(false, e.Message); } } - public KeyValuePair RunCommand(SignedCommand C, bool inCustomCommand=false) + public KeyValuePair RunCommand(SignedCommand C, bool inCustomCommand=false, string source="?") { if(acceptNewCommands == false) { @@ -326,9 +328,9 @@ namespace SecondBotEvents.Services { return new KeyValuePair(false, "Custom command chaining is not allowed"); } - return master.CustomCommandsService.RunCommand(C); + return master.CustomCommandsService.RunCommand(C, source); } - KeyValuePair reply = RunBaseCommand(C); + KeyValuePair reply = RunBaseCommand(C, source); if (C.replyTarget != null) { SmartCommandReply(C.replyTarget, reply.Value, C.command); diff --git a/SecondBotEvents/Services/CustomCommandsService.cs b/SecondBotEvents/Services/CustomCommandsService.cs index 3771460..c93fc3d 100644 --- a/SecondBotEvents/Services/CustomCommandsService.cs +++ b/SecondBotEvents/Services/CustomCommandsService.cs @@ -18,7 +18,7 @@ namespace SecondBotEvents.Services { return commands.ContainsKey(C); } - public KeyValuePair RunCommand(SignedCommand C) + public KeyValuePair RunCommand(SignedCommand C, string source) { if(commands.ContainsKey(C.command) == false) { @@ -39,7 +39,7 @@ namespace SecondBotEvents.Services Av = Av.Replace("[C_ARG_"+ loop.ToString()+"]", C.args[loop - 1]); loop++; } - KeyValuePair reply = master.CommandsService.CommandInterfaceCaller(Av, false, true); + KeyValuePair reply = master.CommandsService.CommandInterfaceCaller(Av, false, true, source); if(reply.Key == true) { commandsRun++;