Made username and color in AutoMod mod messages use correct values (#2967)
We use values given in pubsub messages and handle their edge-cases properly.
This commit is contained in:
@@ -140,25 +140,26 @@ std::pair<MessagePtr, MessagePtr> makeAutomodMessage(
|
||||
// Builder for offender's message
|
||||
builder2.emplace<TimestampElement>();
|
||||
builder2.emplace<TwitchModerationElement>();
|
||||
builder2.message().loginName = action.target.name;
|
||||
builder2.message().loginName = action.target.login;
|
||||
builder2.message().flags.set(MessageFlag::PubSub);
|
||||
|
||||
// sender username
|
||||
builder2
|
||||
.emplace<TextElement>(
|
||||
action.target.name + ":", MessageElementFlag::BoldUsername,
|
||||
MessageColor(QColor("red")), FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
action.target.displayName + ":", MessageElementFlag::BoldUsername,
|
||||
MessageColor(action.target.color), FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
builder2
|
||||
.emplace<TextElement>(action.target.name + ":",
|
||||
.emplace<TextElement>(action.target.displayName + ":",
|
||||
MessageElementFlag::NonBoldUsername,
|
||||
MessageColor(QColor("red")))
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
MessageColor(action.target.color))
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
// sender's message caught by AutoMod
|
||||
builder2.emplace<TextElement>(action.message, MessageElementFlag::Text,
|
||||
MessageColor::Text);
|
||||
builder2.message().flags.set(MessageFlag::AutoMod);
|
||||
auto text2 = QString("%1: %2").arg(action.target.name, action.message);
|
||||
auto text2 =
|
||||
QString("%1: %2").arg(action.target.displayName, action.message);
|
||||
builder2.message().messageText = text2;
|
||||
builder2.message().searchText = text2;
|
||||
|
||||
@@ -277,7 +278,7 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||
this->emplace<TimestampElement>();
|
||||
this->message().flags.set(MessageFlag::System);
|
||||
this->message().flags.set(MessageFlag::Timeout);
|
||||
this->message().timeoutUser = action.target.name;
|
||||
this->message().timeoutUser = action.target.login;
|
||||
this->message().count = count;
|
||||
|
||||
QString text;
|
||||
@@ -296,13 +297,13 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||
text);
|
||||
}
|
||||
|
||||
if (!action.source.name.isEmpty())
|
||||
if (!action.source.login.isEmpty())
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate("by", text);
|
||||
this->emplaceSystemTextAndUpdate(
|
||||
action.source.name + (action.reason.isEmpty() ? "." : ":"),
|
||||
action.source.login + (action.reason.isEmpty() ? "." : ":"),
|
||||
text)
|
||||
->setLink({Link::UserInfo, action.source.name});
|
||||
->setLink({Link::UserInfo, action.source.login});
|
||||
}
|
||||
|
||||
if (!action.reason.isEmpty())
|
||||
@@ -315,29 +316,30 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||
{
|
||||
if (action.isBan())
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate(action.source.name, text)
|
||||
->setLink({Link::UserInfo, action.source.name});
|
||||
this->emplaceSystemTextAndUpdate(action.source.login, text)
|
||||
->setLink({Link::UserInfo, action.source.login});
|
||||
this->emplaceSystemTextAndUpdate("banned", text);
|
||||
if (action.reason.isEmpty())
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate(action.target.name, text)
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
this->emplaceSystemTextAndUpdate(action.target.login, text)
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
}
|
||||
else
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate(action.target.name + ":", text)
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
this->emplaceSystemTextAndUpdate(action.target.login + ":",
|
||||
text)
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
this->emplaceSystemTextAndUpdate(
|
||||
QString("\"%1\".").arg(action.reason), text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate(action.source.name, text)
|
||||
->setLink({Link::UserInfo, action.source.name});
|
||||
this->emplaceSystemTextAndUpdate(action.source.login, text)
|
||||
->setLink({Link::UserInfo, action.source.login});
|
||||
this->emplaceSystemTextAndUpdate("timed out", text);
|
||||
this->emplaceSystemTextAndUpdate(action.target.name, text)
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
this->emplaceSystemTextAndUpdate(action.target.login, text)
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
if (action.reason.isEmpty())
|
||||
{
|
||||
this->emplaceSystemTextAndUpdate(
|
||||
@@ -371,16 +373,16 @@ MessageBuilder::MessageBuilder(const UnbanAction &action)
|
||||
this->message().flags.set(MessageFlag::System);
|
||||
this->message().flags.set(MessageFlag::Untimeout);
|
||||
|
||||
this->message().timeoutUser = action.target.name;
|
||||
this->message().timeoutUser = action.target.login;
|
||||
|
||||
QString text;
|
||||
|
||||
this->emplaceSystemTextAndUpdate(action.source.name, text)
|
||||
->setLink({Link::UserInfo, action.source.name});
|
||||
this->emplaceSystemTextAndUpdate(action.source.login, text)
|
||||
->setLink({Link::UserInfo, action.source.login});
|
||||
this->emplaceSystemTextAndUpdate(
|
||||
action.wasBan() ? "unbanned" : "untimedout", text);
|
||||
this->emplaceSystemTextAndUpdate(action.target.name, text)
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
this->emplaceSystemTextAndUpdate(action.target.login, text)
|
||||
->setLink({Link::UserInfo, action.target.login});
|
||||
|
||||
this->message().messageText = text;
|
||||
this->message().searchText = text;
|
||||
@@ -397,31 +399,31 @@ MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
||||
{
|
||||
case AutomodUserAction::AddPermitted: {
|
||||
text = QString("%1 added %2 as a permitted term on AutoMod.")
|
||||
.arg(action.source.name, action.message);
|
||||
.arg(action.source.login, action.message);
|
||||
}
|
||||
break;
|
||||
|
||||
case AutomodUserAction::AddBlocked: {
|
||||
text = QString("%1 added %2 as a blocked term on AutoMod.")
|
||||
.arg(action.source.name, action.message);
|
||||
.arg(action.source.login, action.message);
|
||||
}
|
||||
break;
|
||||
|
||||
case AutomodUserAction::RemovePermitted: {
|
||||
text = QString("%1 removed %2 as a permitted term on AutoMod.")
|
||||
.arg(action.source.name, action.message);
|
||||
.arg(action.source.login, action.message);
|
||||
}
|
||||
break;
|
||||
|
||||
case AutomodUserAction::RemoveBlocked: {
|
||||
text = QString("%1 removed %2 as a blocked term on AutoMod.")
|
||||
.arg(action.source.name, action.message);
|
||||
.arg(action.source.login, action.message);
|
||||
}
|
||||
break;
|
||||
|
||||
case AutomodUserAction::Properties: {
|
||||
text = QString("%1 modified the AutoMod properties.")
|
||||
.arg(action.source.name);
|
||||
.arg(action.source.login);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user