Merge pull request #928 from apa420/apa-automod-small-rewrite
Rewrote the cases with enums for the automod implementation
This commit is contained in:
@@ -244,34 +244,46 @@ MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
|||||||
this->message().flags.set(MessageFlag::System);
|
this->message().flags.set(MessageFlag::System);
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if (action.type == 1)
|
switch (action.type)
|
||||||
{
|
{
|
||||||
text = QString("%1 added %2 as a permitted term on AutoMod.")
|
case action.AddPermitted:
|
||||||
.arg(action.source.name)
|
{
|
||||||
.arg(action.message);
|
text = QString("%1 added %2 as a permitted term on AutoMod.")
|
||||||
}
|
.arg(action.source.name)
|
||||||
else if (action.type == 2)
|
.arg(action.message);
|
||||||
{
|
}
|
||||||
text = QString("%1 added %2 as a blocked term on AutoMod.")
|
break;
|
||||||
.arg(action.source.name)
|
|
||||||
.arg(action.message);
|
case action.AddBlocked:
|
||||||
}
|
{
|
||||||
else if (action.type == 3)
|
text = QString("%1 added %2 as a blocked term on AutoMod.")
|
||||||
{
|
.arg(action.source.name)
|
||||||
text = QString("%1 removed %2 as a permitted term term on AutoMod.")
|
.arg(action.message);
|
||||||
.arg(action.source.name)
|
}
|
||||||
.arg(action.message);
|
break;
|
||||||
}
|
|
||||||
else if (action.type == 4)
|
case action.RemovePermitted:
|
||||||
{
|
{
|
||||||
text = QString("%1 removed %2 as a blocked term on AutoMod.")
|
text = QString("%1 removed %2 as a permitted term term on AutoMod.")
|
||||||
.arg(action.source.name)
|
.arg(action.source.name)
|
||||||
.arg(action.message);
|
.arg(action.message);
|
||||||
}
|
}
|
||||||
else if (action.type == 5)
|
break;
|
||||||
{
|
|
||||||
text = QString("%1 modified the AutoMod properties.")
|
case action.RemoveBlocked:
|
||||||
.arg(action.source.name);
|
{
|
||||||
|
text = QString("%1 removed %2 as a blocked term on AutoMod.")
|
||||||
|
.arg(action.source.name)
|
||||||
|
.arg(action.message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case action.Properties:
|
||||||
|
{
|
||||||
|
text = QString("%1 modified the AutoMod properties.")
|
||||||
|
.arg(action.source.name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->emplace<TextElement>(text, MessageElementFlag::Text,
|
this->emplace<TextElement>(text, MessageElementFlag::Text,
|
||||||
|
|||||||
@@ -122,9 +122,15 @@ struct AutomodUserAction : PubSubAction {
|
|||||||
|
|
||||||
ActionUser target;
|
ActionUser target;
|
||||||
|
|
||||||
QString message;
|
enum {
|
||||||
|
AddPermitted,
|
||||||
|
RemovePermitted,
|
||||||
|
AddBlocked,
|
||||||
|
RemoveBlocked,
|
||||||
|
Properties,
|
||||||
|
} type;
|
||||||
|
|
||||||
qint8 type;
|
QString message;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ PubSub::PubSub()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto &args = getArgs(data);
|
const auto &args = getArgs(data);
|
||||||
action.type = 1;
|
action.type = AutomodUserAction::AddPermitted;
|
||||||
|
|
||||||
if (args.Size() < 1)
|
if (args.Size() < 1)
|
||||||
{
|
{
|
||||||
@@ -610,7 +610,7 @@ PubSub::PubSub()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto &args = getArgs(data);
|
const auto &args = getArgs(data);
|
||||||
action.type = 2;
|
action.type = AutomodUserAction::AddBlocked;
|
||||||
|
|
||||||
if (args.Size() < 1)
|
if (args.Size() < 1)
|
||||||
{
|
{
|
||||||
@@ -639,7 +639,7 @@ PubSub::PubSub()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto &args = getArgs(data);
|
const auto &args = getArgs(data);
|
||||||
action.type = 3;
|
action.type = AutomodUserAction::RemovePermitted;
|
||||||
|
|
||||||
if (args.Size() < 1)
|
if (args.Size() < 1)
|
||||||
{
|
{
|
||||||
@@ -669,7 +669,7 @@ PubSub::PubSub()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto &args = getArgs(data);
|
const auto &args = getArgs(data);
|
||||||
action.type = 4;
|
action.type = AutomodUserAction::RemoveBlocked;
|
||||||
|
|
||||||
if (args.Size() < 1)
|
if (args.Size() < 1)
|
||||||
{
|
{
|
||||||
@@ -694,7 +694,7 @@ PubSub::PubSub()
|
|||||||
// The automod settings got modified
|
// The automod settings got modified
|
||||||
AutomodUserAction action(data, roomID);
|
AutomodUserAction action(data, roomID);
|
||||||
getCreatedByUser(data, action.source);
|
getCreatedByUser(data, action.source);
|
||||||
action.type = 5;
|
action.type = AutomodUserAction::Properties;
|
||||||
this->signals_.moderation.automodUserMessage.invoke(action);
|
this->signals_.moderation.automodUserMessage.invoke(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user