From 8168f334cebe471810512e532f0acf3f1364b41f Mon Sep 17 00:00:00 2001 From: Madpeter Date: Sun, 26 Apr 2020 00:03:54 +0100 Subject: [PATCH] updates the discord full fat client to use command history hook and SendIM hook --- Core/bottypes/DiscordBot.cs | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Core/bottypes/DiscordBot.cs b/Core/bottypes/DiscordBot.cs index af9929e..5238fa9 100644 --- a/Core/bottypes/DiscordBot.cs +++ b/Core/bottypes/DiscordBot.cs @@ -430,14 +430,6 @@ namespace BSB.bottypes { status = CommandsInterface.Call(command); } - if (status == true) - { - _ = SendMessageToChannelAsync("interface", "Command running: " + message.Content + "", "bot", UUID.Zero, myconfig.userName, "bot"); - } - else - { - _ = SendMessageToChannelAsync("interface", "Command rejected: " + message.Content + "", "bot", UUID.Zero, myconfig.userName, "bot"); - } } else { @@ -553,6 +545,31 @@ namespace BSB.bottypes await DiscordBotChatControler(message, sender_name, sender_uuid, avatar, group, group_uuid, localchat, fromme); } + public override void CommandHistoryAdd(string command, string arg, bool status) + { + base.CommandHistoryAdd(command, arg, status); + if (status == true) + { + _ = SendMessageToChannelAsync("interface", "Command running: " + command + " ["+arg+"]", "bot", UUID.Zero, myconfig.userName, "bot"); + } + else + { + _ = SendMessageToChannelAsync("interface", "Command rejected: " + command + " [" + arg + "]", "bot", UUID.Zero, myconfig.userName, "bot"); + } + } + + public async override void sendIM(UUID avatar, string message) + { + base.sendIM(avatar, message); + if(AvatarKey2Name.ContainsKey(avatar) == true) + { + if (DiscordClientConnected == true) + { + await DiscordIMMessage(avatar, AvatarKey2Name[avatar], message).ConfigureAwait(false); + } + } + } + protected async Task DiscordBotChatControler(string message, string sender_name, UUID sender_uuid, bool avatar, bool group, UUID group_uuid, bool localchat, bool fromme) { if (myconfig.DiscordFullServer == false)