mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
- .say now uses new SmartText instead of CREmbed
- Added IMessageChannel extensions for sending smarttext - Added implicit operator from string to smarttext (which just creates smartplaintext instance)
This commit is contained in:
@@ -34,6 +34,58 @@ namespace NadekoBot.Common.Replacements
|
||||
return input;
|
||||
}
|
||||
|
||||
public SmartText Replace(SmartText data)
|
||||
=> data switch
|
||||
{
|
||||
SmartEmbedText embedData => Replace(embedData),
|
||||
SmartPlainText plain => Replace(plain),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(data), "Unsupported argument type")
|
||||
};
|
||||
|
||||
public SmartPlainText Replace(SmartPlainText plainText)
|
||||
=> Replace(plainText.Text);
|
||||
|
||||
public SmartEmbedText Replace(SmartEmbedText embedData)
|
||||
{
|
||||
var newEmbedData = new SmartEmbedText();
|
||||
newEmbedData.PlainText = Replace(embedData.PlainText);
|
||||
newEmbedData.Description = Replace(embedData.Description);
|
||||
newEmbedData.Title = Replace(embedData.Title);
|
||||
newEmbedData.Thumbnail = Replace(embedData.Thumbnail);
|
||||
newEmbedData.Image = Replace(embedData.Image);
|
||||
if (embedData.Author != null)
|
||||
{
|
||||
newEmbedData.Author = new SmartTextEmbedAuthor();
|
||||
newEmbedData.Author.Name = Replace(embedData.Author.Name);
|
||||
newEmbedData.Author.IconUrl = Replace(embedData.Author.IconUrl);
|
||||
}
|
||||
|
||||
if (embedData.Fields != null)
|
||||
{
|
||||
var fields = new List<SmartTextEmbedField>();
|
||||
foreach (var f in embedData.Fields)
|
||||
{
|
||||
var newF = new SmartTextEmbedField();
|
||||
newF.Name = Replace(f.Name);
|
||||
newF.Value = Replace(f.Value);
|
||||
fields.Add(newF);
|
||||
}
|
||||
|
||||
newEmbedData.Fields = fields.ToArray();
|
||||
}
|
||||
|
||||
if (embedData.Footer != null)
|
||||
{
|
||||
newEmbedData.Footer = new SmartTextEmbedFooter();
|
||||
newEmbedData.Footer.Text = Replace(embedData.Footer.Text);
|
||||
newEmbedData.Footer.IconUrl = Replace(embedData.Footer.IconUrl);
|
||||
}
|
||||
|
||||
newEmbedData.Color = embedData.Color;
|
||||
|
||||
return newEmbedData;
|
||||
}
|
||||
|
||||
public CREmbed Replace(CREmbed embedData)
|
||||
{
|
||||
embedData.PlainText = Replace(embedData.PlainText);
|
||||
|
Reference in New Issue
Block a user