feat(eventsub): add automod.message.* and channel.suspicious_user.* (#6003)
This commit is contained in:
@@ -0,0 +1,253 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/automod-message-hold-v2.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::payload::automod_message_hold::v2 {
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbroadcasterUserID = root.if_contains("broadcaster_user_id");
|
||||
if (jvbroadcasterUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserID =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserID);
|
||||
|
||||
if (broadcasterUserID.has_error())
|
||||
{
|
||||
return broadcasterUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserLogin =
|
||||
root.if_contains("broadcaster_user_login");
|
||||
if (jvbroadcasterUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserLogin);
|
||||
|
||||
if (broadcasterUserLogin.has_error())
|
||||
{
|
||||
return broadcasterUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserName =
|
||||
root.if_contains("broadcaster_user_name");
|
||||
if (jvbroadcasterUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserName =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserName);
|
||||
|
||||
if (broadcasterUserName.has_error())
|
||||
{
|
||||
return broadcasterUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvmessageID = root.if_contains("message_id");
|
||||
if (jvmessageID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto messageID = boost::json::try_value_to<std::string>(*jvmessageID);
|
||||
|
||||
if (messageID.has_error())
|
||||
{
|
||||
return messageID.error();
|
||||
}
|
||||
|
||||
const auto *jvmessage = root.if_contains("message");
|
||||
if (jvmessage == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<chat::Message>(*jvmessage);
|
||||
|
||||
if (message.has_error())
|
||||
{
|
||||
return message.error();
|
||||
}
|
||||
|
||||
const auto *jvheldAt = root.if_contains("held_at");
|
||||
if (jvheldAt == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto heldAt = boost::json::try_value_to<std::string>(*jvheldAt);
|
||||
|
||||
if (heldAt.has_error())
|
||||
{
|
||||
return heldAt.error();
|
||||
}
|
||||
|
||||
const auto *jvreasonTag = root.if_contains("reason");
|
||||
if (jvreasonTag == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto reasonTagRes =
|
||||
boost::json::try_value_to<boost::json::string>(*jvreasonTag);
|
||||
if (reasonTagRes.has_error())
|
||||
{
|
||||
return reasonTagRes.error();
|
||||
}
|
||||
std::string_view reasonTag = *reasonTagRes;
|
||||
decltype(std::declval<Event>().reason) reason;
|
||||
if (reasonTag == automod::AutomodReason::TAG)
|
||||
{
|
||||
const auto *reasonVal =
|
||||
root.if_contains(detail::fieldFor<automod::AutomodReason>());
|
||||
if (!reasonVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto reasonautomodAutomodReason =
|
||||
boost::json::try_value_to<automod::AutomodReason>(*reasonVal);
|
||||
if (reasonautomodAutomodReason.has_error())
|
||||
{
|
||||
return reasonautomodAutomodReason.error();
|
||||
}
|
||||
reason.emplace<automod::AutomodReason>(
|
||||
std::move(reasonautomodAutomodReason.value()));
|
||||
}
|
||||
else if (reasonTag == automod::BlockedTermReason::TAG)
|
||||
{
|
||||
const auto *reasonVal =
|
||||
root.if_contains(detail::fieldFor<automod::BlockedTermReason>());
|
||||
if (!reasonVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto reasonautomodBlockedTermReason =
|
||||
boost::json::try_value_to<automod::BlockedTermReason>(*reasonVal);
|
||||
if (reasonautomodBlockedTermReason.has_error())
|
||||
{
|
||||
return reasonautomodBlockedTermReason.error();
|
||||
}
|
||||
reason.emplace<automod::BlockedTermReason>(
|
||||
std::move(reasonautomodBlockedTermReason.value()));
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::UnknownVariant);
|
||||
}
|
||||
|
||||
return Event{
|
||||
.broadcasterUserID = std::move(broadcasterUserID.value()),
|
||||
.broadcasterUserLogin = std::move(broadcasterUserLogin.value()),
|
||||
.broadcasterUserName = std::move(broadcasterUserName.value()),
|
||||
.userID = std::move(userID.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.messageID = std::move(messageID.value()),
|
||||
.message = std::move(message.value()),
|
||||
.heldAt = std::move(heldAt.value()),
|
||||
.reason = std::move(reason),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Payload> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsubscription = root.if_contains("subscription");
|
||||
if (jvsubscription == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto subscription =
|
||||
boost::json::try_value_to<subscription::Subscription>(*jvsubscription);
|
||||
|
||||
if (subscription.has_error())
|
||||
{
|
||||
return subscription.error();
|
||||
}
|
||||
|
||||
const auto *jvevent = root.if_contains("event");
|
||||
if (jvevent == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto event = boost::json::try_value_to<Event>(*jvevent);
|
||||
|
||||
if (event.has_error())
|
||||
{
|
||||
return event.error();
|
||||
}
|
||||
|
||||
return Payload{
|
||||
.subscription = std::move(subscription.value()),
|
||||
.event = std::move(event.value()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::payload::automod_message_hold::v2
|
||||
@@ -0,0 +1,312 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/automod-message-update-v2.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::payload::automod_message_update::v2 {
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbroadcasterUserID = root.if_contains("broadcaster_user_id");
|
||||
if (jvbroadcasterUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserID =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserID);
|
||||
|
||||
if (broadcasterUserID.has_error())
|
||||
{
|
||||
return broadcasterUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserLogin =
|
||||
root.if_contains("broadcaster_user_login");
|
||||
if (jvbroadcasterUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserLogin);
|
||||
|
||||
if (broadcasterUserLogin.has_error())
|
||||
{
|
||||
return broadcasterUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserName =
|
||||
root.if_contains("broadcaster_user_name");
|
||||
if (jvbroadcasterUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserName =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserName);
|
||||
|
||||
if (broadcasterUserName.has_error())
|
||||
{
|
||||
return broadcasterUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserID = root.if_contains("moderator_user_id");
|
||||
if (jvmoderatorUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserID =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserID);
|
||||
|
||||
if (moderatorUserID.has_error())
|
||||
{
|
||||
return moderatorUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserLogin = root.if_contains("moderator_user_login");
|
||||
if (jvmoderatorUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserLogin);
|
||||
|
||||
if (moderatorUserLogin.has_error())
|
||||
{
|
||||
return moderatorUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserName = root.if_contains("moderator_user_name");
|
||||
if (jvmoderatorUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserName =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserName);
|
||||
|
||||
if (moderatorUserName.has_error())
|
||||
{
|
||||
return moderatorUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvmessageID = root.if_contains("message_id");
|
||||
if (jvmessageID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto messageID = boost::json::try_value_to<std::string>(*jvmessageID);
|
||||
|
||||
if (messageID.has_error())
|
||||
{
|
||||
return messageID.error();
|
||||
}
|
||||
|
||||
const auto *jvmessage = root.if_contains("message");
|
||||
if (jvmessage == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<chat::Message>(*jvmessage);
|
||||
|
||||
if (message.has_error())
|
||||
{
|
||||
return message.error();
|
||||
}
|
||||
|
||||
const auto *jvstatus = root.if_contains("status");
|
||||
if (jvstatus == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto status = boost::json::try_value_to<std::string>(*jvstatus);
|
||||
|
||||
if (status.has_error())
|
||||
{
|
||||
return status.error();
|
||||
}
|
||||
|
||||
const auto *jvheldAt = root.if_contains("held_at");
|
||||
if (jvheldAt == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto heldAt = boost::json::try_value_to<std::string>(*jvheldAt);
|
||||
|
||||
if (heldAt.has_error())
|
||||
{
|
||||
return heldAt.error();
|
||||
}
|
||||
|
||||
const auto *jvreasonTag = root.if_contains("reason");
|
||||
if (jvreasonTag == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto reasonTagRes =
|
||||
boost::json::try_value_to<boost::json::string>(*jvreasonTag);
|
||||
if (reasonTagRes.has_error())
|
||||
{
|
||||
return reasonTagRes.error();
|
||||
}
|
||||
std::string_view reasonTag = *reasonTagRes;
|
||||
decltype(std::declval<Event>().reason) reason;
|
||||
if (reasonTag == automod::AutomodReason::TAG)
|
||||
{
|
||||
const auto *reasonVal =
|
||||
root.if_contains(detail::fieldFor<automod::AutomodReason>());
|
||||
if (!reasonVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto reasonautomodAutomodReason =
|
||||
boost::json::try_value_to<automod::AutomodReason>(*reasonVal);
|
||||
if (reasonautomodAutomodReason.has_error())
|
||||
{
|
||||
return reasonautomodAutomodReason.error();
|
||||
}
|
||||
reason.emplace<automod::AutomodReason>(
|
||||
std::move(reasonautomodAutomodReason.value()));
|
||||
}
|
||||
else if (reasonTag == automod::BlockedTermReason::TAG)
|
||||
{
|
||||
const auto *reasonVal =
|
||||
root.if_contains(detail::fieldFor<automod::BlockedTermReason>());
|
||||
if (!reasonVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto reasonautomodBlockedTermReason =
|
||||
boost::json::try_value_to<automod::BlockedTermReason>(*reasonVal);
|
||||
if (reasonautomodBlockedTermReason.has_error())
|
||||
{
|
||||
return reasonautomodBlockedTermReason.error();
|
||||
}
|
||||
reason.emplace<automod::BlockedTermReason>(
|
||||
std::move(reasonautomodBlockedTermReason.value()));
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::UnknownVariant);
|
||||
}
|
||||
|
||||
return Event{
|
||||
.broadcasterUserID = std::move(broadcasterUserID.value()),
|
||||
.broadcasterUserLogin = std::move(broadcasterUserLogin.value()),
|
||||
.broadcasterUserName = std::move(broadcasterUserName.value()),
|
||||
.userID = std::move(userID.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.moderatorUserID = std::move(moderatorUserID.value()),
|
||||
.moderatorUserLogin = std::move(moderatorUserLogin.value()),
|
||||
.moderatorUserName = std::move(moderatorUserName.value()),
|
||||
.messageID = std::move(messageID.value()),
|
||||
.message = std::move(message.value()),
|
||||
.status = std::move(status.value()),
|
||||
.heldAt = std::move(heldAt.value()),
|
||||
.reason = std::move(reason),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Payload> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsubscription = root.if_contains("subscription");
|
||||
if (jvsubscription == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto subscription =
|
||||
boost::json::try_value_to<subscription::Subscription>(*jvsubscription);
|
||||
|
||||
if (subscription.has_error())
|
||||
{
|
||||
return subscription.error();
|
||||
}
|
||||
|
||||
const auto *jvevent = root.if_contains("event");
|
||||
if (jvevent == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto event = boost::json::try_value_to<Event>(*jvevent);
|
||||
|
||||
if (event.has_error())
|
||||
{
|
||||
return event.error();
|
||||
}
|
||||
|
||||
return Payload{
|
||||
.subscription = std::move(subscription.value()),
|
||||
.event = std::move(event.value()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::payload::automod_message_update::v2
|
||||
@@ -0,0 +1,242 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/automod-message.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::automod {
|
||||
|
||||
boost::json::result_for<Boundary, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Boundary> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
|
||||
decltype(std::declval<Boundary>().startPos)>>);
|
||||
const auto *jvstartPos = root.if_contains("start_pos");
|
||||
if (jvstartPos == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto startPos = boost::json::try_value_to<int>(*jvstartPos);
|
||||
|
||||
if (startPos.has_error())
|
||||
{
|
||||
return startPos.error();
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
|
||||
decltype(std::declval<Boundary>().endPos)>>);
|
||||
const auto *jvendPos = root.if_contains("end_pos");
|
||||
if (jvendPos == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto endPos = boost::json::try_value_to<int>(*jvendPos);
|
||||
|
||||
if (endPos.has_error())
|
||||
{
|
||||
return endPos.error();
|
||||
}
|
||||
|
||||
return Boundary{
|
||||
.startPos = startPos.value(),
|
||||
.endPos = endPos.value(),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<AutomodReason, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<AutomodReason> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvcategory = root.if_contains("category");
|
||||
if (jvcategory == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto category = boost::json::try_value_to<String>(*jvcategory);
|
||||
|
||||
if (category.has_error())
|
||||
{
|
||||
return category.error();
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
|
||||
decltype(std::declval<AutomodReason>().level)>>);
|
||||
const auto *jvlevel = root.if_contains("level");
|
||||
if (jvlevel == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto level = boost::json::try_value_to<int>(*jvlevel);
|
||||
|
||||
if (level.has_error())
|
||||
{
|
||||
return level.error();
|
||||
}
|
||||
|
||||
std::vector<Boundary> vboundaries;
|
||||
const auto *jvboundaries = root.if_contains("boundaries");
|
||||
if (jvboundaries != nullptr && !jvboundaries->is_null())
|
||||
{
|
||||
auto boundaries =
|
||||
boost::json::try_value_to<std::vector<Boundary>>(*jvboundaries);
|
||||
if (boundaries.has_error())
|
||||
{
|
||||
return boundaries.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vboundaries = std::move(boundaries.value());
|
||||
}
|
||||
}
|
||||
|
||||
return AutomodReason{
|
||||
.category = std::move(category.value()),
|
||||
.level = level.value(),
|
||||
.boundaries = std::move(vboundaries),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<FoundTerm, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<FoundTerm> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtermID = root.if_contains("term_id");
|
||||
if (jvtermID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto termID = boost::json::try_value_to<std::string>(*jvtermID);
|
||||
|
||||
if (termID.has_error())
|
||||
{
|
||||
return termID.error();
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
|
||||
decltype(std::declval<FoundTerm>().boundary)>>);
|
||||
const auto *jvboundary = root.if_contains("boundary");
|
||||
if (jvboundary == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto boundary = boost::json::try_value_to<Boundary>(*jvboundary);
|
||||
|
||||
if (boundary.has_error())
|
||||
{
|
||||
return boundary.error();
|
||||
}
|
||||
|
||||
const auto *jvownerBroadcasterUserID =
|
||||
root.if_contains("owner_broadcaster_user_id");
|
||||
if (jvownerBroadcasterUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerBroadcasterUserID =
|
||||
boost::json::try_value_to<std::string>(*jvownerBroadcasterUserID);
|
||||
|
||||
if (ownerBroadcasterUserID.has_error())
|
||||
{
|
||||
return ownerBroadcasterUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvownerBroadcasterUserLogin =
|
||||
root.if_contains("owner_broadcaster_user_login");
|
||||
if (jvownerBroadcasterUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerBroadcasterUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvownerBroadcasterUserLogin);
|
||||
|
||||
if (ownerBroadcasterUserLogin.has_error())
|
||||
{
|
||||
return ownerBroadcasterUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvownerBroadcasterUserName =
|
||||
root.if_contains("owner_broadcaster_user_name");
|
||||
if (jvownerBroadcasterUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerBroadcasterUserName =
|
||||
boost::json::try_value_to<std::string>(*jvownerBroadcasterUserName);
|
||||
|
||||
if (ownerBroadcasterUserName.has_error())
|
||||
{
|
||||
return ownerBroadcasterUserName.error();
|
||||
}
|
||||
|
||||
return FoundTerm{
|
||||
.termID = std::move(termID.value()),
|
||||
.boundary = boundary.value(),
|
||||
.ownerBroadcasterUserID = std::move(ownerBroadcasterUserID.value()),
|
||||
.ownerBroadcasterUserLogin =
|
||||
std::move(ownerBroadcasterUserLogin.value()),
|
||||
.ownerBroadcasterUserName = std::move(ownerBroadcasterUserName.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<BlockedTermReason, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<BlockedTermReason> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
std::vector<FoundTerm> vtermsFound;
|
||||
const auto *jvtermsFound = root.if_contains("terms_found");
|
||||
if (jvtermsFound != nullptr && !jvtermsFound->is_null())
|
||||
{
|
||||
auto termsFound =
|
||||
boost::json::try_value_to<std::vector<FoundTerm>>(*jvtermsFound);
|
||||
if (termsFound.has_error())
|
||||
{
|
||||
return termsFound.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vtermsFound = std::move(termsFound.value());
|
||||
}
|
||||
}
|
||||
|
||||
return BlockedTermReason{
|
||||
.termsFound = std::move(vtermsFound),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::automod
|
||||
@@ -64,327 +64,6 @@ boost::json::result_for<Badge, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Cheermote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvprefix = root.if_contains("prefix");
|
||||
if (jvprefix == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto prefix = boost::json::try_value_to<std::string>(*jvprefix);
|
||||
|
||||
if (prefix.has_error())
|
||||
{
|
||||
return prefix.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().bits)>>);
|
||||
const auto *jvbits = root.if_contains("bits");
|
||||
if (jvbits == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto bits = boost::json::try_value_to<int>(*jvbits);
|
||||
|
||||
if (bits.has_error())
|
||||
{
|
||||
return bits.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().tier)>>);
|
||||
const auto *jvtier = root.if_contains("tier");
|
||||
if (jvtier == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto tier = boost::json::try_value_to<int>(*jvtier);
|
||||
|
||||
if (tier.has_error())
|
||||
{
|
||||
return tier.error();
|
||||
}
|
||||
|
||||
return Cheermote{
|
||||
.prefix = std::move(prefix.value()),
|
||||
.bits = bits.value(),
|
||||
.tier = tier.value(),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Emote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvid = root.if_contains("id");
|
||||
if (jvid == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto id = boost::json::try_value_to<std::string>(*jvid);
|
||||
|
||||
if (id.has_error())
|
||||
{
|
||||
return id.error();
|
||||
}
|
||||
|
||||
const auto *jvemoteSetID = root.if_contains("emote_set_id");
|
||||
if (jvemoteSetID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto emoteSetID = boost::json::try_value_to<std::string>(*jvemoteSetID);
|
||||
|
||||
if (emoteSetID.has_error())
|
||||
{
|
||||
return emoteSetID.error();
|
||||
}
|
||||
|
||||
const auto *jvownerID = root.if_contains("owner_id");
|
||||
if (jvownerID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerID = boost::json::try_value_to<std::string>(*jvownerID);
|
||||
|
||||
if (ownerID.has_error())
|
||||
{
|
||||
return ownerID.error();
|
||||
}
|
||||
|
||||
std::vector<std::string> vformat;
|
||||
const auto *jvformat = root.if_contains("format");
|
||||
if (jvformat != nullptr && !jvformat->is_null())
|
||||
{
|
||||
auto format =
|
||||
boost::json::try_value_to<std::vector<std::string>>(*jvformat);
|
||||
if (format.has_error())
|
||||
{
|
||||
return format.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vformat = std::move(format.value());
|
||||
}
|
||||
}
|
||||
|
||||
return Emote{
|
||||
.id = std::move(id.value()),
|
||||
.emoteSetID = std::move(emoteSetID.value()),
|
||||
.ownerID = std::move(ownerID.value()),
|
||||
.format = std::move(vformat),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Mention> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
return Mention{
|
||||
.userID = std::move(userID.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<MessageFragment, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<MessageFragment> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtype = root.if_contains("type");
|
||||
if (jvtype == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto type = boost::json::try_value_to<std::string>(*jvtype);
|
||||
|
||||
if (type.has_error())
|
||||
{
|
||||
return type.error();
|
||||
}
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
std::optional<Cheermote> cheermote = std::nullopt;
|
||||
const auto *jvcheermote = root.if_contains("cheermote");
|
||||
if (jvcheermote != nullptr && !jvcheermote->is_null())
|
||||
{
|
||||
auto tcheermote = boost::json::try_value_to<Cheermote>(*jvcheermote);
|
||||
|
||||
if (tcheermote.has_error())
|
||||
{
|
||||
return tcheermote.error();
|
||||
}
|
||||
cheermote = std::move(tcheermote.value());
|
||||
}
|
||||
|
||||
std::optional<Emote> emote = std::nullopt;
|
||||
const auto *jvemote = root.if_contains("emote");
|
||||
if (jvemote != nullptr && !jvemote->is_null())
|
||||
{
|
||||
auto temote = boost::json::try_value_to<Emote>(*jvemote);
|
||||
|
||||
if (temote.has_error())
|
||||
{
|
||||
return temote.error();
|
||||
}
|
||||
emote = std::move(temote.value());
|
||||
}
|
||||
|
||||
std::optional<Mention> mention = std::nullopt;
|
||||
const auto *jvmention = root.if_contains("mention");
|
||||
if (jvmention != nullptr && !jvmention->is_null())
|
||||
{
|
||||
auto tmention = boost::json::try_value_to<Mention>(*jvmention);
|
||||
|
||||
if (tmention.has_error())
|
||||
{
|
||||
return tmention.error();
|
||||
}
|
||||
mention = std::move(tmention.value());
|
||||
}
|
||||
|
||||
return MessageFragment{
|
||||
.type = std::move(type.value()),
|
||||
.text = std::move(text.value()),
|
||||
.cheermote = std::move(cheermote),
|
||||
.emote = std::move(emote),
|
||||
.mention = std::move(mention),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Message, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Message> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
std::vector<MessageFragment> vfragments;
|
||||
const auto *jvfragments = root.if_contains("fragments");
|
||||
if (jvfragments != nullptr && !jvfragments->is_null())
|
||||
{
|
||||
auto fragments =
|
||||
boost::json::try_value_to<std::vector<MessageFragment>>(
|
||||
*jvfragments);
|
||||
if (fragments.has_error())
|
||||
{
|
||||
return fragments.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vfragments = std::move(fragments.value());
|
||||
}
|
||||
}
|
||||
|
||||
return Message{
|
||||
.text = std::move(text.value()),
|
||||
.fragments = std::move(vfragments),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Cheer, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Cheer> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -718,7 +397,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<Message>(*jvmessage);
|
||||
auto message = boost::json::try_value_to<chat::Message>(*jvmessage);
|
||||
|
||||
if (message.has_error())
|
||||
{
|
||||
|
||||
@@ -64,281 +64,6 @@ boost::json::result_for<Badge, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Cheermote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvprefix = root.if_contains("prefix");
|
||||
if (jvprefix == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto prefix = boost::json::try_value_to<std::string>(*jvprefix);
|
||||
|
||||
if (prefix.has_error())
|
||||
{
|
||||
return prefix.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().bits)>>);
|
||||
const auto *jvbits = root.if_contains("bits");
|
||||
if (jvbits == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto bits = boost::json::try_value_to<int>(*jvbits);
|
||||
|
||||
if (bits.has_error())
|
||||
{
|
||||
return bits.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().tier)>>);
|
||||
const auto *jvtier = root.if_contains("tier");
|
||||
if (jvtier == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto tier = boost::json::try_value_to<int>(*jvtier);
|
||||
|
||||
if (tier.has_error())
|
||||
{
|
||||
return tier.error();
|
||||
}
|
||||
|
||||
return Cheermote{
|
||||
.prefix = std::move(prefix.value()),
|
||||
.bits = bits.value(),
|
||||
.tier = tier.value(),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Emote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvid = root.if_contains("id");
|
||||
if (jvid == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto id = boost::json::try_value_to<std::string>(*jvid);
|
||||
|
||||
if (id.has_error())
|
||||
{
|
||||
return id.error();
|
||||
}
|
||||
|
||||
const auto *jvemoteSetID = root.if_contains("emote_set_id");
|
||||
if (jvemoteSetID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto emoteSetID = boost::json::try_value_to<std::string>(*jvemoteSetID);
|
||||
|
||||
if (emoteSetID.has_error())
|
||||
{
|
||||
return emoteSetID.error();
|
||||
}
|
||||
|
||||
const auto *jvownerID = root.if_contains("owner_id");
|
||||
if (jvownerID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto ownerID = boost::json::try_value_to<std::string>(*jvownerID);
|
||||
|
||||
if (ownerID.has_error())
|
||||
{
|
||||
return ownerID.error();
|
||||
}
|
||||
|
||||
std::vector<std::string> vformat;
|
||||
const auto *jvformat = root.if_contains("format");
|
||||
if (jvformat != nullptr && !jvformat->is_null())
|
||||
{
|
||||
auto format =
|
||||
boost::json::try_value_to<std::vector<std::string>>(*jvformat);
|
||||
if (format.has_error())
|
||||
{
|
||||
return format.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vformat = std::move(format.value());
|
||||
}
|
||||
}
|
||||
|
||||
return Emote{
|
||||
.id = std::move(id.value()),
|
||||
.emoteSetID = std::move(emoteSetID.value()),
|
||||
.ownerID = std::move(ownerID.value()),
|
||||
.format = std::move(vformat),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Mention> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
return Mention{
|
||||
.userID = std::move(userID.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<MessageFragment, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<MessageFragment> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtype = root.if_contains("type");
|
||||
if (jvtype == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto type = boost::json::try_value_to<std::string>(*jvtype);
|
||||
|
||||
if (type.has_error())
|
||||
{
|
||||
return type.error();
|
||||
}
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
std::optional<Cheermote> cheermote = std::nullopt;
|
||||
const auto *jvcheermote = root.if_contains("cheermote");
|
||||
if (jvcheermote != nullptr && !jvcheermote->is_null())
|
||||
{
|
||||
auto tcheermote = boost::json::try_value_to<Cheermote>(*jvcheermote);
|
||||
|
||||
if (tcheermote.has_error())
|
||||
{
|
||||
return tcheermote.error();
|
||||
}
|
||||
cheermote = std::move(tcheermote.value());
|
||||
}
|
||||
|
||||
std::optional<Emote> emote = std::nullopt;
|
||||
const auto *jvemote = root.if_contains("emote");
|
||||
if (jvemote != nullptr && !jvemote->is_null())
|
||||
{
|
||||
auto temote = boost::json::try_value_to<Emote>(*jvemote);
|
||||
|
||||
if (temote.has_error())
|
||||
{
|
||||
return temote.error();
|
||||
}
|
||||
emote = std::move(temote.value());
|
||||
}
|
||||
|
||||
std::optional<Mention> mention = std::nullopt;
|
||||
const auto *jvmention = root.if_contains("mention");
|
||||
if (jvmention != nullptr && !jvmention->is_null())
|
||||
{
|
||||
auto tmention = boost::json::try_value_to<Mention>(*jvmention);
|
||||
|
||||
if (tmention.has_error())
|
||||
{
|
||||
return tmention.error();
|
||||
}
|
||||
mention = std::move(tmention.value());
|
||||
}
|
||||
|
||||
return MessageFragment{
|
||||
.type = std::move(type.value()),
|
||||
.text = std::move(text.value()),
|
||||
.cheermote = std::move(cheermote),
|
||||
.emote = std::move(emote),
|
||||
.mention = std::move(mention),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Subcription, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Subcription> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -1227,52 +952,6 @@ boost::json::result_for<BitsBadgeTier, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Message, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Message> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<std::string>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
std::vector<MessageFragment> vfragments;
|
||||
const auto *jvfragments = root.if_contains("fragments");
|
||||
if (jvfragments != nullptr && !jvfragments->is_null())
|
||||
{
|
||||
auto fragments =
|
||||
boost::json::try_value_to<std::vector<MessageFragment>>(
|
||||
*jvfragments);
|
||||
if (fragments.has_error())
|
||||
{
|
||||
return fragments.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vfragments = std::move(fragments.value());
|
||||
}
|
||||
}
|
||||
|
||||
return Message{
|
||||
.text = std::move(text.value()),
|
||||
.fragments = std::move(vfragments),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -1445,7 +1124,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<Message>(*jvmessage);
|
||||
auto message = boost::json::try_value_to<chat::Message>(*jvmessage);
|
||||
|
||||
if (message.has_error())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-message-v1.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::payload::channel_suspicious_user_message::
|
||||
v1 {
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbroadcasterUserID = root.if_contains("broadcaster_user_id");
|
||||
if (jvbroadcasterUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserID =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserID);
|
||||
|
||||
if (broadcasterUserID.has_error())
|
||||
{
|
||||
return broadcasterUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserLogin =
|
||||
root.if_contains("broadcaster_user_login");
|
||||
if (jvbroadcasterUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserLogin);
|
||||
|
||||
if (broadcasterUserLogin.has_error())
|
||||
{
|
||||
return broadcasterUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserName =
|
||||
root.if_contains("broadcaster_user_name");
|
||||
if (jvbroadcasterUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserName =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserName);
|
||||
|
||||
if (broadcasterUserName.has_error())
|
||||
{
|
||||
return broadcasterUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvlowTrustStatus = root.if_contains("low_trust_status");
|
||||
if (jvlowTrustStatus == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto lowTrustStatus =
|
||||
boost::json::try_value_to<std::string>(*jvlowTrustStatus);
|
||||
|
||||
if (lowTrustStatus.has_error())
|
||||
{
|
||||
return lowTrustStatus.error();
|
||||
}
|
||||
|
||||
std::vector<std::string> vsharedBanChannelIds;
|
||||
const auto *jvsharedBanChannelIds =
|
||||
root.if_contains("shared_ban_channel_ids");
|
||||
if (jvsharedBanChannelIds != nullptr && !jvsharedBanChannelIds->is_null())
|
||||
{
|
||||
auto sharedBanChannelIds =
|
||||
boost::json::try_value_to<std::vector<std::string>>(
|
||||
*jvsharedBanChannelIds);
|
||||
if (sharedBanChannelIds.has_error())
|
||||
{
|
||||
return sharedBanChannelIds.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vsharedBanChannelIds = std::move(sharedBanChannelIds.value());
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> vtypes;
|
||||
const auto *jvtypes = root.if_contains("types");
|
||||
if (jvtypes != nullptr && !jvtypes->is_null())
|
||||
{
|
||||
auto types =
|
||||
boost::json::try_value_to<std::vector<std::string>>(*jvtypes);
|
||||
if (types.has_error())
|
||||
{
|
||||
return types.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vtypes = std::move(types.value());
|
||||
}
|
||||
}
|
||||
const auto *jvbanEvasionEvaluation =
|
||||
root.if_contains("ban_evasion_evaluation");
|
||||
if (jvbanEvasionEvaluation == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto banEvasionEvaluation =
|
||||
boost::json::try_value_to<std::string>(*jvbanEvasionEvaluation);
|
||||
|
||||
if (banEvasionEvaluation.has_error())
|
||||
{
|
||||
return banEvasionEvaluation.error();
|
||||
}
|
||||
|
||||
const auto *jvmessage = root.if_contains("message");
|
||||
if (jvmessage == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto message = boost::json::try_value_to<chat::Message>(*jvmessage);
|
||||
|
||||
if (message.has_error())
|
||||
{
|
||||
return message.error();
|
||||
}
|
||||
|
||||
return Event{
|
||||
.broadcasterUserID = std::move(broadcasterUserID.value()),
|
||||
.broadcasterUserLogin = std::move(broadcasterUserLogin.value()),
|
||||
.broadcasterUserName = std::move(broadcasterUserName.value()),
|
||||
.userID = std::move(userID.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.lowTrustStatus = std::move(lowTrustStatus.value()),
|
||||
.sharedBanChannelIds = std::move(vsharedBanChannelIds),
|
||||
.types = std::move(vtypes),
|
||||
.banEvasionEvaluation = std::move(banEvasionEvaluation.value()),
|
||||
.message = std::move(message.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Payload> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsubscription = root.if_contains("subscription");
|
||||
if (jvsubscription == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto subscription =
|
||||
boost::json::try_value_to<subscription::Subscription>(*jvsubscription);
|
||||
|
||||
if (subscription.has_error())
|
||||
{
|
||||
return subscription.error();
|
||||
}
|
||||
|
||||
const auto *jvevent = root.if_contains("event");
|
||||
if (jvevent == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto event = boost::json::try_value_to<Event>(*jvevent);
|
||||
|
||||
if (event.has_error())
|
||||
{
|
||||
return event.error();
|
||||
}
|
||||
|
||||
return Payload{
|
||||
.subscription = std::move(subscription.value()),
|
||||
.event = std::move(event.value()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::payload::channel_suspicious_user_message::v1
|
||||
@@ -0,0 +1,218 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-update-v1.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::payload::channel_suspicious_user_update::
|
||||
v1 {
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvbroadcasterUserID = root.if_contains("broadcaster_user_id");
|
||||
if (jvbroadcasterUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserID =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserID);
|
||||
|
||||
if (broadcasterUserID.has_error())
|
||||
{
|
||||
return broadcasterUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserLogin =
|
||||
root.if_contains("broadcaster_user_login");
|
||||
if (jvbroadcasterUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserLogin);
|
||||
|
||||
if (broadcasterUserLogin.has_error())
|
||||
{
|
||||
return broadcasterUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvbroadcasterUserName =
|
||||
root.if_contains("broadcaster_user_name");
|
||||
if (jvbroadcasterUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto broadcasterUserName =
|
||||
boost::json::try_value_to<std::string>(*jvbroadcasterUserName);
|
||||
|
||||
if (broadcasterUserName.has_error())
|
||||
{
|
||||
return broadcasterUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserID = root.if_contains("moderator_user_id");
|
||||
if (jvmoderatorUserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserID =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserID);
|
||||
|
||||
if (moderatorUserID.has_error())
|
||||
{
|
||||
return moderatorUserID.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserLogin = root.if_contains("moderator_user_login");
|
||||
if (jvmoderatorUserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserLogin =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserLogin);
|
||||
|
||||
if (moderatorUserLogin.has_error())
|
||||
{
|
||||
return moderatorUserLogin.error();
|
||||
}
|
||||
|
||||
const auto *jvmoderatorUserName = root.if_contains("moderator_user_name");
|
||||
if (jvmoderatorUserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto moderatorUserName =
|
||||
boost::json::try_value_to<std::string>(*jvmoderatorUserName);
|
||||
|
||||
if (moderatorUserName.has_error())
|
||||
{
|
||||
return moderatorUserName.error();
|
||||
}
|
||||
|
||||
const auto *jvlowTrustStatus = root.if_contains("low_trust_status");
|
||||
if (jvlowTrustStatus == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto lowTrustStatus =
|
||||
boost::json::try_value_to<std::string>(*jvlowTrustStatus);
|
||||
|
||||
if (lowTrustStatus.has_error())
|
||||
{
|
||||
return lowTrustStatus.error();
|
||||
}
|
||||
|
||||
return Event{
|
||||
.broadcasterUserID = std::move(broadcasterUserID.value()),
|
||||
.broadcasterUserLogin = std::move(broadcasterUserLogin.value()),
|
||||
.broadcasterUserName = std::move(broadcasterUserName.value()),
|
||||
.userID = std::move(userID.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.moderatorUserID = std::move(moderatorUserID.value()),
|
||||
.moderatorUserLogin = std::move(moderatorUserLogin.value()),
|
||||
.moderatorUserName = std::move(moderatorUserName.value()),
|
||||
.lowTrustStatus = std::move(lowTrustStatus.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Payload, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Payload> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvsubscription = root.if_contains("subscription");
|
||||
if (jvsubscription == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto subscription =
|
||||
boost::json::try_value_to<subscription::Subscription>(*jvsubscription);
|
||||
|
||||
if (subscription.has_error())
|
||||
{
|
||||
return subscription.error();
|
||||
}
|
||||
|
||||
const auto *jvevent = root.if_contains("event");
|
||||
if (jvevent == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto event = boost::json::try_value_to<Event>(*jvevent);
|
||||
|
||||
if (event.has_error())
|
||||
{
|
||||
return event.error();
|
||||
}
|
||||
|
||||
return Payload{
|
||||
.subscription = std::move(subscription.value()),
|
||||
.event = std::move(event.value()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::payload::channel_suspicious_user_update::v1
|
||||
@@ -0,0 +1,318 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/structured-message.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::chat {
|
||||
|
||||
boost::json::result_for<Cheermote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Cheermote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvprefix = root.if_contains("prefix");
|
||||
if (jvprefix == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto prefix = boost::json::try_value_to<String>(*jvprefix);
|
||||
|
||||
if (prefix.has_error())
|
||||
{
|
||||
return prefix.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().bits)>>);
|
||||
const auto *jvbits = root.if_contains("bits");
|
||||
if (jvbits == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto bits = boost::json::try_value_to<int>(*jvbits);
|
||||
|
||||
if (bits.has_error())
|
||||
{
|
||||
return bits.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Cheermote>().tier)>>);
|
||||
const auto *jvtier = root.if_contains("tier");
|
||||
if (jvtier == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto tier = boost::json::try_value_to<int>(*jvtier);
|
||||
|
||||
if (tier.has_error())
|
||||
{
|
||||
return tier.error();
|
||||
}
|
||||
|
||||
return Cheermote{
|
||||
.prefix = std::move(prefix.value()),
|
||||
.bits = bits.value(),
|
||||
.tier = tier.value(),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Emote, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Emote> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvid = root.if_contains("id");
|
||||
if (jvid == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto id = boost::json::try_value_to<String>(*jvid);
|
||||
|
||||
if (id.has_error())
|
||||
{
|
||||
return id.error();
|
||||
}
|
||||
|
||||
const auto *jvemoteSetID = root.if_contains("emote_set_id");
|
||||
if (jvemoteSetID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto emoteSetID = boost::json::try_value_to<String>(*jvemoteSetID);
|
||||
|
||||
if (emoteSetID.has_error())
|
||||
{
|
||||
return emoteSetID.error();
|
||||
}
|
||||
|
||||
return Emote{
|
||||
.id = std::move(id.value()),
|
||||
.emoteSetID = std::move(emoteSetID.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Mention, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Mention> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvuserID = root.if_contains("user_id");
|
||||
if (jvuserID == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userID = boost::json::try_value_to<String>(*jvuserID);
|
||||
|
||||
if (userID.has_error())
|
||||
{
|
||||
return userID.error();
|
||||
}
|
||||
|
||||
const auto *jvuserName = root.if_contains("user_name");
|
||||
if (jvuserName == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userName = boost::json::try_value_to<String>(*jvuserName);
|
||||
|
||||
if (userName.has_error())
|
||||
{
|
||||
return userName.error();
|
||||
}
|
||||
|
||||
const auto *jvuserLogin = root.if_contains("user_login");
|
||||
if (jvuserLogin == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto userLogin = boost::json::try_value_to<String>(*jvuserLogin);
|
||||
|
||||
if (userLogin.has_error())
|
||||
{
|
||||
return userLogin.error();
|
||||
}
|
||||
|
||||
return Mention{
|
||||
.userID = std::move(userID.value()),
|
||||
.userName = std::move(userName.value()),
|
||||
.userLogin = std::move(userLogin.value()),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Text, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Text> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return Text{};
|
||||
}
|
||||
|
||||
boost::json::result_for<MessageFragment, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<MessageFragment> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<String>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
const auto *jvinnerTag = root.if_contains("type");
|
||||
if (jvinnerTag == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto innerTagRes =
|
||||
boost::json::try_value_to<boost::json::string>(*jvinnerTag);
|
||||
if (innerTagRes.has_error())
|
||||
{
|
||||
return innerTagRes.error();
|
||||
}
|
||||
std::string_view innerTag = *innerTagRes;
|
||||
decltype(std::declval<MessageFragment>().inner) inner;
|
||||
if (innerTag == Text::TAG)
|
||||
{
|
||||
inner.emplace<Text>();
|
||||
}
|
||||
else if (innerTag == Cheermote::TAG)
|
||||
{
|
||||
const auto *innerVal = root.if_contains(detail::fieldFor<Cheermote>());
|
||||
if (!innerVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto innerCheermote = boost::json::try_value_to<Cheermote>(*innerVal);
|
||||
if (innerCheermote.has_error())
|
||||
{
|
||||
return innerCheermote.error();
|
||||
}
|
||||
inner.emplace<Cheermote>(std::move(innerCheermote.value()));
|
||||
}
|
||||
else if (innerTag == Emote::TAG)
|
||||
{
|
||||
const auto *innerVal = root.if_contains(detail::fieldFor<Emote>());
|
||||
if (!innerVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto innerEmote = boost::json::try_value_to<Emote>(*innerVal);
|
||||
if (innerEmote.has_error())
|
||||
{
|
||||
return innerEmote.error();
|
||||
}
|
||||
inner.emplace<Emote>(std::move(innerEmote.value()));
|
||||
}
|
||||
else if (innerTag == Mention::TAG)
|
||||
{
|
||||
const auto *innerVal = root.if_contains(detail::fieldFor<Mention>());
|
||||
if (!innerVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto innerMention = boost::json::try_value_to<Mention>(*innerVal);
|
||||
if (innerMention.has_error())
|
||||
{
|
||||
return innerMention.error();
|
||||
}
|
||||
inner.emplace<Mention>(std::move(innerMention.value()));
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::UnknownVariant);
|
||||
}
|
||||
|
||||
return MessageFragment{
|
||||
.text = std::move(text.value()),
|
||||
.inner = std::move(inner),
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Message, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Message> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_object())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject);
|
||||
}
|
||||
const auto &root = jvRoot.get_object();
|
||||
|
||||
const auto *jvtext = root.if_contains("text");
|
||||
if (jvtext == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto text = boost::json::try_value_to<String>(*jvtext);
|
||||
|
||||
if (text.has_error())
|
||||
{
|
||||
return text.error();
|
||||
}
|
||||
|
||||
std::vector<MessageFragment> vfragments;
|
||||
const auto *jvfragments = root.if_contains("fragments");
|
||||
if (jvfragments != nullptr && !jvfragments->is_null())
|
||||
{
|
||||
auto fragments =
|
||||
boost::json::try_value_to<std::vector<MessageFragment>>(
|
||||
*jvfragments);
|
||||
if (fragments.has_error())
|
||||
{
|
||||
return fragments.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
vfragments = std::move(fragments.value());
|
||||
}
|
||||
}
|
||||
|
||||
return Message{
|
||||
.text = std::move(text.value()),
|
||||
.fragments = std::move(vfragments),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib::chat
|
||||
Reference in New Issue
Block a user