Class TwitchChatBuilder
Documentation: https://dev.twitch.tv/docs/irc
-
Field Summary
Modifier and TypeFieldDescriptionprotected io.github.bucket4j.Bandwidth
Custom RateLimit for AUTHprotected Collection<String>
User IDs of Bot Owners for applyingCommandPermission.OWNER
protected Integer
Size of the ChatQueueprotected io.github.bucket4j.Bandwidth
Custom RateLimit for ChatMessagesIRC Command Handlersprotected io.github.bucket4j.Bucket
Shared bucket for authsprotected io.github.bucket4j.Bucket
Shared bucket for joinsprotected io.github.bucket4j.Bucket
Shared bucket for messagesprotected io.github.bucket4j.Bucket
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitprotected io.github.bucket4j.Bandwidth
Custom RateLimit for JOIN/PARTprotected io.github.bucket4j.Bandwidth
Custom RateLimit for Messages per Channelprotected io.github.bucket4j.Bandwidth[]
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Twitch API Client (Helix)static TwitchChatBuilder
builder()
Initialize the builderio.github.bucket4j.Bandwidth
Custom RateLimit for AUTHA custom websocket url forTwitchChat
to connect to.User IDs of Bot Owners for applyingCommandPermission.OWNER
com.github.philippheuer.credentialmanager.domain.OAuth2Credential
IRC User Idlong
The amount of milliseconds to wait after queuing a JOIN before classifying the attempt as a failure.Size of the ChatQueuelong
Millisecond wait time for taking items off chat queue.io.github.bucket4j.Bandwidth
Custom RateLimit for ChatMessagesClient IdClient SecretIRC Command HandlersWebSocket Connection Backoff Strategycom.github.philippheuer.credentialmanager.CredentialManager
Credential ManagerClass<? extends com.github.philippheuer.events4j.api.service.IEventHandler>
EventManagercom.github.philippheuer.events4j.core.EventManager
Event Managerio.github.bucket4j.Bucket
Shared bucket for authsio.github.bucket4j.Bucket
Shared bucket for joinsio.github.bucket4j.Bucket
Shared bucket for messagesio.github.bucket4j.Bucket
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitio.github.bucket4j.Bandwidth
Custom RateLimit for JOIN/PARTint
The maximum number of retries to make for joining each channel, with exponential backoff.io.github.bucket4j.Bandwidth
Custom RateLimit for Messages per ChannelProxy ConfigurationHTTP Request Queue SizeScheduler Thread Pool ExecutorWebsocketConnectionio.github.bucket4j.Bandwidth[]
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitint
Websocket Close Delay in ms (0 = minimum)int
WebSocket RFC Ping Period in ms (0 = disabled)boolean
Whether one's own channel should automatically be joinedboolean
Whether JOIN/PART events should be enabled for theTwitchChat
instance.boolean
Whether join failures should result in removal from current channels.boolean
Whether theOAuth2Credential
password should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library.boolean
Whether thegetChatAccount()
should be validated on reconnection failures.setBotOwnerIds
(Collection<String> botOwnerIds) User IDs of Bot Owners for applyingCommandPermission.OWNER
setCommandPrefixes
(Set<String> commandPrefixes) IRC Command HandlerswithAuthRateLimit
(io.github.bucket4j.Bandwidth authRateLimit) Custom RateLimit for AUTHwithAutoJoinOwnChannel
(boolean autoJoinOwnChannel) Whether one's own channel should automatically be joinedwithBaseUrl
(String baseUrl) A custom websocket url forTwitchChat
to connect to.withBotOwnerId
(String userId) With a Bot Owner's User IDwithBotOwnerIds
(Collection<String> botOwnerIds) With multiple Bot Owner User IDswithChatAccount
(com.github.philippheuer.credentialmanager.domain.OAuth2Credential chatAccount) IRC User IdwithChatJoinTimeout
(long chatJoinTimeout) The amount of milliseconds to wait after queuing a JOIN before classifying the attempt as a failure.withChatQueueSize
(Integer chatQueueSize) Size of the ChatQueuewithChatQueueTimeout
(long chatQueueTimeout) Millisecond wait time for taking items off chat queue.withChatRateLimit
(io.github.bucket4j.Bandwidth chatRateLimit) Custom RateLimit for ChatMessageswithClientId
(String clientId) Client IdwithClientSecret
(String clientSecret) Client SecretwithCommandTrigger
(String commandTrigger) With a CommandTriggerwithCommandTriggers
(Collection<String> commandTrigger) With multiple CommandTriggerswithConnectionBackoffStrategy
(IBackoffStrategy connectionBackoffStrategy) WebSocket Connection Backoff StrategywithCredentialManager
(com.github.philippheuer.credentialmanager.CredentialManager credentialManager) Credential ManagerwithDefaultEventHandler
(Class<? extends com.github.philippheuer.events4j.api.service.IEventHandler> defaultEventHandler) EventManagerwithEnableMembershipEvents
(boolean enableMembershipEvents) Whether JOIN/PART events should be enabled for theTwitchChat
instance.withEventManager
(com.github.philippheuer.events4j.core.EventManager eventManager) Event ManagerwithIrcAuthBucket
(io.github.bucket4j.Bucket ircAuthBucket) Shared bucket for authswithIrcJoinBucket
(io.github.bucket4j.Bucket ircJoinBucket) Shared bucket for joinswithIrcMessageBucket
(io.github.bucket4j.Bucket ircMessageBucket) Shared bucket for messageswithIrcWhisperBucket
(io.github.bucket4j.Bucket ircWhisperBucket) Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitwithJoinRateLimit
(io.github.bucket4j.Bandwidth joinRateLimit) Custom RateLimit for JOIN/PARTwithMaxJoinRetries
(int maxJoinRetries) The maximum number of retries to make for joining each channel, with exponential backoff.withOutboundCommandFilter
(BiPredicate<TwitchChat, String> outboundCommandFilter) Deprecated.withPerChannelRateLimit
(io.github.bucket4j.Bandwidth perChannelRateLimit) Custom RateLimit for Messages per ChannelwithProxyConfig
(ProxyConfig proxyConfig) Proxy ConfigurationwithRemoveChannelOnJoinFailure
(boolean removeChannelOnJoinFailure) Whether join failures should result in removal from current channels.withRequestQueueSize
(Integer requestQueueSize) HTTP Request Queue SizewithScheduledThreadPoolExecutor
(ScheduledThreadPoolExecutor scheduledThreadPoolExecutor) Scheduler Thread Pool ExecutorwithSendCredentialToThirdPartyHost
(boolean sendCredentialToThirdPartyHost) Whether theOAuth2Credential
password should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library.withVerifyChatAccountOnReconnect
(boolean verifyChatAccountOnReconnect) Whether thegetChatAccount()
should be validated on reconnection failures.protected TwitchChatBuilder
withWebsocketConnection
(WebsocketConnection websocketConnection) WebsocketConnectionwithWhisperRateLimit
(io.github.bucket4j.Bandwidth[] whisperRateLimit) Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitwithWsCloseDelay
(int wsCloseDelay) Websocket Close Delay in ms (0 = minimum)withWsPingPeriod
(int wsPingPeriod) WebSocket RFC Ping Period in ms (0 = disabled)
-
Field Details
-
botOwnerIds
User IDs of Bot Owners for applyingCommandPermission.OWNER
-
commandPrefixes
IRC Command Handlers -
chatQueueSize
Size of the ChatQueue -
chatRateLimit
protected io.github.bucket4j.Bandwidth chatRateLimitCustom RateLimit for ChatMessages -
whisperRateLimit
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitCustom RateLimit for Whispers -
joinRateLimit
protected io.github.bucket4j.Bandwidth joinRateLimitCustom RateLimit for JOIN/PART -
authRateLimit
protected io.github.bucket4j.Bandwidth authRateLimitCustom RateLimit for AUTH -
perChannelRateLimit
protected io.github.bucket4j.Bandwidth perChannelRateLimitCustom RateLimit for Messages per ChannelFor example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).
-
ircMessageBucket
protected io.github.bucket4j.Bucket ircMessageBucketShared bucket for messages -
ircWhisperBucket
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitShared bucket for whispers -
ircJoinBucket
protected io.github.bucket4j.Bucket ircJoinBucketShared bucket for joins -
ircAuthBucket
protected io.github.bucket4j.Bucket ircAuthBucketShared bucket for auths
-
-
Method Details
-
builder
Initialize the builder- Returns:
- Twitch Chat Builder
-
build
Twitch API Client (Helix)- Returns:
- TwitchHelix
-
withCommandTrigger
With a CommandTrigger- Parameters:
commandTrigger
- Command Trigger (Prefix)- Returns:
- TwitchChatBuilder
-
withCommandTriggers
With multiple CommandTriggers- Parameters:
commandTrigger
- Command Trigger (Prefix)- Returns:
- TwitchChatBuilder
-
withBotOwnerId
With a Bot Owner's User ID- Parameters:
userId
- the user id- Returns:
- TwitchChatBuilder
-
withBotOwnerIds
With multiple Bot Owner User IDs- Parameters:
botOwnerIds
- the user ids- Returns:
- TwitchChatBuilder
-
getWebsocketConnection
WebsocketConnectioncan be used to inject a mocked connection into the TwitchChat instance
-
getClientId
Client Id -
getClientSecret
Client Secret -
getRequestQueueSize
HTTP Request Queue Size -
getEventManager
public com.github.philippheuer.events4j.core.EventManager getEventManager()Event Manager -
getDefaultEventHandler
public Class<? extends com.github.philippheuer.events4j.api.service.IEventHandler> getDefaultEventHandler()EventManager -
getCredentialManager
public com.github.philippheuer.credentialmanager.CredentialManager getCredentialManager()Credential Manager -
getChatAccount
public com.github.philippheuer.credentialmanager.domain.OAuth2Credential getChatAccount()IRC User Id -
getBaseUrl
A custom websocket url forTwitchChat
to connect to. Must include the scheme (e.g. ws:// or wss://). -
isSendCredentialToThirdPartyHost
public boolean isSendCredentialToThirdPartyHost()Whether theOAuth2Credential
password should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library.Do not depart from the default false value unless you understand the consequences.
-
getBotOwnerIds
User IDs of Bot Owners for applyingCommandPermission.OWNER
-
getCommandPrefixes
IRC Command Handlers -
getChatQueueSize
Size of the ChatQueue -
getChatRateLimit
public io.github.bucket4j.Bandwidth getChatRateLimit()Custom RateLimit for ChatMessages -
getWhisperRateLimit
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitCustom RateLimit for Whispers -
getJoinRateLimit
public io.github.bucket4j.Bandwidth getJoinRateLimit()Custom RateLimit for JOIN/PART -
getAuthRateLimit
public io.github.bucket4j.Bandwidth getAuthRateLimit()Custom RateLimit for AUTH -
getPerChannelRateLimit
public io.github.bucket4j.Bandwidth getPerChannelRateLimit()Custom RateLimit for Messages per ChannelFor example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).
-
getIrcMessageBucket
public io.github.bucket4j.Bucket getIrcMessageBucket()Shared bucket for messages -
getIrcWhisperBucket
Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitShared bucket for whispers -
getIrcJoinBucket
public io.github.bucket4j.Bucket getIrcJoinBucket()Shared bucket for joins -
getIrcAuthBucket
public io.github.bucket4j.Bucket getIrcAuthBucket()Shared bucket for auths -
getScheduledThreadPoolExecutor
Scheduler Thread Pool Executor -
getChatQueueTimeout
public long getChatQueueTimeout()Millisecond wait time for taking items off chat queue. Default recommended -
getProxyConfig
Proxy Configuration -
isAutoJoinOwnChannel
public boolean isAutoJoinOwnChannel()Whether one's own channel should automatically be joined -
isEnableMembershipEvents
public boolean isEnableMembershipEvents()Whether JOIN/PART events should be enabled for theTwitchChat
instance. -
isRemoveChannelOnJoinFailure
public boolean isRemoveChannelOnJoinFailure()Whether join failures should result in removal from current channels.- See Also:
-
getMaxJoinRetries
public int getMaxJoinRetries()The maximum number of retries to make for joining each channel, with exponential backoff. Set to zero or a negative value to disable this feature. -
getChatJoinTimeout
public long getChatJoinTimeout()The amount of milliseconds to wait after queuing a JOIN before classifying the attempt as a failure.If this value is configured too low, the chat instance could mistake a successfully joined channel for a failure. This can be especially problematic when removeChannelOnJoinFailure has been set to true.
-
getWsPingPeriod
public int getWsPingPeriod()WebSocket RFC Ping Period in ms (0 = disabled) -
getWsCloseDelay
public int getWsCloseDelay()Websocket Close Delay in ms (0 = minimum)- See Also:
-
getConnectionBackoffStrategy
WebSocket Connection Backoff Strategy -
isVerifyChatAccountOnReconnect
public boolean isVerifyChatAccountOnReconnect()Whether thegetChatAccount()
should be validated on reconnection failures.If enabled and the token has expired, chat will connect in read-only mode instead.
If the network connection is too slow, you may want to disable this setting to avoid disconnects while waiting for the result of the validate endpoint.
-
withWebsocketConnection
WebsocketConnectioncan be used to inject a mocked connection into the TwitchChat instance
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withClientId
Client Id- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withClientSecret
Client Secret- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withRequestQueueSize
HTTP Request Queue Size- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withEventManager
public TwitchChatBuilder withEventManager(com.github.philippheuer.events4j.core.EventManager eventManager) Event Manager- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withDefaultEventHandler
public TwitchChatBuilder withDefaultEventHandler(Class<? extends com.github.philippheuer.events4j.api.service.IEventHandler> defaultEventHandler) EventManager- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withCredentialManager
public TwitchChatBuilder withCredentialManager(com.github.philippheuer.credentialmanager.CredentialManager credentialManager) Credential Manager- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withChatAccount
public TwitchChatBuilder withChatAccount(com.github.philippheuer.credentialmanager.domain.OAuth2Credential chatAccount) IRC User Id- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withBaseUrl
A custom websocket url forTwitchChat
to connect to. Must include the scheme (e.g. ws:// or wss://).- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withSendCredentialToThirdPartyHost
Whether theOAuth2Credential
password should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library.Do not depart from the default false value unless you understand the consequences.
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
setBotOwnerIds
User IDs of Bot Owners for applyingCommandPermission.OWNER
- Returns:
this
.
-
setCommandPrefixes
IRC Command Handlers- Returns:
this
.
-
withChatQueueSize
Size of the ChatQueue- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withChatRateLimit
Custom RateLimit for ChatMessages- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withWhisperRateLimit
@Deprecated public TwitchChatBuilder withWhisperRateLimit(io.github.bucket4j.Bandwidth[] whisperRateLimit) Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitCustom RateLimit for Whispers- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withJoinRateLimit
Custom RateLimit for JOIN/PART- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withAuthRateLimit
Custom RateLimit for AUTH- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withPerChannelRateLimit
Custom RateLimit for Messages per ChannelFor example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withIrcMessageBucket
Shared bucket for messages- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withIrcWhisperBucket
@Deprecated public TwitchChatBuilder withIrcWhisperBucket(io.github.bucket4j.Bucket ircWhisperBucket) Deprecated.Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimitShared bucket for whispers- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withIrcJoinBucket
Shared bucket for joins- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withIrcAuthBucket
Shared bucket for auths- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withScheduledThreadPoolExecutor
public TwitchChatBuilder withScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor scheduledThreadPoolExecutor) Scheduler Thread Pool Executor- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withChatQueueTimeout
Millisecond wait time for taking items off chat queue. Default recommended- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withProxyConfig
Proxy Configuration- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withAutoJoinOwnChannel
Whether one's own channel should automatically be joined- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withEnableMembershipEvents
Whether JOIN/PART events should be enabled for theTwitchChat
instance.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withRemoveChannelOnJoinFailure
Whether join failures should result in removal from current channels.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed). - See Also:
-
withMaxJoinRetries
The maximum number of retries to make for joining each channel, with exponential backoff. Set to zero or a negative value to disable this feature.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withChatJoinTimeout
The amount of milliseconds to wait after queuing a JOIN before classifying the attempt as a failure.If this value is configured too low, the chat instance could mistake a successfully joined channel for a failure. This can be especially problematic when removeChannelOnJoinFailure has been set to true.
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withWsPingPeriod
WebSocket RFC Ping Period in ms (0 = disabled)- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withWsCloseDelay
Websocket Close Delay in ms (0 = minimum)- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed). - See Also:
-
withConnectionBackoffStrategy
WebSocket Connection Backoff Strategy- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withVerifyChatAccountOnReconnect
Whether thegetChatAccount()
should be validated on reconnection failures.If enabled and the token has expired, chat will connect in read-only mode instead.
If the network connection is too slow, you may want to disable this setting to avoid disconnects while waiting for the result of the validate endpoint.
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
withOutboundCommandFilter
@Deprecated @Internal public TwitchChatBuilder withOutboundCommandFilter(BiPredicate<TwitchChat, String> outboundCommandFilter) Deprecated.Filter for outbound messages. The command will not be sent to the IRC server if the predicate yields true.Only intended for internal use by twitch4j.
- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-