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
-
Constructor Summary
ConstructorDescriptionTwitchClientHelper
(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 TypeMethodDescriptionvoid
close()
boolean
disableClipEventListenerForId
(String channelId) Disable Clip Creation Listener, without invoking a Helix API callboolean
disableFollowEventListenerForId
(String channelId) Disable Follow Listener, without invoking a Helix API callboolean
disableStreamEventListenerForId
(String channelId) Disable StreamEventListener, without invoking a Helix API callboolean
enableClipEventListener
(String channelId, String channelName, Instant startedAt) Enable Clip Creation Listener, without invoking a Helix API call, starting at a custom timestampboolean
enableFollowEventListener
(String channelId, String channelName) Enable Follow Listener, without invoking a Helix API callboolean
enableStreamEventListener
(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 Helixvoid
setThreadDelay
(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, wait
Methods 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:IClientHelper
Enable StreamEvent Listener, without invoking a Helix API call- Specified by:
enableStreamEventListener
in interfaceIClientHelper
- Parameters:
channelId
- Channel IdchannelName
- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableStreamEventListenerForId
Description copied from interface:IClientHelper
Disable StreamEventListener, without invoking a Helix API call- Specified by:
disableStreamEventListenerForId
in interfaceIClientHelper
- Parameters:
channelId
- Channel Id- Returns:
- true if the channel was removed, false otherwise
-
enableFollowEventListener
Description copied from interface:IClientHelper
Enable Follow Listener, without invoking a Helix API callFor
FollowEvent
to fire, defaultAuthToken must be a user access token from a moderator of the channel with theTwitchScopes.HELIX_CHANNEL_FOLLOWERS_READ
scope. Otherwise, the client helper can only fireChannelFollowCountUpdateEvent
due to Twitch restrictions implemented on 2023-09-12.- Specified by:
enableFollowEventListener
in interfaceIClientHelper
- Parameters:
channelId
- Channel IdchannelName
- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableFollowEventListenerForId
Description copied from interface:IClientHelper
Disable Follow Listener, without invoking a Helix API call- Specified by:
disableFollowEventListenerForId
in interfaceIClientHelper
- Parameters:
channelId
- Channel Id- Returns:
- true when a previously-tracked channel was removed, false otherwise
-
enableClipEventListener
Description copied from interface:IClientHelper
Enable Clip Creation Listener, without invoking a Helix API call, starting at a custom timestamp- Specified by:
enableClipEventListener
in 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:IClientHelper
Disable Clip Creation Listener, without invoking a Helix API call- Specified by:
disableClipEventListenerForId
in interfaceIClientHelper
- Parameters:
channelId
- Channel Id- Returns:
- whether a previously-tracked channel was removed
-
setThreadDelay
public void setThreadDelay(long threadDelay) Description copied from interface:IClientHelper
UpdatesExponentialBackoffStrategy.getBaseMillis()
for each of the independent listeners (i.e. stream status and followers)- Specified by:
setThreadDelay
in interfaceIClientHelper
- Parameters:
threadDelay
- the minimum milliseconds delay between each api call
-
getCachedInformation
Description copied from interface:IClientHelper
Get 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:
getCachedInformation
in 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:
close
in interfaceAutoCloseable
-
getTwitchHelix
Twitch Helix- Specified by:
getTwitchHelix
in interfaceIClientHelper
-