From 3e8c7caefde5d367f2ffc4a1a35ce406eea2ef89 Mon Sep 17 00:00:00 2001 From: Smitty van Bodegom Date: Sun, 20 Jun 2021 11:59:42 -0400 Subject: [PATCH] support table flipping and unflipping --- src/actionshandler.cpp | 14 ++++++++++++++ src/commandmodel.cpp | 10 ++++++++++ src/spellcheckhighlighter.cpp | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/actionshandler.cpp b/src/actionshandler.cpp index f5b7db78c..5b91b9bee 100644 --- a/src/actionshandler.cpp +++ b/src/actionshandler.cpp @@ -124,6 +124,8 @@ void ActionsHandler::postMessage(const QString &text, // Message commands static const QString shrugPrefix = QStringLiteral("/shrug"); static const QString lennyPrefix = QStringLiteral("/lenny"); + static const QString tableflipPrefix = QStringLiteral("/tableflip"); + static const QString unflipPrefix = QStringLiteral("/unflip"); static const QString plainPrefix = QStringLiteral("/plain "); // TODO static const QString htmlPrefix = QStringLiteral("/html "); // TODO static const QString rainbowPrefix = QStringLiteral("/rainbow "); @@ -169,6 +171,18 @@ void ActionsHandler::postMessage(const QString &text, return; } + if (cleanedText.indexOf(tableflipPrefix) == 0) { + cleanedText = QStringLiteral("(╯°□°)╯︵ ┻━┻") % cleanedText.remove(0, tableflipPrefix.length()); + m_room->postHtmlMessage(cleanedText, cleanedText, messageEventType, replyEventId, editEventId); + return; + } + + if (cleanedText.indexOf(unflipPrefix) == 0) { + cleanedText = QStringLiteral("┬──┬ ノ( ゜-゜ノ)") % cleanedText.remove(0, unflipPrefix.length()); + m_room->postHtmlMessage(cleanedText, cleanedText, messageEventType, replyEventId, editEventId); + return; + } + if (cleanedText.indexOf(rainbowPrefix) == 0) { cleanedText = cleanedText.remove(0, rainbowPrefix.length()); QString rainbowText; diff --git a/src/commandmodel.cpp b/src/commandmodel.cpp index 53408cd13..c9f9dd813 100644 --- a/src/commandmodel.cpp +++ b/src/commandmodel.cpp @@ -45,6 +45,16 @@ QVariantList CommandModel::commands() QStringLiteral(""), i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")})); + commands.append(QVariant::fromValue(Command{ + QStringLiteral("/tableflip "), + QStringLiteral(""), + i18n("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message")})); + + commands.append(QVariant::fromValue(Command{ + QStringLiteral("/unflip "), + QStringLiteral(""), + i18n("Prepends ┬──┬ ノ( ゜-゜ノ) to a plain-text message")})); + commands.append(QVariant::fromValue(Command{ QStringLiteral("/plain "), QStringLiteral(""), diff --git a/src/spellcheckhighlighter.cpp b/src/spellcheckhighlighter.cpp index 699f05a66..3aac861a5 100644 --- a/src/spellcheckhighlighter.cpp +++ b/src/spellcheckhighlighter.cpp @@ -116,7 +116,7 @@ static bool isSpellcheckable(const QStringRef &token) return false; } // part of a slash command - if (token.contains("rainbowme") || token.contains("lenny")) { + if (token.contains("rainbowme") || token.contains("lenny") || token.contains("tableflip") || token.contains("unflip")) { return false; } // TODO ignore urls and uppercase?