support table flipping and unflipping

This commit is contained in:
Smitty van Bodegom
2021-06-20 11:59:42 -04:00
parent b1d8956036
commit 3e8c7caefd
3 changed files with 25 additions and 1 deletions

View File

@@ -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;

View File

@@ -45,6 +45,16 @@ QVariantList CommandModel::commands()
QStringLiteral("<message>"),
i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")}));
commands.append(QVariant::fromValue(Command{
QStringLiteral("/tableflip "),
QStringLiteral("<message>"),
i18n("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message")}));
commands.append(QVariant::fromValue(Command{
QStringLiteral("/unflip "),
QStringLiteral("<message>"),
i18n("Prepends ┬──┬ ( ゜-゜ノ) to a plain-text message")}));
commands.append(QVariant::fromValue(Command{
QStringLiteral("/plain "),
QStringLiteral("<message>"),

View File

@@ -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?