adds localchat support for the bot and objects
This commit is contained in:
parent
df47584011
commit
eb4a3075ea
2 changed files with 38 additions and 3 deletions
|
|
@ -32,6 +32,30 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
return null;
|
||||
}
|
||||
|
||||
protected async Task<IUserMessage> 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<ITextChannel> FindTextChannel(string channelname, ICategoryChannel cat, UUID sender, string TopicType, bool CleanChannel)
|
||||
{
|
||||
return await FindTextChannel(DiscordServer, channelname, cat, sender, TopicType, true, CleanChannel);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue