mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Get better timeout messages for self (#1629)
* Don't require mod rights to listen to moderation actions topic * Format timeout messages directed at you differently e.g. "You were banned" or "You were timed out for 4h20m", also including reason if specified.
This commit is contained in:
parent
2ac0b60952
commit
6f926e7d77
2 changed files with 58 additions and 26 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "Application.hpp"
|
||||
#include "common/LinkParser.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
|
@ -170,9 +171,12 @@ MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
|
|||
this->message().searchText = text;
|
||||
}
|
||||
|
||||
// XXX: This does not belong in the MessageBuilder, this should be part of the TwitchMessageBuilder
|
||||
MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||
: MessageBuilder()
|
||||
{
|
||||
auto current = getApp()->accounts->twitch.getCurrent();
|
||||
|
||||
this->emplace<TimestampElement>();
|
||||
this->message().flags.set(MessageFlag::System);
|
||||
this->message().flags.set(MessageFlag::Timeout);
|
||||
|
@ -181,6 +185,36 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
|||
|
||||
QString text;
|
||||
|
||||
if (action.target.id == current->getUserId())
|
||||
{
|
||||
text.append("You were ");
|
||||
if (action.isBan())
|
||||
{
|
||||
text.append("banned");
|
||||
}
|
||||
else
|
||||
{
|
||||
text.append(
|
||||
QString("timed out for %1").arg(formatTime(action.duration)));
|
||||
}
|
||||
|
||||
if (!action.source.name.isEmpty())
|
||||
{
|
||||
text.append(" by ");
|
||||
text.append(action.source.name);
|
||||
}
|
||||
|
||||
if (action.reason.isEmpty())
|
||||
{
|
||||
text.append(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
text.append(QString(": \"%1\".").arg(action.reason));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (action.isBan())
|
||||
{
|
||||
if (action.reason.isEmpty())
|
||||
|
@ -220,6 +254,7 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
|||
text.append(QString(" (%1 times)").arg(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->emplace<TextElement>(text, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
|
|
|
@ -600,9 +600,6 @@ void TwitchChannel::loadRecentMessages()
|
|||
|
||||
void TwitchChannel::refreshPubsub()
|
||||
{
|
||||
// listen to moderation actions
|
||||
if (!this->hasModRights())
|
||||
return;
|
||||
auto roomId = this->roomId();
|
||||
if (roomId.isEmpty())
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue