Package com.github.twitch4j.chat
Klasse TwitchChat
java.lang.Object
com.github.twitch4j.chat.TwitchChat
- Alle implementierten Schnittstellen:
ITwitchChat,AutoCloseable
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected final booleanWhether one's own channel should automatically be joinedprotected final Collection<String> Bot Owner IDsCache of per-channel message bucketsCache: ChannelId to ChannelNameCache: ChannelName to ChannelIdprotected final longMinimum milliseconds to wait after a join attemptprotected final longTime to wait for an item on the chat queue before continuing to next iteration If set too high your thread will be late check to shutdownIRC Command HandlersCurrent Channelsprotected final booleanWhether JOIN/PART events should be enabledstatic final StringThirdParty WebSocket Server for Testingprotected final TwitchIdentityProviderTwitch Identity Providerprotected final BucketIRC Auth Bucketprotected final BlockingQueue<String> IRC Command Queueprotected final BucketIRC Join Bucketprotected final BucketIRC Message Bucketprotected final BucketIRC Whisper BucketCache of recent number of join attempts for each channelprotected final intThe maximum number of attempts to make for joining each channelprotected final BandwidthIRC Per-Channel Message Limitprotected final ScheduledFuture<?> IRC Command Queue Threadprotected final booleanWhether join failures should result in removal from current channelsstatic final intprotected final booleanWhether theOAuth2Credentialpassword should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library.protected booleanCommand Queue Thread stop flagprotected final ScheduledExecutorServiceThread Pool Executorstatic final StringTwitch's official WebSocket Serverprotected final booleanWhether OAuth token status should be checked on reconnect -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungTwitchChat(WebsocketConnection websocketConnection, EventManager eventManager, CredentialManager credentialManager, OAuth2Credential chatCredential, String baseUrl, boolean sendCredentialToThirdPartyHost, Collection<String> commandPrefixes, Integer chatQueueSize, Bucket ircMessageBucket, Bucket ircWhisperBucket, Bucket ircJoinBucket, Bucket ircAuthBucket, ScheduledThreadPoolExecutor taskExecutor, long chatQueueTimeout, ProxyConfig proxyConfig, boolean autoJoinOwnChannel, boolean enableMembershipEvents, Collection<String> botOwnerIds, boolean removeChannelOnJoinFailure, int maxJoinRetries, long chatJoinTimeout, int wsPingPeriod, IBackoffStrategy connectionBackoffStrategy, Bandwidth perChannelRateLimit, boolean validateOnConnect, int wsCloseDelay, BiPredicate<TwitchChat, String> outboundCommandFilter) Constructor -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidclose()Closevoidconnect()Connecting to IRC-WSvoidDisconnecting from IRC-WSReturns a set of all currently joined channels (without # prefix)Veraltet.CredentialManagerVeraltet.use getChannels() insteadEventManagerlonggetState()booleanisChannelJoined(String channelName) Check if Chat is currently in a channelprotected voidvoidjoinChannel(String channelName) Joining the channelbooleanleaveChannel(String channelName) leaving the channelprotected voidprotected voidprotected voidonTextMessage(String text) voidReconnecting to IRC-WSprotected voidsendCommand(String command, String... args) Send IRC CommandbooleanSends a message to the channel while including the specified message tags.voidsendPrivateMessage(String targetUser, String message) Veraltet.Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#sendWhisperbooleanSend raw irc commandVon Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden com.github.twitch4j.chat.ITwitchChat
ban, clearChat, delete, sendActionMessage, sendAnnouncement, sendMessage, sendMessage, setEmoteOnly, setFollowersOnly, setSlowMode, setSubscribersOnly, setUniqueChat, timeout, unban
-
Felddetails
-
REQUIRED_THREAD_COUNT
public static final int REQUIRED_THREAD_COUNT- Siehe auch:
-
TWITCH_WEB_SOCKET_SERVER
Twitch's official WebSocket Server- Siehe auch:
-
FDGT_TEST_SOCKET_SERVER
ThirdParty WebSocket Server for Testing- Siehe auch:
-
sendCredentialToThirdPartyHost
protected final boolean sendCredentialToThirdPartyHostWhether theOAuth2Credentialpassword should be sent when the baseUrl does not match the official twitch websocket server, thus bypassing a security check in the library. -
currentChannels
Current Channels -
channelIdToChannelName
Cache: ChannelId to ChannelName -
channelNameToChannelId
Cache: ChannelName to ChannelId -
ircMessageBucket
IRC Message Bucket -
ircWhisperBucket
IRC Whisper Bucket -
ircJoinBucket
IRC Join Bucket -
ircAuthBucket
IRC Auth Bucket -
perChannelRateLimit
IRC Per-Channel Message Limit -
ircCommandQueue
IRC Command Queue -
queueThread
IRC Command Queue Thread -
stopQueueThread
protected volatile boolean stopQueueThreadCommand Queue Thread stop flag -
botOwnerIds
Bot Owner IDs -
commandPrefixes
IRC Command Handlers -
taskExecutor
Thread Pool Executor -
chatQueueTimeout
protected final long chatQueueTimeoutTime to wait for an item on the chat queue before continuing to next iteration If set too high your thread will be late check to shutdown -
autoJoinOwnChannel
protected final boolean autoJoinOwnChannelWhether one's own channel should automatically be joined -
removeChannelOnJoinFailure
protected final boolean removeChannelOnJoinFailureWhether join failures should result in removal from current channels -
enableMembershipEvents
protected final boolean enableMembershipEventsWhether JOIN/PART events should be enabled -
maxJoinRetries
protected final int maxJoinRetriesThe maximum number of attempts to make for joining each channel -
chatJoinTimeout
protected final long chatJoinTimeoutMinimum milliseconds to wait after a join attempt -
joinAttemptsByChannelName
Cache of recent number of join attempts for each channel -
bucketByChannelName
Cache of per-channel message buckets -
identityProvider
Twitch Identity Provider -
validateOnConnect
protected final boolean validateOnConnectWhether OAuth token status should be checked on reconnect
-
-
Konstruktordetails
-
TwitchChat
public TwitchChat(WebsocketConnection websocketConnection, EventManager eventManager, CredentialManager credentialManager, OAuth2Credential chatCredential, String baseUrl, boolean sendCredentialToThirdPartyHost, Collection<String> commandPrefixes, Integer chatQueueSize, Bucket ircMessageBucket, Bucket ircWhisperBucket, Bucket ircJoinBucket, Bucket ircAuthBucket, ScheduledThreadPoolExecutor taskExecutor, long chatQueueTimeout, ProxyConfig proxyConfig, boolean autoJoinOwnChannel, boolean enableMembershipEvents, Collection<String> botOwnerIds, boolean removeChannelOnJoinFailure, int maxJoinRetries, long chatJoinTimeout, int wsPingPeriod, IBackoffStrategy connectionBackoffStrategy, Bandwidth perChannelRateLimit, boolean validateOnConnect, int wsCloseDelay, BiPredicate<TwitchChat, String> outboundCommandFilter) Constructor- Parameter:
websocketConnection- WebsocketConnectioneventManager- EventManagercredentialManager- CredentialManagerchatCredential- Chat CredentialbaseUrl- The websocket url for the chat client to connect tosendCredentialToThirdPartyHost- Whether the password should be sent when the baseUrl is not officialcommandPrefixes- Command PrefixeschatQueueSize- Chat Queue SizeircMessageBucket- Bucket for chatircWhisperBucket- Bucket for whispersircJoinBucket- Bucket for joinsircAuthBucket- Bucket for authstaskExecutor- ScheduledThreadPoolExecutorchatQueueTimeout- Timeout to wait for events in Chat QueueproxyConfig- Proxy ConfigurationautoJoinOwnChannel- Whether one's own channel should automatically be joinedenableMembershipEvents- Whether JOIN/PART events should be enabledbotOwnerIds- Bot Owner IDsremoveChannelOnJoinFailure- Whether channels should be removed after a join failuremaxJoinRetries- Maximum join retries per channelchatJoinTimeout- Minimum milliseconds to wait after a join attemptwsPingPeriod- WebSocket Ping PeriodconnectionBackoffStrategy- WebSocket Connection Backoff StrategyperChannelRateLimit- Per channel message limitvalidateOnConnect- Whether token should be validated on connectwsCloseDelay- Websocket Close DelayoutboundCommandFilter- Outbound Command Filter
-
-
Methodendetails
-
onConnected
protected void onConnected() -
onTextMessage
-
onDisconnecting
protected void onDisconnecting() -
connect
public void connect()Connecting to IRC-WS -
disconnect
public void disconnect()Disconnecting from IRC-WS -
reconnect
public void reconnect()Reconnecting to IRC-WS -
sendCommand
Send IRC Command- Parameter:
command- IRC Commandargs- command arguments
-
sendRaw
Send raw irc commandNote: perChannelRateLimit does not apply when directly using this method
- Parameter:
command- raw irc command
-
joinChannel
Joining the channel- Angegeben von:
joinChannelin SchnittstelleITwitchChat- Parameter:
channelName- channel name
-
issueJoin
-
leaveChannel
leaving the channel- Angegeben von:
leaveChannelin SchnittstelleITwitchChat- Parameter:
channelName- channel name- Gibt zurück:
- whether the channel was previously joined
-
sendMessage
Beschreibung aus Schnittstelle kopiert:ITwitchChatSends a message to the channel while including the specified message tags.- Angegeben von:
sendMessagein SchnittstelleITwitchChat- Parameter:
channel- the name of the channel to send the message to.message- the message to be sent.tags- the message tags.- Gibt zurück:
- whether the message was added to the queue
-
sendPrivateMessage
Veraltet.Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#sendWhisperSends a user a private message- Parameter:
targetUser- usernamemessage- message
-
close
public void close()Close- Angegeben von:
closein SchnittstelleAutoCloseable- Angegeben von:
closein SchnittstelleITwitchChat
-
isChannelJoined
Beschreibung aus Schnittstelle kopiert:ITwitchChatCheck if Chat is currently in a channel- Angegeben von:
isChannelJoinedin SchnittstelleITwitchChat- Parameter:
channelName- channel to check (without # prefix)- Gibt zurück:
- boolean
-
getCurrentChannels
Veraltet.use getChannels() insteadReturns a set of all currently joined channels (without # prefix)- Gibt zurück:
- a set of channel names
-
getChannels
Beschreibung aus Schnittstelle kopiert:ITwitchChatReturns a set of all currently joined channels (without # prefix)- Angegeben von:
getChannelsin SchnittstelleITwitchChat- Gibt zurück:
- a set of channel names
-
getChannelIdToChannelName
- Angegeben von:
getChannelIdToChannelNamein SchnittstelleITwitchChat- Gibt zurück:
- the cached map used for channel id to name mapping
-
getChannelNameToChannelId
- Angegeben von:
getChannelNameToChannelIdin SchnittstelleITwitchChat- Gibt zurück:
- the cached map used for channel name to id mapping
-
getLatency
public long getLatency()- Angegeben von:
getLatencyin SchnittstelleITwitchChat- Gibt zurück:
- the most recently measured round-trip latency for the socket(s) in milliseconds, or -1 if unknown
-
getState
- Gibt zurück:
- the connection state
-
getConnectionState
Veraltet.usegetState()instead- Gibt zurück:
- the connection state
-
getEventManager
EventManager- Angegeben von:
getEventManagerin SchnittstelleITwitchChat
-
getCredentialManager
CredentialManager
-
getState()instead