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;
|
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)
|
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);
|
return await FindTextChannel(DiscordServer, channelname, cat, sender, TopicType, true, CleanChannel);
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,10 @@ namespace BetterSecondBot.DiscordSupervisor
|
||||||
protected async Task<Task> DiscordBotChatControler(string message, string sender_name, UUID sender_uuid, bool avatar, bool group, UUID group_uuid, bool localchat, bool fromme)
|
protected async Task<Task> DiscordBotChatControler(string message, string sender_name, UUID sender_uuid, bool avatar, bool group, UUID group_uuid, bool localchat, bool fromme)
|
||||||
{
|
{
|
||||||
if (HasBot() == true)
|
if (HasBot() == true)
|
||||||
{
|
|
||||||
if (fromme == false)
|
|
||||||
{
|
{
|
||||||
if (DiscordClientConnected == true)
|
if (DiscordClientConnected == true)
|
||||||
|
{
|
||||||
|
if (fromme == false)
|
||||||
{
|
{
|
||||||
if (avatar == true)
|
if (avatar == true)
|
||||||
{
|
{
|
||||||
|
|
@ -85,8 +85,19 @@ namespace BetterSecondBot.DiscordSupervisor
|
||||||
}
|
}
|
||||||
else
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue