Class TwitchClientPoolBuilder

java.lang.Object
com.github.twitch4j.TwitchClientPoolBuilder

public class TwitchClientPoolBuilder extends Object
Builder to get a TwitchClientPool Instance by provided various options, to provide the user with a lot of customizable options.
  • Field Details

    • botOwnerIds

      protected Collection<String> botOwnerIds
      User IDs of Bot Owners for applying CommandPermission.OWNER
    • commandPrefixes

      protected Set<String> commandPrefixes
      IRC Command Handlers
    • chatQueueSize

      protected Integer chatQueueSize
      Size of the ChatQueue
    • chatRateLimit

      protected io.github.bucket4j.Bandwidth chatRateLimit
      Custom RateLimit for ChatMessages
    • chatWhisperLimit

      @Deprecated protected io.github.bucket4j.Bandwidth[] chatWhisperLimit
      Deprecated.
      Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
      Custom RateLimit for Whispers
    • chatJoinLimit

      protected io.github.bucket4j.Bandwidth chatJoinLimit
      Custom RateLimit for JOIN/PART
    • chatAuthLimit

      protected io.github.bucket4j.Bandwidth chatAuthLimit
      Custom RateLimit for AUTH
    • chatChannelMessageLimit

      protected io.github.bucket4j.Bandwidth chatChannelMessageLimit
      Custom RateLimit for Messages per Channel

      For example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).

  • Method Details

    • withBotOwnerId

      public TwitchClientPoolBuilder withBotOwnerId(String userId)
      With a Bot Owner's User ID
      Parameters:
      userId - the user id
      Returns:
      TwitchClientPoolBuilder
    • withCommandTrigger

      public TwitchClientPoolBuilder withCommandTrigger(String commandTrigger)
      With a CommandTrigger
      Parameters:
      commandTrigger - Command Trigger (Prefix)
      Returns:
      TwitchClientPoolBuilder
    • withHelperThreadRate

      @Deprecated public TwitchClientPoolBuilder withHelperThreadRate(long helperThreadDelay)
      Deprecated.
      in favor of withHelperThreadDelay
      With a base thread delay for API calls by TwitchClientHelper

      Note: the method name has been a misnomer as it has always set the delay rather than a rate. One can change the rate at any time via IClientHelper.setThreadRate(long).

      Parameters:
      helperThreadDelay - TwitchClientHelper Base Thread Delay
      Returns:
      TwitchClientPoolBuilder
    • builder

      public static TwitchClientPoolBuilder builder()
      Initialize the builder
      Returns:
      Twitch Client Pool Builder
    • build

      public TwitchClientPool build()
      Initialize
      Returns:
      TwitchClientPool initialized class
    • getClientId

      public String getClientId()
      Client Id
    • getClientSecret

      public String getClientSecret()
      Client Secret
    • getUserAgent

      public String getUserAgent()
      User Agent
    • getRequestQueueSize

      public Integer getRequestQueueSize()
      HTTP Request Queue Size
    • getRedirectUrl

      public String getRedirectUrl()
      Redirect Url
    • getTimeout

      public Integer getTimeout()
      Default Timeout
    • getEnableExtensions

      @Deprecated public Boolean getEnableExtensions()
      Deprecated.
      the Extensions API traditionally uses the decommissioned Kraken API. While the module now forwards calls to Helix, please migrate to using Helix directly as this module will be removed in the future.
      Enabled: Extensions
      See Also:
    • getEnableHelix

      public Boolean getEnableHelix()
      Enabled: Helix
    • getEnableKraken

      @Deprecated public Boolean getEnableKraken()
      Deprecated.
      Twitch shutdown the Kraken API in 2022.
      Enabled: Kraken
    • getEnableTMI

      @Deprecated public Boolean getEnableTMI()
      Deprecated.
      All of the TwitchMessagingInterfaceBuilder endpoints have been (or will be) decommissioned by Twitch.
      Enabled: TMI
    • getEnableChat

      public Boolean getEnableChat()
      Enabled: Chat
    • getEnableEventSocket

      public Boolean getEnableEventSocket()
      Enabled: EventSub over WebSocket
    • getEnableChatPool

      public Boolean getEnableChatPool()
    • getMaxChannelsPerChatInstance

      public int getMaxChannelsPerChatInstance()
    • getBotOwnerIds

      public Collection<String> getBotOwnerIds()
      User IDs of Bot Owners for applying CommandPermission.OWNER
    • getCommandPrefixes

      public Set<String> getCommandPrefixes()
      IRC Command Handlers
    • getEnablePubSub

      public Boolean getEnablePubSub()
      Enabled: PubSub
    • getEnablePubSubPool

      public Boolean getEnablePubSubPool()
    • getMaxTopicsPerPubSubInstance

      public int getMaxTopicsPerPubSubInstance()
    • getEnableGraphQL

      public Boolean getEnableGraphQL()
      Enabled: GraphQL

      This is an unofficial API that is not intended for third-party use. Use at your own risk. Methods could change or stop working at any time.

    • getChatAccount

      public com.github.philippheuer.credentialmanager.domain.OAuth2Credential getChatAccount()
      Chat Account
    • getEventManager

      public com.github.philippheuer.events4j.core.EventManager getEventManager()
      EventManager
    • getDefaultEventHandler

      public Class<? extends com.github.philippheuer.events4j.api.service.IEventHandler> getDefaultEventHandler()
      EventManager
    • getChatQueueSize

      public Integer getChatQueueSize()
      Size of the ChatQueue
    • getChatRateLimit

      public io.github.bucket4j.Bandwidth getChatRateLimit()
      Custom RateLimit for ChatMessages
    • getChatWhisperLimit

      @Deprecated public io.github.bucket4j.Bandwidth[] getChatWhisperLimit()
      Deprecated.
      Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
      Custom RateLimit for Whispers
    • getChatJoinLimit

      public io.github.bucket4j.Bandwidth getChatJoinLimit()
      Custom RateLimit for JOIN/PART
    • getChatAuthLimit

      public io.github.bucket4j.Bandwidth getChatAuthLimit()
      Custom RateLimit for AUTH
    • getChatChannelMessageLimit

      public io.github.bucket4j.Bandwidth getChatChannelMessageLimit()
      Custom RateLimit for Messages per Channel

      For example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).

    • getChatQueueTimeout

      public long getChatQueueTimeout()
      Wait time for taking items off chat queue in milliseconds. Default recommended
    • getChatMaxJoinRetries

      public int getChatMaxJoinRetries()
      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.
    • getChatServer

      public String getChatServer()
      Sets the default server used for chat

      Defaults to TwitchChat.TWITCH_WEB_SOCKET_SERVER, you can use TwitchChat.FDGT_TEST_SOCKET_SERVER for testing

    • getHelixBaseUrl

      public String getHelixBaseUrl()
      The base URL to use for Helix API calls.

      Can be adjusted to point to the Twitch CLI Mock API, for example.

      See Also:
    • getCredentialManager

      @NotNull public @NotNull com.github.philippheuer.credentialmanager.CredentialManager getCredentialManager()
      CredentialManager
    • getScheduledThreadPoolExecutor

      public ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor()
      Scheduler Thread Pool Executor
    • getHelperThreadDelay

      public long getHelperThreadDelay()
      Millisecond Delay for Client Helper Thread
    • getDefaultAuthToken

      public com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultAuthToken()
      Default Auth Token for API Requests
    • getDefaultFirstPartyToken

      public com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultFirstPartyToken()
      Default First-Party OAuth Token for GraphQL calls
    • getProxyConfig

      public ProxyConfig getProxyConfig()
      Proxy Configuration
    • getFeignLogLevel

      public feign.Logger.Level getFeignLogLevel()
      you can overwrite the feign loglevel to print the full requests + responses if needed
    • 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:
    • isChatCommandsViaHelix

      public boolean isChatCommandsViaHelix()
      Whether chat commands should be executed via the Helix API, if possible.

      Must have withEnableHelix(Boolean) set to true. Must have withEnableChat(Boolean) or withEnableChatPool(Boolean) set to true.

      Must have withChatAccount(OAuth2Credential) or withDefaultAuthToken(OAuth2Credential) specified.

    • getForwardedChatCommandHelixLimitPerChannel

      public io.github.bucket4j.Bandwidth getForwardedChatCommandHelixLimitPerChannel()
      The per-channel rate limit at which chat commands forwarded to helix should be executed.

      This prevents commands to a single channel from consuming the entire helix rate limit bucket. As such, this can be restricted further or loosened, depending on how many channels the bot serves.

      This has no effect unless isChatCommandsViaHelix() is true.

      Users should migrate to manual helix calls (with whatever throttling they desire) instead.

    • withClientId

      public TwitchClientPoolBuilder withClientId(String clientId)
      Client Id
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withClientSecret

      public TwitchClientPoolBuilder withClientSecret(String clientSecret)
      Client Secret
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withUserAgent

      public TwitchClientPoolBuilder withUserAgent(String userAgent)
      User Agent
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withRequestQueueSize

      public TwitchClientPoolBuilder withRequestQueueSize(Integer requestQueueSize)
      HTTP Request Queue Size
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withRedirectUrl

      public TwitchClientPoolBuilder withRedirectUrl(String redirectUrl)
      Redirect Url
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withTimeout

      public TwitchClientPoolBuilder withTimeout(Integer timeout)
      Default Timeout
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableExtensions

      @Deprecated public TwitchClientPoolBuilder withEnableExtensions(Boolean enableExtensions)
      Deprecated.
      the Extensions API traditionally uses the decommissioned Kraken API. While the module now forwards calls to Helix, please migrate to using Helix directly as this module will be removed in the future.
      Enabled: Extensions
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
      See Also:
    • withEnableHelix

      public TwitchClientPoolBuilder withEnableHelix(Boolean enableHelix)
      Enabled: Helix
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableKraken

      @Deprecated public TwitchClientPoolBuilder withEnableKraken(Boolean enableKraken)
      Deprecated.
      Twitch shutdown the Kraken API in 2022.
      Enabled: Kraken
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableTMI

      @Deprecated public TwitchClientPoolBuilder withEnableTMI(Boolean enableTMI)
      Deprecated.
      All of the TwitchMessagingInterfaceBuilder endpoints have been (or will be) decommissioned by Twitch.
      Enabled: TMI
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableChat

      public TwitchClientPoolBuilder withEnableChat(Boolean enableChat)
      Enabled: Chat
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableEventSocket

      public TwitchClientPoolBuilder withEnableEventSocket(Boolean enableEventSocket)
      Enabled: EventSub over WebSocket
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableChatPool

      public TwitchClientPoolBuilder withEnableChatPool(Boolean enableChatPool)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withMaxChannelsPerChatInstance

      public TwitchClientPoolBuilder withMaxChannelsPerChatInstance(int maxChannelsPerChatInstance)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • setBotOwnerIds

      public TwitchClientPoolBuilder setBotOwnerIds(Collection<String> botOwnerIds)
      User IDs of Bot Owners for applying CommandPermission.OWNER
      Returns:
      this.
    • withEnablePubSub

      public TwitchClientPoolBuilder withEnablePubSub(Boolean enablePubSub)
      Enabled: PubSub
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnablePubSubPool

      public TwitchClientPoolBuilder withEnablePubSubPool(Boolean enablePubSubPool)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withMaxTopicsPerPubSubInstance

      public TwitchClientPoolBuilder withMaxTopicsPerPubSubInstance(int maxTopicsPerPubSubInstance)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEnableGraphQL

      public TwitchClientPoolBuilder withEnableGraphQL(Boolean enableGraphQL)
      Enabled: GraphQL

      This is an unofficial API that is not intended for third-party use. Use at your own risk. Methods could change or stop working at any time.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatAccount

      public TwitchClientPoolBuilder withChatAccount(com.github.philippheuer.credentialmanager.domain.OAuth2Credential chatAccount)
      Chat Account
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withEventManager

      public TwitchClientPoolBuilder withEventManager(com.github.philippheuer.events4j.core.EventManager eventManager)
      EventManager
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withDefaultEventHandler

      public TwitchClientPoolBuilder 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).
    • withChatQueueSize

      public TwitchClientPoolBuilder withChatQueueSize(Integer chatQueueSize)
      Size of the ChatQueue
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatRateLimit

      public TwitchClientPoolBuilder withChatRateLimit(io.github.bucket4j.Bandwidth chatRateLimit)
      Custom RateLimit for ChatMessages
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatWhisperLimit

      @Deprecated public TwitchClientPoolBuilder withChatWhisperLimit(io.github.bucket4j.Bandwidth[] chatWhisperLimit)
      Deprecated.
      Twitch will decommission whispers over IRC on February 18, 2023; please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
      Custom RateLimit for Whispers
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatJoinLimit

      public TwitchClientPoolBuilder withChatJoinLimit(io.github.bucket4j.Bandwidth chatJoinLimit)
      Custom RateLimit for JOIN/PART
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatAuthLimit

      public TwitchClientPoolBuilder withChatAuthLimit(io.github.bucket4j.Bandwidth chatAuthLimit)
      Custom RateLimit for AUTH
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatChannelMessageLimit

      public TwitchClientPoolBuilder withChatChannelMessageLimit(io.github.bucket4j.Bandwidth chatChannelMessageLimit)
      Custom RateLimit for Messages per Channel

      For 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).
    • withChatQueueTimeout

      public TwitchClientPoolBuilder withChatQueueTimeout(long chatQueueTimeout)
      Wait time for taking items off chat queue in milliseconds. Default recommended
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withChatMaxJoinRetries

      public TwitchClientPoolBuilder withChatMaxJoinRetries(int chatMaxJoinRetries)
      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).
    • withChatServer

      public TwitchClientPoolBuilder withChatServer(String chatServer)
      Sets the default server used for chat

      Defaults to TwitchChat.TWITCH_WEB_SOCKET_SERVER, you can use TwitchChat.FDGT_TEST_SOCKET_SERVER for testing

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withHelixBaseUrl

      public TwitchClientPoolBuilder withHelixBaseUrl(String helixBaseUrl)
      The base URL to use for Helix API calls.

      Can be adjusted to point to the Twitch CLI Mock API, for example.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
      See Also:
    • withCredentialManager

      public TwitchClientPoolBuilder withCredentialManager(@NotNull @NotNull com.github.philippheuer.credentialmanager.CredentialManager credentialManager)
      CredentialManager
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withScheduledThreadPoolExecutor

      public TwitchClientPoolBuilder 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).
    • withHelperThreadDelay

      public TwitchClientPoolBuilder withHelperThreadDelay(long helperThreadDelay)
      Millisecond Delay for Client Helper Thread
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withDefaultAuthToken

      public TwitchClientPoolBuilder withDefaultAuthToken(com.github.philippheuer.credentialmanager.domain.OAuth2Credential defaultAuthToken)
      Default Auth Token for API Requests
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withDefaultFirstPartyToken

      public TwitchClientPoolBuilder withDefaultFirstPartyToken(com.github.philippheuer.credentialmanager.domain.OAuth2Credential defaultFirstPartyToken)
      Default First-Party OAuth Token for GraphQL calls
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withProxyConfig

      public TwitchClientPoolBuilder withProxyConfig(ProxyConfig proxyConfig)
      Proxy Configuration
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withFeignLogLevel

      public TwitchClientPoolBuilder withFeignLogLevel(feign.Logger.Level feignLogLevel)
      you can overwrite the feign loglevel to print the full requests + responses if needed
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withWsPingPeriod

      public TwitchClientPoolBuilder withWsPingPeriod(int wsPingPeriod)
      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

      public TwitchClientPoolBuilder withWsCloseDelay(int wsCloseDelay)
      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:
    • withChatCommandsViaHelix

      public TwitchClientPoolBuilder withChatCommandsViaHelix(boolean chatCommandsViaHelix)
      Whether chat commands should be executed via the Helix API, if possible.

      Must have withEnableHelix(Boolean) set to true. Must have withEnableChat(Boolean) or withEnableChatPool(Boolean) set to true.

      Must have withChatAccount(OAuth2Credential) or withDefaultAuthToken(OAuth2Credential) specified.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withForwardedChatCommandHelixLimitPerChannel

      @Deprecated public TwitchClientPoolBuilder withForwardedChatCommandHelixLimitPerChannel(io.github.bucket4j.Bandwidth forwardedChatCommandHelixLimitPerChannel)
      Deprecated.
      The per-channel rate limit at which chat commands forwarded to helix should be executed.

      This prevents commands to a single channel from consuming the entire helix rate limit bucket. As such, this can be restricted further or loosened, depending on how many channels the bot serves.

      This has no effect unless isChatCommandsViaHelix() is true.

      Users should migrate to manual helix calls (with whatever throttling they desire) instead.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).