Support sending spoilers
This commit is contained in:
@@ -128,6 +128,7 @@ void ActionsHandler::postMessage(const QString &text,
|
|||||||
static const QString htmlPrefix = QStringLiteral("/html "); // TODO
|
static const QString htmlPrefix = QStringLiteral("/html "); // TODO
|
||||||
static const QString rainbowPrefix = QStringLiteral("/rainbow ");
|
static const QString rainbowPrefix = QStringLiteral("/rainbow ");
|
||||||
static const QString rainbowmePrefix = QStringLiteral("/rainbowme ");
|
static const QString rainbowmePrefix = QStringLiteral("/rainbowme ");
|
||||||
|
static const QString spoilerPrefix = QStringLiteral("/spoiler ");
|
||||||
static const QString mePrefix = QStringLiteral("/me ");
|
static const QString mePrefix = QStringLiteral("/me ");
|
||||||
static const QString noticePrefix = QStringLiteral("/notice ");
|
static const QString noticePrefix = QStringLiteral("/notice ");
|
||||||
|
|
||||||
@@ -178,6 +179,14 @@ void ActionsHandler::postMessage(const QString &text,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cleanedText.indexOf(spoilerPrefix) == 0) {
|
||||||
|
cleanedText = cleanedText.remove(0, spoilerPrefix.length());
|
||||||
|
const QStringList splittedText = rawText.split(" ");
|
||||||
|
QString spoilerHtml = QStringLiteral("<span data-mx-spoiler>") % preprocess(cleanedText) % QStringLiteral("</span>");
|
||||||
|
m_room->postHtmlMessage(cleanedText, spoilerHtml, RoomMessageEvent::MsgType::Notice, replyEventId, editEventId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cleanedText.indexOf(rainbowmePrefix) == 0) {
|
if (cleanedText.indexOf(rainbowmePrefix) == 0) {
|
||||||
cleanedText = cleanedText.remove(0, rainbowmePrefix.length());
|
cleanedText = cleanedText.remove(0, rainbowmePrefix.length());
|
||||||
QString rainbowText;
|
QString rainbowText;
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ QVariantList CommandModel::commands()
|
|||||||
QStringLiteral("<message>"),
|
QStringLiteral("<message>"),
|
||||||
i18n("Sends the given emote coloured as a rainbow")}));
|
i18n("Sends the given emote coloured as a rainbow")}));
|
||||||
|
|
||||||
|
commands.append(QVariant::fromValue(Command{
|
||||||
|
QStringLiteral("/spoiler "),
|
||||||
|
QStringLiteral("<message>"),
|
||||||
|
i18n("Sends the given message as a spoiler")}));
|
||||||
|
|
||||||
|
|
||||||
// Actions commands
|
// Actions commands
|
||||||
commands.append(QVariant::fromValue(Command{
|
commands.append(QVariant::fromValue(Command{
|
||||||
|
|||||||
Reference in New Issue
Block a user