Package com.github.twitch4j.chat
Interface ITwitchChat
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
TwitchChat,TwitchChatConnectionPool
public interface ITwitchChat
extends java.lang.AutoCloseable
-
Method Summary
Modifier and Type Method Description default booleanban(java.lang.String channel, java.lang.String user, java.lang.String reason)Ban a userdefault booleanclearChat(java.lang.String channel)Clears the history for first-party chat clients.voidclose()default booleandelete(java.lang.String channel, java.lang.String targetMsgId)Deletes a message.java.util.Map<java.lang.String,java.lang.String>getChannelIdToChannelName()java.util.Map<java.lang.String,java.lang.String>getChannelNameToChannelId()java.util.Set<java.lang.String>getChannels()Returns a set of all currently joined channels (without # prefix)com.github.philippheuer.events4j.core.EventManagergetEventManager()default booleanisChannelJoined(java.lang.String channelName)Check if Chat is currently in a channelvoidjoinChannel(java.lang.String channelName)Joins a channelbooleanleaveChannel(java.lang.String channelName)Parts from a channeldefault booleansendActionMessage(java.lang.String channel, java.lang.String message)Sends an action message (/me) in a joined channel.default booleansendMessage(java.lang.String channel, java.lang.String message)Sends a message in a joined channel.booleansendMessage(java.lang.String channel, java.lang.String message, @Nullable java.util.Map<java.lang.String,java.lang.Object> tags)Sends a message to the channel while including the specified message tags.default booleansendMessage(java.lang.String channel, java.lang.String message, java.lang.String nonce, java.lang.String replyMsgId)Sends a message to the channel while including an optional nonce and/or reply parent.default booleansetEmoteOnly(java.lang.String channel, boolean enable)Configures emote only mode in a channel.default booleansetFollowersOnly(java.lang.String channel, java.time.Duration time)Configures followers only mode in a channel.default booleansetSlowMode(java.lang.String channel, int seconds)Configures the slow mode setting for a channel.default booleansetSubscribersOnly(java.lang.String channel, boolean enable)Configures subscribers only mode in a channel.default booleansetUniqueChat(java.lang.String channel, boolean enable)Configures unique chat mode (r9k) in a channel.default booleantimeout(java.lang.String channel, java.lang.String user, java.time.Duration duration, java.lang.String reason)Timeout a userdefault booleanunban(java.lang.String channel, java.lang.String user)Unban a user
-
Method Details
-
getEventManager
com.github.philippheuer.events4j.core.EventManager getEventManager() -
joinChannel
void joinChannel(java.lang.String channelName)Joins a channel- Parameters:
channelName- The target channel name.
-
leaveChannel
boolean leaveChannel(java.lang.String channelName)Parts from a channel- Parameters:
channelName- The target channel name.- Returns:
- whether the channel was previously joined
-
sendMessage
default boolean sendMessage(java.lang.String channel, java.lang.String message)Sends a message in a joined channel.- Parameters:
channel- The target channel name.message- The message to be sent.- Returns:
- whether the message was added to the queue
-
sendMessage
@Unofficial default boolean sendMessage(java.lang.String channel, java.lang.String message, java.lang.String nonce, java.lang.String replyMsgId)Sends a message to the channel while including an optional nonce and/or reply parent.- Parameters:
channel- the name of the channel to send the message to.message- the message to be sent.nonce- the cryptographic nonce (optional).replyMsgId- the msgId of the parent message being replied to (optional).- Returns:
- whether the message was added to the queue
-
sendMessage
@Unofficial boolean sendMessage(java.lang.String channel, java.lang.String message, @Unofficial @Nullable @Nullable java.util.Map<java.lang.String,java.lang.Object> tags)Sends a message to the channel while including the specified message tags.- Parameters:
channel- the name of the channel to send the message to.message- the message to be sent.tags- the message tags (unofficial).- Returns:
- whether the message was added to the queue
-
getChannels
java.util.Set<java.lang.String> getChannels()Returns a set of all currently joined channels (without # prefix)- Returns:
- a set of channel names
-
close
void close()- Specified by:
closein interfacejava.lang.AutoCloseable
-
getChannelIdToChannelName
java.util.Map<java.lang.String,java.lang.String> getChannelIdToChannelName()- Returns:
- cached mappings of channel ids to names
-
getChannelNameToChannelId
java.util.Map<java.lang.String,java.lang.String> getChannelNameToChannelId()- Returns:
- cached mappings of channel names to ids
-
isChannelJoined
default boolean isChannelJoined(java.lang.String channelName)Check if Chat is currently in a channel- Parameters:
channelName- channel to check (without # prefix)- Returns:
- boolean
-
sendActionMessage
default boolean sendActionMessage(java.lang.String channel, java.lang.String message)Sends an action message (/me) in a joined channel.- Parameters:
channel- The target channel name.message- The message to be sent.- Returns:
- whether the message was added to the queue
-
setSlowMode
default boolean setSlowMode(java.lang.String channel, int seconds)Configures the slow mode setting for a channel.Non-positive values would disable slow mode. Positive values must not be greater than 1800.
- Parameters:
channel- The target channel name.seconds- The slow mode seconds.- Returns:
- whether the command was added to the queue
-
setFollowersOnly
default boolean setFollowersOnly(java.lang.String channel, java.time.Duration time)Configures followers only mode in a channel.Passing null (or a negative duration) for time disables followers only. The amount of time must not exceed 3 months.
- Parameters:
channel- The target channel name.time- The amount of time users must be followed.- Returns:
- whether the command was added to the queue
-
setSubscribersOnly
default boolean setSubscribersOnly(java.lang.String channel, boolean enable)Configures subscribers only mode in a channel.- Parameters:
channel- The target channel name.enable- Whether the setting should be enabled or disabled.- Returns:
- whether the command was added to the queue
-
setUniqueChat
default boolean setUniqueChat(java.lang.String channel, boolean enable)Configures unique chat mode (r9k) in a channel.- Parameters:
channel- The target channel name.enable- Whether the setting should be enabled or disabled.- Returns:
- whether the command was added to the queue
-
setEmoteOnly
default boolean setEmoteOnly(java.lang.String channel, boolean enable)Configures emote only mode in a channel.- Parameters:
channel- The target channel name.enable- Whether the setting should be enabled or disabled.- Returns:
- whether the command was added to the queue
-
clearChat
default boolean clearChat(java.lang.String channel)Clears the history for first-party chat clients.- Parameters:
channel- The target channel name.- Returns:
- whether the command was added to the queue
-
delete
default boolean delete(java.lang.String channel, java.lang.String targetMsgId)Deletes a message.- Parameters:
channel- the name of the channel to delete the message from.targetMsgId- the unique id of the message to be deleted.- Returns:
- whether the command was added to the queue
- See Also:
IRCMessageEvent.getMessageId()
-
timeout
default boolean timeout(java.lang.String channel, java.lang.String user, java.time.Duration duration, java.lang.String reason)Timeout a user- Parameters:
channel- channeluser- usernameduration- durationreason- reason- Returns:
- whether the command was added to the queue
-
ban
default boolean ban(java.lang.String channel, java.lang.String user, java.lang.String reason)Ban a user- Parameters:
channel- channeluser- usernamereason- reason- Returns:
- whether the command was added to the queue
-
unban
default boolean unban(java.lang.String channel, java.lang.String user)Unban a user- Parameters:
channel- channeluser- username- Returns:
- whether the command was added to the queue
-