Newsbot.Collector/Newsbot.Collector.Services/Notifications/Discord/MessageValidation.cs

56 lines
1.3 KiB
C#

using Newsbot.Collector.Domain.Models;
namespace Newsbot.Collector.Services.Notifications.Discord;
public class MessageValidation
{
public void IsMessageValid(DiscordMessage payload)
{
if (payload.Embeds is null)
{
}
}
public static bool IsEmbedFooterValid(DiscordMessageEmbed[] embeds)
{
if (embeds.Count() == 0)
{
return true;
}
foreach (var embed in embeds)
{
if (embed.Footer is null)
{
return true;
}
if (embed.Footer.IconUrl is null)
{
return true;
}
var containsHttp = embed.Footer.IconUrl.Contains("http://");
var containsHttps = embed.Footer.IconUrl.Contains("https://");
if (containsHttp == false || containsHttps == false)
{
throw new Exception("Footer.IconUrl does not contain http:// or https://");
}
}
return true;
}
public static string ConvertHtmlCodes(string message)
{
message = message.Replace("&#39", "'");
return message;
}
public static bool IsEmbedAuthorValid(DiscordMessageEmbedAuthor author)
{
return true;
}
}