From 211f6004eb61531b2eec105fb693c6f7092010b5 Mon Sep 17 00:00:00 2001 From: Smitty van Bodegom Date: Fri, 18 Jun 2021 12:04:00 -0400 Subject: [PATCH] Support sending spoilers --- src/actionshandler.cpp | 9 +++++++++ src/commandmodel.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/actionshandler.cpp b/src/actionshandler.cpp index baedc03d3..f5b7db78c 100644 --- a/src/actionshandler.cpp +++ b/src/actionshandler.cpp @@ -128,6 +128,7 @@ void ActionsHandler::postMessage(const QString &text, static const QString htmlPrefix = QStringLiteral("/html "); // TODO static const QString rainbowPrefix = QStringLiteral("/rainbow "); static const QString rainbowmePrefix = QStringLiteral("/rainbowme "); + static const QString spoilerPrefix = QStringLiteral("/spoiler "); static const QString mePrefix = QStringLiteral("/me "); static const QString noticePrefix = QStringLiteral("/notice "); @@ -178,6 +179,14 @@ void ActionsHandler::postMessage(const QString &text, return; } + if (cleanedText.indexOf(spoilerPrefix) == 0) { + cleanedText = cleanedText.remove(0, spoilerPrefix.length()); + const QStringList splittedText = rawText.split(" "); + QString spoilerHtml = QStringLiteral("") % preprocess(cleanedText) % QStringLiteral(""); + m_room->postHtmlMessage(cleanedText, spoilerHtml, RoomMessageEvent::MsgType::Notice, replyEventId, editEventId); + return; + } + if (cleanedText.indexOf(rainbowmePrefix) == 0) { cleanedText = cleanedText.remove(0, rainbowmePrefix.length()); QString rainbowText; diff --git a/src/commandmodel.cpp b/src/commandmodel.cpp index bb34146a4..53408cd13 100644 --- a/src/commandmodel.cpp +++ b/src/commandmodel.cpp @@ -65,6 +65,11 @@ QVariantList CommandModel::commands() QStringLiteral(""), i18n("Sends the given emote coloured as a rainbow")})); + commands.append(QVariant::fromValue(Command{ + QStringLiteral("/spoiler "), + QStringLiteral(""), + i18n("Sends the given message as a spoiler")})); + // Actions commands commands.append(QVariant::fromValue(Command{