Merge branch 'TerminusMKB-master' into dev
This commit is contained in:
commit
c1a0b25c9c
@ -1,5 +1,6 @@
|
|||||||
package org.telegram.telegrambots.api.methods;
|
package org.telegram.telegrambots.api.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||||
@ -24,8 +25,11 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
|||||||
private static final String TEXT_FIELD = "text";
|
private static final String TEXT_FIELD = "text";
|
||||||
private static final String SHOWALERT_FIELD = "show_alert";
|
private static final String SHOWALERT_FIELD = "show_alert";
|
||||||
|
|
||||||
|
@JsonProperty(CALLBACKQUERYID_FIELD)
|
||||||
private String callbackQueryId; ///< Unique identifier for the query to be answered
|
private String callbackQueryId; ///< Unique identifier for the query to be answered
|
||||||
|
@JsonProperty(TEXT_FIELD)
|
||||||
private String text; ///< Text of the notification. If not specified, nothing will be shown to the user
|
private String text; ///< Text of the notification. If not specified, nothing will be shown to the user
|
||||||
|
@JsonProperty(SHOWALERT_FIELD)
|
||||||
private Boolean showAlert; ///< Optional. If true, an alert will be shown by the client instead of a notificaiton at the top of the chat screen. Defaults to false.
|
private Boolean showAlert; ///< Optional. If true, an alert will be shown by the client instead of a notificaiton at the top of the chat screen. Defaults to false.
|
||||||
|
|
||||||
|
|
||||||
@ -33,6 +37,30 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCallbackQueryId() {
|
||||||
|
return this.callbackQueryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallbackQueryId(String callbackQueryId) {
|
||||||
|
this.callbackQueryId = callbackQueryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return this.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getShowAlert() {
|
||||||
|
return this.showAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowAlert(Boolean showAlert) {
|
||||||
|
this.showAlert = showAlert;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject toJson() {
|
public JSONObject toJson() {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
@ -51,6 +51,22 @@ public class CallbackQuery implements IBotApiObject {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getFrom() {
|
||||||
|
return this.from;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Message getMessage() {
|
||||||
|
return this.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInlineMessageId() {
|
||||||
|
return this.inlineMessageId;
|
||||||
|
}
|
||||||
|
|
||||||
public CallbackQuery(JSONObject jsonObject) {
|
public CallbackQuery(JSONObject jsonObject) {
|
||||||
super();
|
super();
|
||||||
this.id = jsonObject.getString(ID_FIELD);
|
this.id = jsonObject.getString(ID_FIELD);
|
||||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
|||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -23,107 +24,42 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class InlineKeyboardMarkup implements ReplyKeyboard {
|
public class InlineKeyboardMarkup implements ReplyKeyboard {
|
||||||
|
|
||||||
private static final String KEYBOARD_FIELD = "keyboard";
|
private static final String KEYBOARD_FIELD = "inline_keyboard";
|
||||||
private static final String RESIZEKEYBOARD_FIELD = "resize_keyboard";
|
|
||||||
private static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard";
|
|
||||||
private static final String SELECTIVE_FIELD = "selective";
|
|
||||||
@JsonProperty(KEYBOARD_FIELD)
|
@JsonProperty(KEYBOARD_FIELD)
|
||||||
private List<List<String>> keyboard; ///< Array of button rows, each represented by an Array of Strings
|
private List<List<InlineKeyboardButton>> keyboard; ///< Array of button rows, each represented by an Array of Strings
|
||||||
@JsonProperty(RESIZEKEYBOARD_FIELD)
|
|
||||||
private Boolean resizeKeyboard; ///< Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false.
|
|
||||||
@JsonProperty(ONETIMEKEYBOARD_FIELD)
|
|
||||||
private Boolean oneTimeKeyboad; ///< Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
|
|
||||||
/**
|
|
||||||
* Optional. Use this parameter if you want to show the keyboard to 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.
|
|
||||||
*/
|
|
||||||
private Boolean selective;
|
|
||||||
|
|
||||||
public InlineKeyboardMarkup() {
|
public InlineKeyboardMarkup() {
|
||||||
super();
|
super();
|
||||||
keyboard = new ArrayList<List<String>>();
|
keyboard = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InlineKeyboardMarkup(JSONObject jsonObject) {
|
public InlineKeyboardMarkup(JSONObject jsonObject) {
|
||||||
super();
|
super();
|
||||||
this.keyboard = new ArrayList<List<String>>();
|
this.keyboard = new ArrayList<>();
|
||||||
JSONArray keyboard = jsonObject.getJSONArray(KEYBOARD_FIELD);
|
|
||||||
for (int i = 0; i < keyboard.length(); i++) {
|
|
||||||
JSONArray keyboardRow = keyboard.getJSONArray(i);
|
|
||||||
List<String> row = new ArrayList<String>();
|
|
||||||
for (int j = 0; j < keyboardRow.length(); j++) {
|
|
||||||
row.add(keyboardRow.getString(j));
|
|
||||||
}
|
|
||||||
this.keyboard.add(row);
|
|
||||||
}
|
|
||||||
if (jsonObject.has(RESIZEKEYBOARD_FIELD)) {
|
|
||||||
this.resizeKeyboard = jsonObject.getBoolean(RESIZEKEYBOARD_FIELD);
|
|
||||||
}
|
|
||||||
if (jsonObject.has(ONETIMEKEYBOARD_FIELD)) {
|
|
||||||
this.oneTimeKeyboad = jsonObject.getBoolean(ONETIMEKEYBOARD_FIELD);
|
|
||||||
}
|
|
||||||
if (jsonObject.has(SELECTIVE_FIELD)) {
|
|
||||||
this.selective = jsonObject.getBoolean(SELECTIVE_FIELD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<List<String>> getKeyboard() {
|
public List<List<InlineKeyboardButton>> getKeyboard() {
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboard(List<List<String>> keyboard) {
|
public void setKeyboard(List<List<InlineKeyboardButton>> keyboard) {
|
||||||
this.keyboard = keyboard;
|
this.keyboard = keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getResizeKeyboard() {
|
|
||||||
return resizeKeyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResizeKeyboard(Boolean resizeKeyboard) {
|
|
||||||
this.resizeKeyboard = resizeKeyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getOneTimeKeyboad() {
|
|
||||||
return oneTimeKeyboad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOneTimeKeyboad(Boolean oneTimeKeyboad) {
|
|
||||||
this.oneTimeKeyboad = oneTimeKeyboad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getSelective() {
|
|
||||||
return selective;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelective(Boolean selective) {
|
|
||||||
this.selective = selective;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject toJson() {
|
public JSONObject toJson() {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
JSONArray jsonkeyboard = new JSONArray();
|
JSONArray jsonkeyboard = new JSONArray();
|
||||||
|
|
||||||
for (List<String> innerRow : this.keyboard) {
|
for (List<InlineKeyboardButton> innerRow : this.keyboard) {
|
||||||
JSONArray innerJSONKeyboard = new JSONArray();
|
JSONArray innerJSONKeyboard = new JSONArray();
|
||||||
for (String element : innerRow) {
|
for (InlineKeyboardButton element : innerRow) {
|
||||||
innerJSONKeyboard.put(element);
|
innerJSONKeyboard.put(element.toJson());
|
||||||
}
|
}
|
||||||
jsonkeyboard.put(innerJSONKeyboard);
|
jsonkeyboard.put(innerJSONKeyboard);
|
||||||
}
|
}
|
||||||
jsonObject.put(InlineKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
|
jsonObject.put(InlineKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
|
||||||
|
|
||||||
if (this.oneTimeKeyboad != null) {
|
|
||||||
jsonObject.put(InlineKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
|
|
||||||
}
|
|
||||||
if (this.resizeKeyboard != null) {
|
|
||||||
jsonObject.put(InlineKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
|
|
||||||
}
|
|
||||||
if (this.selective != null) {
|
|
||||||
jsonObject.put(InlineKeyboardMarkup.SELECTIVE_FIELD, this.selective);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,23 +67,14 @@ public class InlineKeyboardMarkup implements ReplyKeyboard {
|
|||||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
gen.writeStartObject();
|
gen.writeStartObject();
|
||||||
gen.writeArrayFieldStart(KEYBOARD_FIELD);
|
gen.writeArrayFieldStart(KEYBOARD_FIELD);
|
||||||
for (List<String> innerRow : keyboard) {
|
for (List<InlineKeyboardButton> innerRow : keyboard) {
|
||||||
gen.writeStartArray();
|
gen.writeStartArray();
|
||||||
for (String element : innerRow) {
|
for (InlineKeyboardButton element : innerRow) {
|
||||||
gen.writeString(element);
|
gen.writeObject(element);
|
||||||
}
|
}
|
||||||
gen.writeEndArray();
|
gen.writeEndArray();
|
||||||
}
|
}
|
||||||
gen.writeEndArray();
|
gen.writeEndArray();
|
||||||
if (this.oneTimeKeyboad != null) {
|
|
||||||
gen.writeBooleanField(ONETIMEKEYBOARD_FIELD, oneTimeKeyboad);
|
|
||||||
}
|
|
||||||
if (this.resizeKeyboard != null) {
|
|
||||||
gen.writeBooleanField(RESIZEKEYBOARD_FIELD, resizeKeyboard);
|
|
||||||
}
|
|
||||||
if (this.selective != null) {
|
|
||||||
gen.writeBooleanField(SELECTIVE_FIELD, selective);
|
|
||||||
}
|
|
||||||
gen.writeEndObject();
|
gen.writeEndObject();
|
||||||
gen.flush();
|
gen.flush();
|
||||||
}
|
}
|
||||||
@ -159,11 +86,8 @@ public class InlineKeyboardMarkup implements ReplyKeyboard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ReplyKeyboardMarkup{" +
|
return "InlineKeyboardMarkup{" +
|
||||||
"keyboard=" + keyboard +
|
"inline_keyboard=" + keyboard +
|
||||||
", resizeKeyboard=" + resizeKeyboard +
|
|
||||||
", oneTimeKeyboad=" + oneTimeKeyboad +
|
|
||||||
", selective=" + selective +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user