diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelFromToEventSubCondition.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelFromToEventSubCondition.java new file mode 100644 index 000000000..213849598 --- /dev/null +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelFromToEventSubCondition.java @@ -0,0 +1,30 @@ +package com.github.twitch4j.eventsub.condition; + +import lombok.AccessLevel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Setter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +/** + * Generic condition when a broadcaster can be either on the receiving or giving end of the event type. + */ +@Data +@Setter(AccessLevel.PRIVATE) +@SuperBuilder +@EqualsAndHashCode(callSuper = false) +@Jacksonized +public class ChannelFromToEventSubCondition extends EventSubCondition { + + /** + * The broadcaster user ID that triggered the channel event you want to get notifications for. + */ + private String fromBroadcasterUserId; + + /** + * The broadcaster user ID that received the channel event you want to get notifications for. + */ + private String toBroadcasterUserId; + +} diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelRaidCondition.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelRaidCondition.java new file mode 100644 index 000000000..6a0ceb606 --- /dev/null +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/condition/ChannelRaidCondition.java @@ -0,0 +1,12 @@ +package com.github.twitch4j.eventsub.condition; + +import lombok.EqualsAndHashCode; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +@SuperBuilder +@Jacksonized +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ChannelRaidCondition extends ChannelFromToEventSubCondition {} diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/ChannelRaidEvent.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/ChannelRaidEvent.java new file mode 100644 index 000000000..ce7f81478 --- /dev/null +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/ChannelRaidEvent.java @@ -0,0 +1,22 @@ +package com.github.twitch4j.eventsub.events; + +import lombok.AccessLevel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Data +@Setter(AccessLevel.PRIVATE) +@NoArgsConstructor +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class ChannelRaidEvent extends EventSubChannelFromToEvent { + + /** + * The number of viewers in the raid. + */ + private Integer viewers; + +} diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/EventSubChannelFromToEvent.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/EventSubChannelFromToEvent.java new file mode 100644 index 000000000..eb8cf08e7 --- /dev/null +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/events/EventSubChannelFromToEvent.java @@ -0,0 +1,45 @@ +package com.github.twitch4j.eventsub.events; + +import lombok.AccessLevel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Data +@Setter(AccessLevel.PRIVATE) +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class EventSubChannelFromToEvent extends EventSubEvent { + + /** + * The broadcaster ID that triggered the event. + */ + private String fromBroadcasterUserId; + + /** + * The broadcaster login that triggered the event. + */ + private String fromBroadcasterUserLogin; + + /** + * The broadcaster display name that triggered the event. + */ + private String fromBroadcasterUserName; + + /** + * The broadcaster ID that received the event. + */ + private String toBroadcasterUserId; + + /** + * The broadcaster login that received the event. + */ + private String toBroadcasterUserLogin; + + /** + * The broadcaster display name that received the event. + */ + private String toBroadcasterUserName; + +} diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/BetaChannelRaidType.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/BetaChannelRaidType.java new file mode 100644 index 000000000..c5c905afb --- /dev/null +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/BetaChannelRaidType.java @@ -0,0 +1,37 @@ +package com.github.twitch4j.eventsub.subscriptions; + +import com.github.twitch4j.common.annotation.Unofficial; +import com.github.twitch4j.eventsub.condition.ChannelRaidCondition; +import com.github.twitch4j.eventsub.events.ChannelRaidEvent; + +/** + * A broadcaster raids another broadcaster’s channel. + *

+ * No authorization required. + *

+ * This {@link SubscriptionType} is marked as {@link Unofficial} due to Twitch indicating that it is not intended for use in production environments. + */ +@Unofficial +public class BetaChannelRaidType implements SubscriptionType, ChannelRaidEvent> { + + @Override + public String getName() { + return "channel.raid"; + } + + @Override + public String getVersion() { + return "beta"; + } + + @Override + public ChannelRaidCondition.ChannelRaidConditionBuilder getConditionBuilder() { + return ChannelRaidCondition.builder(); + } + + @Override + public Class getEventClass() { + return ChannelRaidEvent.class; + } + +} diff --git a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/SubscriptionTypes.java b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/SubscriptionTypes.java index f4bf8b2f6..f10fa1199 100644 --- a/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/SubscriptionTypes.java +++ b/eventsub-common/src/main/java/com/github/twitch4j/eventsub/subscriptions/SubscriptionTypes.java @@ -1,5 +1,6 @@ package com.github.twitch4j.eventsub.subscriptions; +import com.github.twitch4j.common.annotation.Unofficial; import lombok.experimental.UtilityClass; import java.util.Collections; @@ -11,6 +12,8 @@ @UtilityClass public class SubscriptionTypes { private final Map> SUBSCRIPTION_TYPES; + @Unofficial + public final BetaChannelRaidType CHANNEL_RAID_BETA; public final ChannelBanType CHANNEL_BAN; public final ChannelCheerType CHANNEL_CHEER; public final ChannelFollowType CHANNEL_FOLLOW; @@ -37,6 +40,7 @@ public class SubscriptionTypes { static { SUBSCRIPTION_TYPES = Collections.unmodifiableMap( Stream.of( + CHANNEL_RAID_BETA = new BetaChannelRaidType(), CHANNEL_BAN = new ChannelBanType(), CHANNEL_CHEER = new ChannelCheerType(), CHANNEL_FOLLOW = new ChannelFollowType(),