feat(eventsub): implement AutoMod term actions (#6000)

This commit is contained in:
nerix
2025-02-27 18:12:42 +01:00
committed by GitHub
parent a89c1910ba
commit 814734e869
13 changed files with 1784 additions and 9 deletions
@@ -282,11 +282,11 @@ struct AutomodTerms {
static constexpr std::string_view FIELD = "automod_terms";
// either add or remove
std::string action;
String action;
// either blocked or permitted
std::string list;
String list;
std::vector<std::string> terms;
std::vector<String> terms;
bool fromAutomod;
};
@@ -872,7 +872,7 @@ boost::json::result_for<AutomodTerms, boost::json::value>::type tag_invoke(
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
}
auto action = boost::json::try_value_to<std::string>(*jvaction);
auto action = boost::json::try_value_to<String>(*jvaction);
if (action.has_error())
{
@@ -885,19 +885,19 @@ boost::json::result_for<AutomodTerms, boost::json::value>::type tag_invoke(
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
}
auto list = boost::json::try_value_to<std::string>(*jvlist);
auto list = boost::json::try_value_to<String>(*jvlist);
if (list.has_error())
{
return list.error();
}
std::vector<std::string> vterms;
std::vector<chatterino::eventsub::lib::String> vterms;
const auto *jvterms = root.if_contains("terms");
if (jvterms != nullptr && !jvterms->is_null())
{
auto terms =
boost::json::try_value_to<std::vector<std::string>>(*jvterms);
auto terms = boost::json::try_value_to<
std::vector<chatterino::eventsub::lib::String>>(*jvterms);
if (terms.has_error())
{
return terms.error();