Package com.github.twitch4j
Class TwitchClientHelper
java.lang.Object
com.github.twitch4j.TwitchClientHelper
- All Implemented Interfaces:
IClientHelper,AutoCloseable
A helper class that covers a few basic use cases of most library users
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTwitchClientHelper(TwitchHelix twitchHelix, com.github.philippheuer.events4j.core.EventManager eventManager, ScheduledThreadPoolExecutor executor, com.github.philippheuer.credentialmanager.CredentialManager credentialManager, com.github.philippheuer.credentialmanager.domain.OAuth2Credential defaultToken) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleandisableClipEventListenerForId(String channelId) Disable Clip Creation Listener, without invoking a Helix API callbooleandisableFollowEventListenerForId(String channelId) Disable Follow Listener, without invoking a Helix API callbooleandisableStreamEventListenerForId(String channelId) Disable StreamEventListener, without invoking a Helix API callbooleanenableClipEventListener(String channelId, String channelName, Instant startedAt) Enable Clip Creation Listener, without invoking a Helix API call, starting at a custom timestampbooleanenableFollowEventListener(String channelId, String channelName) Enable Follow Listener, without invoking a Helix API callbooleanenableStreamEventListener(String channelId, String channelName) Enable StreamEvent Listener, without invoking a Helix API callgetCachedInformation(String channelId) Get cached information for a channel's stream status and follower count.Twitch HelixvoidsetThreadDelay(long threadDelay) UpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.twitch4j.IClientHelper
disableClipEventListener, disableClipEventListener, disableFollowEventListener, disableFollowEventListener, disableStreamEventListener, disableStreamEventListener, enableClipEventListener, enableClipEventListener, enableClipEventListener, enableFollowEventListener, enableFollowEventListener, enableStreamEventListener, enableStreamEventListener, setThreadRate
-
Field Details
-
REQUIRED_THREAD_COUNT
public static final int REQUIRED_THREAD_COUNT- See Also:
-
-
Constructor Details
-
TwitchClientHelper
@Internal public TwitchClientHelper(TwitchHelix twitchHelix, com.github.philippheuer.events4j.core.EventManager eventManager, ScheduledThreadPoolExecutor executor, com.github.philippheuer.credentialmanager.CredentialManager credentialManager, com.github.philippheuer.credentialmanager.domain.OAuth2Credential defaultToken) Constructor- Parameters:
twitchHelix- TwitchHelixeventManager- EventManagerexecutor- ScheduledThreadPoolExecutorcredentialManager- CredentialManagerdefaultToken- OAuth2Credential
-
-
Method Details
-
enableStreamEventListener
Description copied from interface:IClientHelperEnable StreamEvent Listener, without invoking a Helix API call- Specified by:
enableStreamEventListenerin interfaceIClientHelper- Parameters:
channelId- Channel IdchannelName- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableStreamEventListenerForId
Description copied from interface:IClientHelperDisable StreamEventListener, without invoking a Helix API call- Specified by:
disableStreamEventListenerForIdin interfaceIClientHelper- Parameters:
channelId- Channel Id- Returns:
- true if the channel was removed, false otherwise
-
enableFollowEventListener
Description copied from interface:IClientHelperEnable Follow Listener, without invoking a Helix API callFor
FollowEventto fire, defaultAuthToken must be a user access token from a moderator of the channel with theTwitchScopes.HELIX_CHANNEL_FOLLOWERS_READscope. Otherwise, the client helper can only fireChannelFollowCountUpdateEventdue to Twitch restrictions implemented on 2023-09-12.- Specified by:
enableFollowEventListenerin interfaceIClientHelper- Parameters:
channelId- Channel IdchannelName- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableFollowEventListenerForId
Description copied from interface:IClientHelperDisable Follow Listener, without invoking a Helix API call- Specified by:
disableFollowEventListenerForIdin interfaceIClientHelper- Parameters:
channelId- Channel Id- Returns:
- true when a previously-tracked channel was removed, false otherwise
-
enableClipEventListener
Description copied from interface:IClientHelperEnable Clip Creation Listener, without invoking a Helix API call, starting at a custom timestamp- Specified by:
enableClipEventListenerin interfaceIClientHelper- Parameters:
channelId- Channel IdchannelName- Channel NamestartedAt- The oldest clip creation timestamp to start the queries at- Returns:
- whether the channel was added
-
disableClipEventListenerForId
Description copied from interface:IClientHelperDisable Clip Creation Listener, without invoking a Helix API call- Specified by:
disableClipEventListenerForIdin interfaceIClientHelper- Parameters:
channelId- Channel Id- Returns:
- whether a previously-tracked channel was removed
-
setThreadDelay
public void setThreadDelay(long threadDelay) Description copied from interface:IClientHelperUpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e. stream status and followers)- Specified by:
setThreadDelayin interfaceIClientHelper- Parameters:
threadDelay- the minimum milliseconds delay between each api call
-
getCachedInformation
Description copied from interface:IClientHelperGet cached information for a channel's stream status and follower count.For this information to be valid, the respective event listeners need to be enabled for the channel.
For thread safety, the setters on this object should not be used; only getters.
- Specified by:
getCachedInformationin interfaceIClientHelper- Parameters:
channelId- The ID of the channel whose cache is to be retrieved.- Returns:
- ChannelCache in an optional wrapper.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getTwitchHelix
Twitch Helix- Specified by:
getTwitchHelixin interfaceIClientHelper
-