From bbf649bf7090efa89c4d3e943031b4214c05c58a Mon Sep 17 00:00:00 2001 From: TranRed Date: Wed, 1 May 2019 16:08:45 +0200 Subject: [PATCH 1/2] Added {message} parameter for moderation buttons --- src/widgets/helper/ChannelView.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index a1fdf645f..a8ee61b34 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1667,9 +1667,21 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, case Link::UserAction: { QString value = link.value; + value.replace("{user}", layout->getMessage()->loginName) .replace("{channel}", this->channel_->getName()) .replace("{msg-id}", layout->getMessage()->id); + + QString messageText; + if (value.contains("{message}")) + { + messageText = layout->getMessage()->searchText; + // remove name + : + space to only get the actual message text + messageText = messageText.remove( + 0, (layout->getMessage()->loginName.length() + 2)); + value.replace("{message}", messageText); + } + this->channel_->sendMessage(value); } break; From b33478d8c6910781d0b0f8c3699a916ce107fd7a Mon Sep 17 00:00:00 2001 From: TranRed Date: Wed, 1 May 2019 16:43:52 +0200 Subject: [PATCH 2/2] stored original message text in message --- src/messages/Message.hpp | 1 + src/messages/MessageBuilder.cpp | 5 +++++ src/providers/twitch/TwitchMessageBuilder.cpp | 1 + src/widgets/helper/ChannelView.cpp | 13 ++----------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index cdbb2a8d3..c187b5f55 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -48,6 +48,7 @@ struct Message : boost::noncopyable { QTime parseTime; QString id; QString searchText; + QString messageText; QString loginName; QString displayName; QString localizedName; diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp index a029aea35..7b4c64ae8 100644 --- a/src/messages/MessageBuilder.cpp +++ b/src/messages/MessageBuilder.cpp @@ -97,6 +97,7 @@ MessageBuilder::MessageBuilder(const QString &text) this->emplace(); this->emplace(text, MessageElementFlag::Text, MessageColor::System); + this->message().messageText = text; this->message().searchText = text; } @@ -108,6 +109,7 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text) MessageColor::System); this->message().flags.set(MessageFlag::System); this->message().flags.set(MessageFlag::DoNotTriggerNotification); + this->message().messageText = text; this->message().searchText = text; } @@ -158,6 +160,7 @@ MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username, this->emplace(); this->emplace(text, MessageElementFlag::Text, MessageColor::System); + this->message().messageText = text; this->message().searchText = text; } @@ -214,6 +217,7 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count) this->emplace(text, MessageElementFlag::Text, MessageColor::System); + this->message().messageText = text; this->message().searchText = text; } @@ -243,6 +247,7 @@ MessageBuilder::MessageBuilder(const UnbanAction &action) this->emplace(text, MessageElementFlag::Text, MessageColor::System); + this->message().messageText = text; this->message().searchText = text; } diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index b935a2831..8bccc6ea7 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -438,6 +438,7 @@ MessagePtr TwitchMessageBuilder::build() this->addWords(splits, twitchEmotes); + this->message().messageText = this->originalMessage_; this->message().searchText = this->userName + ": " + this->originalMessage_; return this->release(); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index a8ee61b34..07c047eba 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1670,17 +1670,8 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, value.replace("{user}", layout->getMessage()->loginName) .replace("{channel}", this->channel_->getName()) - .replace("{msg-id}", layout->getMessage()->id); - - QString messageText; - if (value.contains("{message}")) - { - messageText = layout->getMessage()->searchText; - // remove name + : + space to only get the actual message text - messageText = messageText.remove( - 0, (layout->getMessage()->loginName.length() + 2)); - value.replace("{message}", messageText); - } + .replace("{msg-id}", layout->getMessage()->id) + .replace("{message}", layout->getMessage()->messageText); this->channel_->sendMessage(value); }