Package rs.kreme.ksbot.api.queries
Class ChatQuery
- java.lang.Object
-
- rs.kreme.ksbot.api.queries.Query<KSChatMessage,ChatQuery>
-
- rs.kreme.ksbot.api.queries.ChatQuery
-
public class ChatQuery extends Query<KSChatMessage,ChatQuery>
ChatQuery is a chainable query builder for filtering and processing collections ofKSChatMessages
using various criteria such as message content, type, sender, timestamps, and more. It safely caches the original data internally and applies dynamic filters on-demand using a compositePredicate
.
-
-
Constructor Summary
Constructors Constructor Description ChatQuery(java.util.Collection<KSChatMessage> messages)
Constructs a new ChatQuery from a collection of chat messages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChatQuery
betweenTimestamps(long startTimestamp, long endTimestamp)
Filters messages between two timestamps (inclusive lower bound, exclusive upper).ChatQuery
contains(java.lang.String string)
Filters messages that contain a specified string in their message content.ChatQuery
messagesAgo(long duration, java.util.concurrent.TimeUnit timeUnit)
Filters messages sent within the given time duration from now.ChatQuery
withoutType(KSChatMessage.MessageTypes type)
Excludes messages of a specific chat type.ChatQuery
withType(KSChatMessage.MessageTypes type)
Filters messages of a specific chat type.-
Methods inherited from class rs.kreme.ksbot.api.queries.Query
count, empty, exists, filter, first, first, last, list, list, max, min, omit, omit, omit, random, reverse, shuffledList, shuffledList, sorted, stream, unique, withId, withName, withNameOrId, withOption, withoutId, withoutName, withoutNameOrId, withoutOption
-
-
-
-
Constructor Detail
-
ChatQuery
public ChatQuery(java.util.Collection<KSChatMessage> messages)
Constructs a new ChatQuery from a collection of chat messages.- Parameters:
chats
- The collection of chat messages to initialize the query with.
-
-
Method Detail
-
contains
public ChatQuery contains(java.lang.String string)
Filters messages that contain a specified string in their message content.- Parameters:
string
- The substring or wildcard pattern to match.- Returns:
- The updated ChatQuery instance.
-
withType
public ChatQuery withType(KSChatMessage.MessageTypes type)
Filters messages of a specific chat type.- Parameters:
type
- The desired MessageTypes enum.- Returns:
- The updated ChatQuery instance.
-
withoutType
public ChatQuery withoutType(KSChatMessage.MessageTypes type)
Excludes messages of a specific chat type.- Parameters:
type
- The MessageTypes to exclude.- Returns:
- The updated ChatQuery instance.
-
betweenTimestamps
public ChatQuery betweenTimestamps(long startTimestamp, long endTimestamp)
Filters messages between two timestamps (inclusive lower bound, exclusive upper).- Parameters:
startTimestamp
- The start timestamp (inclusive).endTimestamp
- The end timestamp (exclusive).- Returns:
- The updated ChatQuery instance.
-
messagesAgo
public ChatQuery messagesAgo(long duration, java.util.concurrent.TimeUnit timeUnit)
Filters messages sent within the given time duration from now.- Parameters:
duration
- The duration to look back.timeUnit
- The unit of time (e.g., SECONDS, MINUTES).- Returns:
- The updated ChatQuery instance.
-
-