Class ConversationContext
java.lang.Object
org.teleight.teleightbots.conversation.ConversationContext
Represents the context of an active conversation between a bot and a user in a specific chat.
This class provides mechanisms to manage the conversation's lifecycle, fetch custom properties, interact with the bot, and capture updates from the user during the conversation.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThis class represents a running conversation associated with aConversationContext. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConversationContext(@NotNull TelegramBot bot, @NotNull Chat chat, @NotNull User user, @NotNull Conversation conversation, @Nullable Map<String, Object> properties) Constructs a new ConversationContext. -
Method Summary
Modifier and TypeMethodDescriptionbot()chat()@Nullable Property<?> getProperty(@NotNull String name) Gets a property by name.Used internally and SHOULD NOT be used elsewhereuser()@Nullable UpdateDeprecated.@Nullable UpdatewaitForUpdate(long timeout, @NotNull TimeUnit unit) Waits for an update with a specified timeout.
-
Constructor Details
-
ConversationContext
@Internal protected ConversationContext(@NotNull @NotNull TelegramBot bot, @NotNull @NotNull Chat chat, @NotNull @NotNull User user, @NotNull @NotNull Conversation conversation, @Nullable @Nullable Map<String, Object> properties) Constructs a new ConversationContext. Used internally and SHOULD NOT be used elsewhere- Parameters:
bot- The bot associated with this conversation.chat- The chat associated with this conversation.user- The user involved in the conversation.conversation- The conversation to be executed.
-
-
Method Details
-
getProperty
Gets a property by name.- Parameters:
name- The name of the property.- Returns:
- The property, or null if the property does not exist.
-
getProperties
- Returns:
- A map of all properties applied to the conversation.
-
bot
- Returns:
- The bot associated with this ConversationContext.
-
chat
- Returns:
- The chat associated with this ConversationContext.
-
user
- Returns:
- The user associated with this ConversationContext.
-
conversation
- Returns:
- The conversation associated with this ConversationContext.
-
runningConversation
Used internally and SHOULD NOT be used elsewhere- Returns:
- The running conversation thread associated with this ConversationContext.
-
waitForUpdate
Deprecated.Waits for an update with no timeout. This is not recommended in most cases- Returns:
- The update, or null if no update is received.
-
waitForUpdate
Waits for an update with a specified timeout.- Parameters:
timeout- The timeout in the specified time unit.unit- The time unit of the timeout.- Returns:
- The update, or null if no update is received within the timeout.
-
waitForUpdate(long, TimeUnit)