embedCustomEmotes

Embeds custom emotes into the emotes string passed by reference, so that the PrinterPlugin can highlight content with colours.

This is called in postprocess.

version(TwitchSupport && WithTwitchPlugin)
void
embedCustomEmotes
(
const string content
,
ref string emotes
,
const bool[dstring] customEmotes
,
const bool[dstring] customGlobalEmotes
)

Parameters

content string

Content string.

emotes string

Reference string into which to save the emote list.

customEmotes bool[dstring]

bool[dstring] associative array of channel-specific custom emotes.

customGlobalEmotes bool[dstring]

bool[dstring] associative array of global custom emotes.

Examples

bool[dstring] customEmotes =
[
    ":tf:"d : true,
    "FrankerZ"d : true,
    "NOTED"d : true,
];

bool[dstring] customGlobalEmotes =
[
    "KEKW"d : true,
    "NotLikeThis"d : true,
    "gg"d : true,
];

{
    enum content = "come on its easy, now rest then talk talk more left, left, " ~
        "right re st, up, down talk some rest a bit talk poop  :tf:";
    string emotes;
    embedCustomEmotes(content, emotes, customEmotes, customGlobalEmotes);
    enum expectedEmotes = ";tf;:113-116";
    assert((emotes == expectedEmotes), emotes);
}
{
    enum content = "NOTED  FrankerZ  NOTED NOTED    gg";
    string emotes;
    embedCustomEmotes(content, emotes, customEmotes, customGlobalEmotes);
    enum expectedEmotes = "NOTED:0-4/FrankerZ:7-14/NOTED:17-21,23-27/gg:32-33";
    assert((emotes == expectedEmotes), emotes);
}
{
    enum content = "No emotes here KAPPA";
    string emotes;
    embedCustomEmotes(content, emotes, customEmotes, customGlobalEmotes);
    enum expectedEmotes = string.init;
    assert((emotes == expectedEmotes), emotes);
}