diff --git a/BetterSecondbot/DiscordSupervisor/ChannelControl.cs b/BetterSecondbot/DiscordSupervisor/ChannelControl.cs index 8424954..6894389 100644 --- a/BetterSecondbot/DiscordSupervisor/ChannelControl.cs +++ b/BetterSecondbot/DiscordSupervisor/ChannelControl.cs @@ -32,6 +32,30 @@ namespace BetterSecondBot.DiscordSupervisor return null; } + protected async Task SendEmbedToChannelAsync(string channelname, string sender, string message, Color color, string catmapid, UUID sender_id, string TopicType) + { + if (AllowNewOutbound() == true) + { + try + { + channelname = channelname.ToLowerInvariant(); + channelname = String.Concat(channelname.Where(char.IsLetterOrDigit)); + ITextChannel Channel = await FindTextChannel(channelname, catmap[catmapid], sender_id, TopicType, false).ConfigureAwait(true); + if (Channel != null) + { + var embed = new EmbedBuilder(); + embed.AddField(sender, message).WithColor(color); + return await Channel.SendMessageAsync(null, false, embed.Build()).ConfigureAwait(false); + } + } + catch + { + return null; + } + } + return null; + } + protected async Task FindTextChannel(string channelname, ICategoryChannel cat, UUID sender, string TopicType, bool CleanChannel) { return await FindTextChannel(DiscordServer, channelname, cat, sender, TopicType, true, CleanChannel); diff --git a/BetterSecondbot/DiscordSupervisor/relay.cs b/BetterSecondbot/DiscordSupervisor/relay.cs index 0b66039..0f05946 100644 --- a/BetterSecondbot/DiscordSupervisor/relay.cs +++ b/BetterSecondbot/DiscordSupervisor/relay.cs @@ -58,9 +58,9 @@ namespace BetterSecondBot.DiscordSupervisor { if (HasBot() == true) { - if (fromme == false) + if (DiscordClientConnected == true) { - if (DiscordClientConnected == true) + if (fromme == false) { if (avatar == true) { @@ -85,9 +85,20 @@ namespace BetterSecondBot.DiscordSupervisor } else { - controler.getBot().Debug("DiscordBotChatControler - Not from an avatar"); + if (sender_uuid != UUID.Zero) + { + await SendEmbedToChannelAsync("localchat", sender_name, message, Discord.Color.DarkMagenta, "bot", UUID.Zero, "bot").ConfigureAwait(false); + } + else + { + await SendEmbedToChannelAsync("localchat", sender_name, message, Discord.Color.DarkRed, "bot", UUID.Zero, "bot").ConfigureAwait(false); + } } } + else + { + await SendEmbedToChannelAsync("localchat", "{ME}", message, Discord.Color.LightGrey, "bot", UUID.Zero, "bot").ConfigureAwait(false); + } } } return Task.CompletedTask;