All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pro.zackpollard.telegrambot.api.conversations.ConversationPrompt Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version
package pro.zackpollard.telegrambot.api.conversations;

import pro.zackpollard.telegrambot.api.chat.message.content.Content;
import pro.zackpollard.telegrambot.api.chat.message.content.ContentType;
import pro.zackpollard.telegrambot.api.chat.message.send.SendableMessage;

/**
 * An element to a conversation, accepts a specific content type.
 * @param  Accepting content type
 * @author Mazen Kotb
 */
public interface ConversationPrompt {
    /**
     * The content type representation of type T.
     * @return Content type
     */
    ContentType type();

    /**
     * Processes input from user
     * @param context The context of the conversation
     * @param input Input message from user
     * @return Whether to repeat the prompt or not
     */
    boolean process(ConversationContext context, T input);

    /**
     * The message sent before accepting input. Not called if conversation is silent.
     * @param context Context of the conversation
     * @return Message sent before accepting input
     */
    SendableMessage promptMessage(ConversationContext context);

    /**
     * Called when the conversation has ended, either naturally or forcibly using the end method.
     * @param context The context of the conversation
     * @see Conversation#end()
     */
    default void conversationEnded(ConversationContext context) {
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy