- .say replacement fix

- .send and .qid now use smarttext instead of crembed
- added + operator for adding string to smarttext
This commit is contained in:
Kwoth
2021-07-12 01:45:40 +02:00
parent 0064df8ae4
commit 373e9e920d
6 changed files with 36 additions and 52 deletions

View File

@@ -5,7 +5,7 @@ using NadekoBot.Services;
namespace NadekoBot
{
public sealed class SmartEmbedText : SmartText
public sealed record SmartEmbedText : SmartText
{
public string PlainText { get; set; }
public string Title { get; set; }

View File

@@ -1,8 +1,8 @@
namespace NadekoBot
{
public sealed class SmartPlainText : SmartText
public sealed record SmartPlainText : SmartText
{
public string Text { get; set; }
public string Text { get; init; }
public SmartPlainText(string text)
{

View File

@@ -1,14 +1,28 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
namespace NadekoBot
{
public abstract class SmartText
public abstract record SmartText
{
public bool IsEmbed => this is SmartEmbedText;
public bool IsPlainText => this is SmartPlainText;
public static implicit operator SmartText(string input)
=> new SmartPlainText(input);
public static SmartText operator +(SmartText text, string input)
=> text switch
{
SmartEmbedText set => set with { PlainText = set.PlainText + input },
SmartPlainText spt => new SmartPlainText(spt.Text + input),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static SmartText operator +(string input, SmartText text)
=> text switch
{
SmartEmbedText set => set with { PlainText = input + set.PlainText },
SmartPlainText spt => new SmartPlainText(input + spt.Text),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static SmartText CreateFrom(string input)
{