- .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

@@ -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)
{