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 booleanbegin()Opens the command buffer.booleancanSendEmbeds()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.ChatgetChat()Gets the chat the message was sent in.PlatformUsergetPlatformUser()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:ChatSenderGets the platform user that is associated with this chat sender.- Specified by:
getPlatformUserin interfaceChatSender- Returns:
- PlatformUser instance.
-
getChat
public Chat getChat()
Description copied from interface:ChatSenderGets the chat the message was sent in.- Specified by:
getChatin 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:ChatSenderCreates a list response to get to the command sender, opportunistically formatting as rich content.- Specified by:
sendListin 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:ChatSenderCreates 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:
sendDetailsin 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:
beginin 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:ChatMessageReceiverSends an unformatted message to the receiver.- Specified by:
sendMessagein interfaceChatMessageReceiver- Parameters:
message- message to add.
-
sendFormattedMessage
public java.util.Collection<ChatMessage> sendFormattedMessage(java.util.function.Consumer<TextBuilder> function)
Description copied from interface:ChatMessageReceiverSends a formatted message to the receiver.- Specified by:
sendFormattedMessagein interfaceChatMessageReceiver- Parameters:
function- function to provide a formatted message.
-
sendMessages
public java.util.Collection<ChatMessage> sendMessages(java.lang.String... messages)
Description copied from interface:ChatMessageReceiverSends several messages to the receiver.- Specified by:
sendMessagesin interfaceChatMessageReceiver- Parameters:
messages- messages to send.
-
canSendEmbeds
public boolean canSendEmbeds()
Description copied from interface:ChatMessageReceiverFinds if this receiver can send receive embedded messages in this conversation.- Specified by:
canSendEmbedsin 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:
endin interfaceChatSender- Returns:
- number of flushes accomplished.
-
flush
public java.util.Collection<ChatMessage> flush()
Flushes the buffer.- Specified by:
flushin interfaceChatSender- Returns:
- ChatMessage generated.
-
-