summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-04-11 20:15:26 +0000
committerGitHub <noreply@github.com>2021-04-11 20:15:26 +0000
commit9d97f9f7053ec596d8045306d6f508279915eb0c (patch)
tree415474b87003cb646e53e929e12ec4ec178f2049 /src
parentImprove sorting a bit and fix some bugs in edge cases (diff)
parentadd notice and rainbownotice commands (diff)
downloadnheko-9d97f9f7053ec596d8045306d6f508279915eb0c.tar.xz
Merge pull request #547 from LordMZTE/feature/notice
add notice and rainbownotice commands
Diffstat (limited to 'src')
-rw-r--r--src/timeline/InputBar.cpp33
-rw-r--r--src/timeline/InputBar.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp

index 38c08d1c..cda38b75 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -350,6 +350,35 @@ InputBar::emote(QString msg, bool rainbowify) } void +InputBar::notice(QString msg, bool rainbowify) +{ + auto html = utils::markdownToHtml(msg, rainbowify); + + mtx::events::msg::Notice notice; + notice.body = msg.trimmed().toStdString(); + + if (html != msg.trimmed().toHtmlEscaped() && + ChatPage::instance()->userSettings()->markdown()) { + notice.formatted_body = html.toStdString(); + notice.format = "org.matrix.custom.html"; + // Remove markdown links by completer + notice.body = + msg.trimmed().replace(conf::strings::matrixToMarkdownLink, "\\1").toStdString(); + } + + if (!room->reply().isEmpty()) { + notice.relations.relations.push_back( + {mtx::common::RelationType::InReplyTo, room->reply().toStdString()}); + } + if (!room->edit().isEmpty()) { + notice.relations.relations.push_back( + {mtx::common::RelationType::Replace, room->edit().toStdString()}); + } + + room->sendMessageEvent(notice, mtx::events::EventType::RoomMessage); +} + +void InputBar::image(const QString &filename, const std::optional<mtx::crypto::EncryptedFile> &file, const QString &url, @@ -531,6 +560,10 @@ InputBar::command(QString command, QString args) message(args, MarkdownOverride::ON, true); } else if (command == "rainbowme") { emote(args, true); + } else if (command == "notice") { + notice(args, false); + } else if (command == "rainbownotice") { + notice(args, true); } } diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index 613b5f9a..9db16bae 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h
@@ -68,6 +68,7 @@ signals: private: void emote(QString body, bool rainbowify); + void notice(QString body, bool rainbowify); void command(QString name, QString args); void image(const QString &filename, const std::optional<mtx::crypto::EncryptedFile> &file,