org.telegram.telegrambots.meta.api.objects.replykeyboard.ForceReplyKeyboard Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of telegrambots-meta Show documentation
Show all versions of telegrambots-meta Show documentation
Easy to use library to create Telegram Bots
package org.telegram.telegrambots.meta.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Upon receiving a message with this object, Telegram clients will display a reply interface
* to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be
* extremely useful if you want to create user-friendly step-by-step interfaces without having to
* sacrifice privacy mode.
* @date 22 of June of 2015
*/
public class ForceReplyKeyboard implements ReplyKeyboard {
private static final String FORCEREPLY_FIELD = "force_reply";
private static final String SELECTIVE_FIELD = "selective";
/**
* Shows reply interface to the user, as if they manually selected the bot‘s message and tapped
* ’Reply'
*/
@JsonProperty(FORCEREPLY_FIELD)
private Boolean forceReply;
/**
* Use this parameter if you want to force reply from specific users only. Targets: 1) users
* that are @mentioned in the text of the Message object; 2) if the bot's message is a reply
* (has reply_to_message_id), sender of the original message.
*/
@JsonProperty(SELECTIVE_FIELD)
private Boolean selective;
public ForceReplyKeyboard() {
super();
this.forceReply = true;
}
public Boolean getForceReply() {
return forceReply;
}
public Boolean getSelective() {
return selective;
}
public ForceReplyKeyboard setSelective(Boolean selective) {
this.selective = selective;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (forceReply == null) {
throw new TelegramApiValidationException("ForceReply parameter can't not be null", this);
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ForceReplyKeyboard)) {
return false;
}
ForceReplyKeyboard forceReplyKeyboard = (ForceReplyKeyboard) o;
return Objects.equals(forceReply, forceReplyKeyboard.forceReply)
&& Objects.equals(selective, forceReplyKeyboard.selective)
;
}
@Override
public int hashCode() {
return Objects.hash(
forceReply,
selective);
}
@Override
public String toString() {
return "ForceReplyKeyboard{" +
"forceReply=" + forceReply +
", selective=" + selective +
'}';
}
}