// 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-chat-message-v1.hpp" #include namespace chatterino::eventsub::lib::payload::channel_chat_message::v1 { boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* tag */, const boost::json::value &jvRoot) { if (!jvRoot.is_object()) { EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject); } const auto &root = jvRoot.get_object(); const auto *jvsetID = root.if_contains("set_id"); if (jvsetID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto setID = boost::json::try_value_to(*jvsetID); if (setID.has_error()) { return setID.error(); } const auto *jvid = root.if_contains("id"); if (jvid == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto id = boost::json::try_value_to(*jvid); if (id.has_error()) { return id.error(); } const auto *jvinfo = root.if_contains("info"); if (jvinfo == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto info = boost::json::try_value_to(*jvinfo); if (info.has_error()) { return info.error(); } return Badge{ .setID = std::move(setID.value()), .id = std::move(id.value()), .info = std::move(info.value()), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* 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(*jvprefix); if (prefix.has_error()) { return prefix.error(); } static_assert( std::is_trivially_copyable_v< std::remove_reference_t().bits)>>); const auto *jvbits = root.if_contains("bits"); if (jvbits == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto bits = boost::json::try_value_to(*jvbits); if (bits.has_error()) { return bits.error(); } static_assert( std::is_trivially_copyable_v< std::remove_reference_t().tier)>>); const auto *jvtier = root.if_contains("tier"); if (jvtier == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto tier = boost::json::try_value_to(*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::type tag_invoke( boost::json::try_value_to_tag /* 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(*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(*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(*jvownerID); if (ownerID.has_error()) { return ownerID.error(); } const auto *jvformat = root.if_contains("format"); if (jvformat == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto format = boost::json::try_value_to>(*jvformat); if (format.has_error()) { return format.error(); } return Emote{ .id = std::move(id.value()), .emoteSetID = std::move(emoteSetID.value()), .ownerID = std::move(ownerID.value()), .format = std::move(format.value()), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* 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(*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(*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(*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::type tag_invoke( boost::json::try_value_to_tag /* 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(*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(*jvtext); if (text.has_error()) { return text.error(); } std::optional cheermote = std::nullopt; const auto *jvcheermote = root.if_contains("cheermote"); if (jvcheermote != nullptr && !jvcheermote->is_null()) { auto tcheermote = boost::json::try_value_to(*jvcheermote); if (tcheermote.has_error()) { return tcheermote.error(); } cheermote = std::move(tcheermote.value()); } std::optional emote = std::nullopt; const auto *jvemote = root.if_contains("emote"); if (jvemote != nullptr && !jvemote->is_null()) { auto temote = boost::json::try_value_to(*jvemote); if (temote.has_error()) { return temote.error(); } emote = std::move(temote.value()); } std::optional mention = std::nullopt; const auto *jvmention = root.if_contains("mention"); if (jvmention != nullptr && !jvmention->is_null()) { auto tmention = boost::json::try_value_to(*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::type tag_invoke( boost::json::try_value_to_tag /* 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(*jvtext); if (text.has_error()) { return text.error(); } const auto *jvfragments = root.if_contains("fragments"); if (jvfragments == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto fragments = boost::json::try_value_to>(*jvfragments); if (fragments.has_error()) { return fragments.error(); } return Message{ .text = std::move(text.value()), .fragments = std::move(fragments.value()), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* 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().bits)>>); const auto *jvbits = root.if_contains("bits"); if (jvbits == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto bits = boost::json::try_value_to(*jvbits); if (bits.has_error()) { return bits.error(); } return Cheer{ .bits = bits.value(), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* tag */, const boost::json::value &jvRoot) { if (!jvRoot.is_object()) { EVENTSUB_BAIL_HERE(error::Kind::ExpectedObject); } const auto &root = jvRoot.get_object(); const auto *jvparentMessageID = root.if_contains("parent_message_id"); if (jvparentMessageID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto parentMessageID = boost::json::try_value_to(*jvparentMessageID); if (parentMessageID.has_error()) { return parentMessageID.error(); } const auto *jvparentUserID = root.if_contains("parent_user_id"); if (jvparentUserID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto parentUserID = boost::json::try_value_to(*jvparentUserID); if (parentUserID.has_error()) { return parentUserID.error(); } const auto *jvparentUserLogin = root.if_contains("parent_user_login"); if (jvparentUserLogin == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto parentUserLogin = boost::json::try_value_to(*jvparentUserLogin); if (parentUserLogin.has_error()) { return parentUserLogin.error(); } const auto *jvparentUserName = root.if_contains("parent_user_name"); if (jvparentUserName == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto parentUserName = boost::json::try_value_to(*jvparentUserName); if (parentUserName.has_error()) { return parentUserName.error(); } const auto *jvparentMessageBody = root.if_contains("parent_message_body"); if (jvparentMessageBody == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto parentMessageBody = boost::json::try_value_to(*jvparentMessageBody); if (parentMessageBody.has_error()) { return parentMessageBody.error(); } const auto *jvthreadMessageID = root.if_contains("thread_message_id"); if (jvthreadMessageID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto threadMessageID = boost::json::try_value_to(*jvthreadMessageID); if (threadMessageID.has_error()) { return threadMessageID.error(); } const auto *jvthreadUserID = root.if_contains("thread_user_id"); if (jvthreadUserID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto threadUserID = boost::json::try_value_to(*jvthreadUserID); if (threadUserID.has_error()) { return threadUserID.error(); } const auto *jvthreadUserLogin = root.if_contains("thread_user_login"); if (jvthreadUserLogin == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto threadUserLogin = boost::json::try_value_to(*jvthreadUserLogin); if (threadUserLogin.has_error()) { return threadUserLogin.error(); } const auto *jvthreadUserName = root.if_contains("thread_user_name"); if (jvthreadUserName == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto threadUserName = boost::json::try_value_to(*jvthreadUserName); if (threadUserName.has_error()) { return threadUserName.error(); } return Reply{ .parentMessageID = std::move(parentMessageID.value()), .parentUserID = std::move(parentUserID.value()), .parentUserLogin = std::move(parentUserLogin.value()), .parentUserName = std::move(parentUserName.value()), .parentMessageBody = std::move(parentMessageBody.value()), .threadMessageID = std::move(threadMessageID.value()), .threadUserID = std::move(threadUserID.value()), .threadUserLogin = std::move(threadUserLogin.value()), .threadUserName = std::move(threadUserName.value()), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* 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(*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(*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(*jvbroadcasterUserName); if (broadcasterUserName.has_error()) { return broadcasterUserName.error(); } const auto *jvchatterUserID = root.if_contains("chatter_user_id"); if (jvchatterUserID == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto chatterUserID = boost::json::try_value_to(*jvchatterUserID); if (chatterUserID.has_error()) { return chatterUserID.error(); } const auto *jvchatterUserLogin = root.if_contains("chatter_user_login"); if (jvchatterUserLogin == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto chatterUserLogin = boost::json::try_value_to(*jvchatterUserLogin); if (chatterUserLogin.has_error()) { return chatterUserLogin.error(); } const auto *jvchatterUserName = root.if_contains("chatter_user_name"); if (jvchatterUserName == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto chatterUserName = boost::json::try_value_to(*jvchatterUserName); if (chatterUserName.has_error()) { return chatterUserName.error(); } const auto *jvcolor = root.if_contains("color"); if (jvcolor == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto color = boost::json::try_value_to(*jvcolor); if (color.has_error()) { return color.error(); } const auto *jvbadges = root.if_contains("badges"); if (jvbadges == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto badges = boost::json::try_value_to>(*jvbadges); if (badges.has_error()) { return badges.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(*jvmessageID); if (messageID.has_error()) { return messageID.error(); } const auto *jvmessageType = root.if_contains("message_type"); if (jvmessageType == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto messageType = boost::json::try_value_to(*jvmessageType); if (messageType.has_error()) { return messageType.error(); } const auto *jvmessage = root.if_contains("message"); if (jvmessage == nullptr) { EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } auto message = boost::json::try_value_to(*jvmessage); if (message.has_error()) { return message.error(); } static_assert( std::is_trivially_copyable_v< std::remove_reference_t().cheer)>>); std::optional cheer = std::nullopt; const auto *jvcheer = root.if_contains("cheer"); if (jvcheer != nullptr && !jvcheer->is_null()) { auto tcheer = boost::json::try_value_to(*jvcheer); if (tcheer.has_error()) { return tcheer.error(); } cheer = tcheer.value(); } std::optional reply = std::nullopt; const auto *jvreply = root.if_contains("reply"); if (jvreply != nullptr && !jvreply->is_null()) { auto treply = boost::json::try_value_to(*jvreply); if (treply.has_error()) { return treply.error(); } reply = std::move(treply.value()); } std::optional channelPointsCustomRewardID = std::nullopt; const auto *jvchannelPointsCustomRewardID = root.if_contains("channel_points_custom_reward_id"); if (jvchannelPointsCustomRewardID != nullptr && !jvchannelPointsCustomRewardID->is_null()) { auto tchannelPointsCustomRewardID = boost::json::try_value_to( *jvchannelPointsCustomRewardID); if (tchannelPointsCustomRewardID.has_error()) { return tchannelPointsCustomRewardID.error(); } channelPointsCustomRewardID = std::move(tchannelPointsCustomRewardID.value()); } return Event{ .broadcasterUserID = std::move(broadcasterUserID.value()), .broadcasterUserLogin = std::move(broadcasterUserLogin.value()), .broadcasterUserName = std::move(broadcasterUserName.value()), .chatterUserID = std::move(chatterUserID.value()), .chatterUserLogin = std::move(chatterUserLogin.value()), .chatterUserName = std::move(chatterUserName.value()), .color = std::move(color.value()), .badges = std::move(badges.value()), .messageID = std::move(messageID.value()), .messageType = std::move(messageType.value()), .message = std::move(message.value()), .cheer = cheer, .reply = std::move(reply), .channelPointsCustomRewardID = std::move(channelPointsCustomRewardID), }; } boost::json::result_for::type tag_invoke( boost::json::try_value_to_tag /* 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(*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(*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_chat_message::v1