Package io.manebot.chat
Class DefaultChatSender
- java.lang.Object
-
- io.manebot.chat.DefaultChatSender
-
- All Implemented Interfaces:
ChatMessageReceiver
,ChatSender
- Direct Known Subclasses:
CommandSender
public class DefaultChatSender extends java.lang.Object implements ChatSender
-
-
Constructor Summary
Constructors Constructor Description DefaultChatSender(PlatformUser user, Chat chat)
-
Method Summary
Modifier and Type Method Description boolean
begin()
Opens the command buffer.boolean
canSendEmbeds()
Finds if this receiver can send receive embedded messages in this conversation.java.util.Collection<ChatMessage>
end()
Ends the command buffer.java.util.Collection<ChatMessage>
flush()
Flushes the buffer.Chat
getChat()
Gets the chat the message was sent in.PlatformUser
getPlatformUser()
Gets the platform user that is associated with this chat sender.java.util.Collection<ChatMessage>
sendDetails(java.util.function.Consumer<CommandDetailsResponse.Builder> consumer)
Creates a details response to get to the command sender, opportunistically formatting as rich content.java.util.Collection<ChatMessage>
sendFormattedMessage(java.util.function.Consumer<TextBuilder> function)
Sends a formatted message to the receiver.<T> java.util.Collection<ChatMessage>
sendList(java.lang.Class<T> type, java.util.function.Consumer<CommandListResponse.Builder<T>> function)
Creates a list response to get to the command sender, opportunistically formatting as rich content.java.util.Collection<ChatMessage>
sendMessage(java.lang.String message)
Sends an unformatted message to the receiver.java.util.Collection<ChatMessage>
sendMessages(java.lang.String... messages)
Sends several messages to the receiver.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.manebot.chat.ChatMessageReceiver
sendFormattedMessages, sendMessages, sendRawMessage, sendRawMessages
-
Methods inherited from interface io.manebot.chat.ChatSender
getDisplayName, getUsername, sendList, sendMessage
-
-
-
-
Constructor Detail
-
DefaultChatSender
public DefaultChatSender(PlatformUser user, Chat chat)
-
-
Method Detail
-
getPlatformUser
public PlatformUser getPlatformUser()
Description copied from interface:ChatSender
Gets the platform user that is associated with this chat sender.- Specified by:
getPlatformUser
in interfaceChatSender
- Returns:
- PlatformUser instance.
-
getChat
public Chat getChat()
Description copied from interface:ChatSender
Gets the chat the message was sent in.- Specified by:
getChat
in interfaceChatSender
- Returns:
- Chat instance.
-
sendList
public <T> java.util.Collection<ChatMessage> sendList(java.lang.Class<T> type, java.util.function.Consumer<CommandListResponse.Builder<T>> function) throws CommandExecutionException
Description copied from interface:ChatSender
Creates a list response to get to the command sender, opportunistically formatting as rich content.- Specified by:
sendList
in interfaceChatSender
- Type Parameters:
T
- List item type.function
- Function providing a command response object from a builder.- Returns:
- CommandResponse object corresponding to the desired message; contains get() method to dispatch.
- Throws:
CommandExecutionException
-
sendDetails
public java.util.Collection<ChatMessage> sendDetails(java.util.function.Consumer<CommandDetailsResponse.Builder> consumer) throws CommandExecutionException
Description copied from interface:ChatSender
Creates a details response to get to the command sender, opportunistically formatting as rich content. Details are formatted as such: ObjectName "ObjectKey" details: Key: value Key: [value1,value2,value3]- Specified by:
sendDetails
in interfaceChatSender
- Parameters:
consumer
- Function providing a command response object from a builder.- Returns:
- CommandResponse object corresponding to the desired message; contains get() method to dispatch.
- Throws:
CommandExecutionException
-
begin
public boolean begin()
Opens the command buffer.- Specified by:
begin
in interfaceChatSender
- Returns:
- true if the buffer was opened, false if no changes were made.
-
sendMessage
public java.util.Collection<ChatMessage> sendMessage(java.lang.String message)
Description copied from interface:ChatMessageReceiver
Sends an unformatted message to the receiver.- Specified by:
sendMessage
in interfaceChatMessageReceiver
- Parameters:
message
- message to add.
-
sendFormattedMessage
public java.util.Collection<ChatMessage> sendFormattedMessage(java.util.function.Consumer<TextBuilder> function)
Description copied from interface:ChatMessageReceiver
Sends a formatted message to the receiver.- Specified by:
sendFormattedMessage
in interfaceChatMessageReceiver
- Parameters:
function
- function to provide a formatted message.
-
sendMessages
public java.util.Collection<ChatMessage> sendMessages(java.lang.String... messages)
Description copied from interface:ChatMessageReceiver
Sends several messages to the receiver.- Specified by:
sendMessages
in interfaceChatMessageReceiver
- Parameters:
messages
- messages to send.
-
canSendEmbeds
public boolean canSendEmbeds()
Description copied from interface:ChatMessageReceiver
Finds if this receiver can send receive embedded messages in this conversation.- Specified by:
canSendEmbeds
in interfaceChatMessageReceiver
- Returns:
- true if the bot can send embedded messages to this receiver, false otherwise.
-
end
public java.util.Collection<ChatMessage> end()
Ends the command buffer.- Specified by:
end
in interfaceChatSender
- Returns:
- number of flushes accomplished.
-
flush
public java.util.Collection<ChatMessage> flush()
Flushes the buffer.- Specified by:
flush
in interfaceChatSender
- Returns:
- ChatMessage generated.
-
-