mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
- .say replacement fix
- .send and .qid now use smarttext instead of crembed - added + operator for adding string to smarttext
This commit is contained in:
@@ -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; }
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user