Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pubsub): add unofficial broadcast settings topic #935

Merged
merged 1 commit into from Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -403,7 +403,6 @@ default PubSubSubscription listenForHypeTrainRewardEvents(OAuth2Credential crede
}

@Unofficial
@Deprecated
default PubSubSubscription listenForBroadcastSettingUpdateEvents(OAuth2Credential credential, String channelId) {
return listenOnTopic(PubSubType.LISTEN, credential, "broadcast-settings-update." + channelId);
}
Expand Down
@@ -0,0 +1,25 @@
package com.github.twitch4j.pubsub.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;

@Data
@Setter(AccessLevel.PRIVATE)
public class BroadcastSettings {
@JsonProperty("channel")
private String channelLogin;
private String channelId;

@JsonProperty("old_status")
private String oldTitle;
@JsonProperty("status")
private String title;

private String oldGame;
private String oldGameId; // "0" if unset

private String game;
private String gameId; // "0" if unset
}
@@ -0,0 +1,12 @@
package com.github.twitch4j.pubsub.events;

import com.github.twitch4j.common.events.TwitchEvent;
import com.github.twitch4j.pubsub.domain.BroadcastSettings;
import lombok.EqualsAndHashCode;
import lombok.Value;

@Value
@EqualsAndHashCode(callSuper = false)
public class BroadcastSettingsUpdateEvent extends TwitchEvent {
BroadcastSettings data;
}
@@ -0,0 +1,22 @@
package com.github.twitch4j.pubsub.handlers;

import com.github.twitch4j.common.events.TwitchEvent;
import com.github.twitch4j.common.util.TypeConvert;
import com.github.twitch4j.pubsub.domain.BroadcastSettings;
import com.github.twitch4j.pubsub.events.BroadcastSettingsUpdateEvent;

class BroadcastSettingsHandler implements TopicHandler {
@Override
public String topicName() {
return "broadcast-settings-update";
}

@Override
public TwitchEvent apply(Args args) {
if ("broadcast_settings_update".equals(args.getType())) {
BroadcastSettings data = TypeConvert.jsonToObject(args.getRawMessage(), BroadcastSettings.class);
return new BroadcastSettingsUpdateEvent(data);
}
return null;
}
}
Expand Up @@ -33,6 +33,7 @@ public enum HandlerRegistry {
new AdsManagerHandler(),
new AutoModLevelHandler(),
new BoostHandler(),
new BroadcastSettingsHandler(),
new CharityHandler(),
new ChatroomHandler(),
new CheerbombHandler(),
Expand Down