Skip to content

Commit

Permalink
printer: Fix emotes in aux[$-2] bleeding through
Browse files Browse the repository at this point in the history
  • Loading branch information
zorael committed Dec 17, 2023
1 parent 6bac539 commit 122cf17
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/kameloso/plugins/printer/formatting.d
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void formatMessageMonochrome(Sink)
putSender();

bool putQuotedTwitchMessage;
auto auxRange = event.aux[].filter!(s => s.length);
string[event.aux.length] auxCopy = event.aux;

version(TwitchSupport)
{
Expand All @@ -440,7 +440,7 @@ void formatMessageMonochrome(Sink)
putTarget();
.put(sink, `: "`, event.aux[0], '"');
putQuotedTwitchMessage = true;
auxRange.popFront();
auxCopy[0] = string.init;
}
}

Expand All @@ -450,6 +450,8 @@ void formatMessageMonochrome(Sink)
if (content.length) putContent();
}

// Base the range on the modified copy
auto auxRange = auxCopy[].filter!(s => s.length);
if (!auxRange.empty)
{
enum pattern = " (%-(%s%|) (%))";
Expand All @@ -468,7 +470,6 @@ void formatMessageMonochrome(Sink)
}

auto countRange = event.count[].filter!(n => !n.isNull);

if (!countRange.empty)
{
enum pattern = " {%-(%s%|} {%)}";
Expand Down Expand Up @@ -1116,7 +1117,7 @@ void formatMessageColoured(Sink)
putSender();

bool putQuotedTwitchMessage;
auto auxRange = event.aux[].filter!(s => s.length);
string[event.aux.length] auxCopy = event.aux;

version(TwitchSupport)
{
Expand Down Expand Up @@ -1160,6 +1161,9 @@ void formatMessageColoured(Sink)
cast(Flag!"colourful")plugin.printerSettings.colourfulEmotes,
plugin.state.settings);
.put(sink, `: "`, customEmoteSink.data, '"');

// Remove the custom emote definitions
auxCopy[$-2] = string.init;
}
else
{
Expand All @@ -1168,7 +1172,7 @@ void formatMessageColoured(Sink)
}

putQuotedTwitchMessage = true;
auxRange.popFront();
auxCopy[0] = string.init;
}
}

Expand All @@ -1178,6 +1182,8 @@ void formatMessageColoured(Sink)
if (content.length) putContent();
}

// Base the range on the modified copy
auto auxRange = auxCopy[].filter!(s => s.length);
if (!auxRange.empty)
{
enum pattern = " (%-(%s%|) (%))";
Expand All @@ -1197,7 +1203,6 @@ void formatMessageColoured(Sink)
}

auto countRange = event.count[].filter!(n => !n.isNull);

if (!countRange.empty)
{
enum pattern = " {%-(%s%|} {%)}";
Expand Down

0 comments on commit 122cf17

Please sign in to comment.