diff options
author | Loren Burkholder <55629213+LorenDB@users.noreply.github.com> | 2022-12-10 10:17:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-10 10:17:15 -0500 |
commit | fa0c14b84681b94ff2136d6b7480c8b7283ad96a (patch) | |
tree | 483acc16811d00af5d13a5c196fe64f2aa3ff491 /src/timeline/InputBar.cpp | |
parent | Translated using Weblate (French) (diff) | |
download | nheko-fa0c14b84681b94ff2136d6b7480c8b7283ad96a.tar.xz |
confetti (#1243)
* 🎉 (confetti) message support. Thanks @LorenDB !
Diffstat (limited to 'src/timeline/InputBar.cpp')
-rw-r--r-- | src/timeline/InputBar.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index a9afb01c..94955152 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -535,6 +535,27 @@ InputBar::notice(const QString &msg, bool rainbowify) } void +InputBar::confetti(const QString &body, bool rainbowify) +{ + auto html = utils::markdownToHtml(body, rainbowify); + + mtx::events::msg::Confetti confetti; + confetti.body = body.trimmed().toStdString(); + + if (html != body.trimmed().toHtmlEscaped() && + ChatPage::instance()->userSettings()->markdown()) { + confetti.formatted_body = html.toStdString(); + confetti.format = "org.matrix.custom.html"; + // Remove markdown links by completer + confetti.body = replaceMatrixToMarkdownLink(body.trimmed()).toStdString(); + } + + confetti.relations = generateRelations(); + + room->sendMessageEvent(confetti, mtx::events::EventType::RoomMessage); +} + +void InputBar::image(const QString &filename, const std::optional<mtx::crypto::EncryptedFile> &file, const QString &url, @@ -777,6 +798,10 @@ InputBar::command(const QString &command, QString args) notice(args, false); } else if (command == QLatin1String("rainbownotice")) { notice(args, true); + } else if (command == QLatin1String("confetti")) { + confetti(args, false); + } else if (command == QLatin1String("rainbowconfetti")) { + confetti(args, true); } else if (command == QLatin1String("goto")) { // Goto has three different modes: // 1 - Going directly to a given event ID |