mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
add notice and rainbownotice commands
This commit is contained in:
parent
7d6bd67615
commit
2e597263a2
2 changed files with 34 additions and 0 deletions
|
@ -349,6 +349,35 @@ InputBar::emote(QString msg, bool rainbowify)
|
||||||
room->sendMessageEvent(emote, mtx::events::EventType::RoomMessage);
|
room->sendMessageEvent(emote, mtx::events::EventType::RoomMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
InputBar::image(const QString &filename,
|
InputBar::image(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
|
@ -531,6 +560,10 @@ InputBar::command(QString command, QString args)
|
||||||
message(args, MarkdownOverride::ON, true);
|
message(args, MarkdownOverride::ON, true);
|
||||||
} else if (command == "rainbowme") {
|
} else if (command == "rainbowme") {
|
||||||
emote(args, true);
|
emote(args, true);
|
||||||
|
} else if (command == "notice") {
|
||||||
|
notice(args, false);
|
||||||
|
} else if (command == "rainbownotice") {
|
||||||
|
notice(args, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emote(QString body, bool rainbowify);
|
void emote(QString body, bool rainbowify);
|
||||||
|
void notice(QString body, bool rainbowify);
|
||||||
void command(QString name, QString args);
|
void command(QString name, QString args);
|
||||||
void image(const QString &filename,
|
void image(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
|
|
Loading…
Reference in a new issue