Class ChatExtensionsKt
-
- All Implemented Interfaces:
public final class ChatExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends AbstractChannelEvent> Flow<T>channelEventsAsFlow(ITwitchChat $self, String channel, Boolean autoJoinAndLeave)Creates an events flow for the given channel. final static <T extends AbstractChannelEvent> Flow<T>channelEventsAsFlow(ITwitchChat $self, Class<T> klass, String channel, Boolean autoJoinAndLeave)Creates an events flow for the given channel. final static Flow<AbstractChannelMessageEvent>channelChatAsFlow(ITwitchChat $self, String channel, Boolean autoJoinAndLeave)Creates a flow for both normal as action messages for the given channel. -
-
Method Detail
-
channelEventsAsFlow
final static <T extends AbstractChannelEvent> Flow<T> channelEventsAsFlow(ITwitchChat $self, String channel, Boolean autoJoinAndLeave)
Creates an events flow for the given channel.
This function creates a flow for the given T events in the given channel. It is wrapped in a joinChannel and leaveChannel for convenience, which can be turned off.
Note: The autoJoinAndLeave feature will automatically leave the twitch channel when you remove the collector from this flow. If this is a problem for you (e.g. you need to stay joined in the channel after removing a collector) you are better off setting autoJoinAndLeave to false, and join/leave the channel on your own.
Example usage:
twitchChat.channelEventsAsFlow<ChannelJoinEvent>("twitch4j") .collect { println("[${it.channel.name}] ${it.user.name} just joined the channel!") }- Parameters:
channel- The channel to retrieve events fromautoJoinAndLeave- Whether we automatically join and leave the channel or not- Returns:
A flow object that encapsulates handling joining, listening to, and leaving a channel
-
channelEventsAsFlow
final static <T extends AbstractChannelEvent> Flow<T> channelEventsAsFlow(ITwitchChat $self, Class<T> klass, String channel, Boolean autoJoinAndLeave)
Creates an events flow for the given channel.
This function creates a flow for the given T events in the given channel. It is wrapped in a joinChannel and leaveChannel for convenience, which can be turned off.
Note: The autoJoinAndLeave feature will automatically leave the twitch channel when you remove the collector from this flow. If this is a problem for you (e.g. you need to stay joined in the channel after removing a collector) you are better off setting autoJoinAndLeave to false, and join/leave the channel on your own.
Example usage:
twitchChat.channelEventsAsFlow(JoinEvent::class.java, "twitch4j", true) .collect { println("[${it.channel.name}] ${it.user.name} joined the channel") }- Parameters:
klass- The event class to receivechannel- The channel to retrieve events fromautoJoinAndLeave- Whether we automatically join and leave the channel or not- Returns:
A flow object that encapsulates handling joining, listening to, and leaving a channel
-
channelChatAsFlow
final static Flow<AbstractChannelMessageEvent> channelChatAsFlow(ITwitchChat $self, String channel, Boolean autoJoinAndLeave)
Creates a flow for both normal as action messages for the given channel.
This function creates a flow for channel messages and channel actions (/me text). It is wrapped in a joinChannel and leaveChannel for convenience, which can be turned off.
Note: The autoJoinAndLeave feature will automatically leave the twitch channel when you remove the collector from this flow. If this is a problem for you (e.g. you need to stay joined in the channel after removing a collector) you are better off setting autoJoinAndLeave to false, and join/leave the channel on your own.
Example usage:
twitchChat.channelChatAsFlow("twitch4j") .collect { println("[${it.channel.name}] ${it.user.name} said: ${it.message}") }- Parameters:
channel- The channel to read chat messages fromautoJoinAndLeave- Whether we automatically join and leave the channel or not- Returns:
A flow object that encapsulates joining, listening to messages, and leaving a channel
-
-
-
-