diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 434b83aa..799ac8ea 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -24,9 +24,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 38c7409a..d1c52f5b 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -35,7 +35,7 @@
-
+
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_core_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19_1.xml
similarity index 61%
rename from .idea/libraries/Maven__com_sun_jersey_jersey_core_1_19.xml
rename to .idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19_1.xml
index 3ac29b22..4d626a66 100644
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_core_1_19.xml
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19_1.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_core_1_19_1.xml
similarity index 62%
rename from .idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19.xml
rename to .idea/libraries/Maven__com_sun_jersey_jersey_core_1_19_1.xml
index 015dbda0..91d65b20 100644
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_bundle_1_19.xml
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_core_1_19_1.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19_1.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19_1.xml
new file mode 100644
index 00000000..ec38da5b
--- /dev/null
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19_1.xml
similarity index 64%
rename from .idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19.xml
rename to .idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19_1.xml
index 2f3fb720..e61c7cb4 100644
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19.xml
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_servlet_1_19_1.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_server_1_19_1.xml
similarity index 61%
rename from .idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19.xml
rename to .idea/libraries/Maven__com_sun_jersey_jersey_server_1_19_1.xml
index 8734ae45..b4ad3ded 100644
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_grizzly2_1_19.xml
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_server_1_19_1.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19.xml
deleted file mode 100644
index 882f8424..00000000
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_sun_jersey_jersey_server_1_19.xml b/.idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19_1.xml
similarity index 60%
rename from .idea/libraries/Maven__com_sun_jersey_jersey_server_1_19.xml
rename to .idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19_1.xml
index 47f74e7c..943df5a5 100644
--- a/.idea/libraries/Maven__com_sun_jersey_jersey_server_1_19.xml
+++ b/.idea/libraries/Maven__com_sun_jersey_jersey_servlet_1_19_1.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b31.xml b/.idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b34.xml
similarity index 58%
rename from .idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b31.xml
rename to .idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b34.xml
index 874c8904..1908e81f 100644
--- a/.idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b31.xml
+++ b/.idea/libraries/Maven__org_glassfish_hk2_external_aopalliance_repackaged_2_4_0_b34.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b31.xml b/.idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b34.xml
similarity index 67%
rename from .idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b31.xml
rename to .idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b34.xml
index 87ed3347..8ef6daa2 100644
--- a/.idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b31.xml
+++ b/.idea/libraries/Maven__org_glassfish_hk2_external_javax_inject_2_4_0_b34.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b31.xml b/.idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b34.xml
similarity index 62%
rename from .idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b31.xml
rename to .idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b34.xml
index 14746f4c..97dd43ff 100644
--- a/.idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b31.xml
+++ b/.idea/libraries/Maven__org_glassfish_hk2_hk2_api_2_4_0_b34.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b31.xml b/.idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b34.xml
similarity index 59%
rename from .idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b31.xml
rename to .idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b34.xml
index e57e76f7..e15594eb 100644
--- a/.idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b31.xml
+++ b/.idea/libraries/Maven__org_glassfish_hk2_hk2_locator_2_4_0_b34.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b31.xml b/.idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b34.xml
similarity index 60%
rename from .idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b31.xml
rename to .idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b34.xml
index e99f9735..00ca7105 100644
--- a/.idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b31.xml
+++ b/.idea/libraries/Maven__org_glassfish_hk2_hk2_utils_2_4_0_b34.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_2.xml
similarity index 66%
rename from .idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_2.xml
index 3836fa4b..4a0aac2a 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_bundles_repackaged_jersey_guava_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_2.xml
similarity index 54%
rename from .idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_2.xml
index cd470f34..8dea8efc 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_containers_jersey_container_grizzly2_http_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_2.xml
similarity index 67%
rename from .idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_2.xml
index d9aea913..37260b9a 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_client_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_2.xml
similarity index 67%
rename from .idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_2.xml
index beb58fe1..5ada064a 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_common_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_2.xml
similarity index 67%
rename from .idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_2.xml
index c0698573..04a42466 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_core_jersey_server_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_2.xml
similarity index 68%
rename from .idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_2.xml
index 3d6acfa0..30240847 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_ext_jersey_entity_filtering_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_2.xml
similarity index 67%
rename from .idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_2.xml
index e3cc3cef..8c59a6a3 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_jaxb_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_1.xml b/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_2.xml
similarity index 58%
rename from .idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_1.xml
rename to .idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_2.xml
index 17b61a13..3e399f21 100644
--- a/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_1.xml
+++ b/.idea/libraries/Maven__org_glassfish_jersey_media_jersey_media_json_jackson_2_22_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_json_json_20151123.xml b/.idea/libraries/Maven__org_json_json_20151123.xml
deleted file mode 100644
index 324279dd..00000000
--- a/.idea/libraries/Maven__org_json_json_20151123.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_json_json_20160212.xml b/.idea/libraries/Maven__org_json_json_20160212.xml
new file mode 100644
index 00000000..44a278c3
--- /dev/null
+++ b/.idea/libraries/Maven__org_json_json_20160212.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TelegramBots.iml b/TelegramBots.iml
index f0d376fb..9b954c23 100644
--- a/TelegramBots.iml
+++ b/TelegramBots.iml
@@ -11,43 +11,43 @@
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
diff --git a/pom.xml b/pom.xml
index e127009e..af7234cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
jar
org.telegram
telegrambots
- 1.1
+ 2.0
Telegram Bots
Easy to use library to create Telegram Bots
@@ -21,8 +21,10 @@
UTF-8
UTF-8
- 2.22.1
+ 2.22.2
+ 1.19.1
4.5.2
+ 20160212
@@ -50,17 +52,17 @@
com.sun.jersey
jersey-bundle
- 1.19
+ ${jerseybundle.version}
com.sun.jersey
jersey-grizzly2-servlet
- 1.19
+ ${jerseybundle.version}
org.json
json
- 20151123
+ ${json.version}
org.apache.httpcomponents
diff --git a/src/main/java/org/telegram/telegrambots/TelegramApiException.java b/src/main/java/org/telegram/telegrambots/TelegramApiException.java
index 288cc52a..5ae66d42 100644
--- a/src/main/java/org/telegram/telegrambots/TelegramApiException.java
+++ b/src/main/java/org/telegram/telegrambots/TelegramApiException.java
@@ -3,7 +3,7 @@ package org.telegram.telegrambots;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief TODO
+ * @brief Exception thrown when something goes wrong in the api
* @date 14 of January of 2016
*/
public class TelegramApiException extends Exception {
diff --git a/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java b/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java
index 1a2bd37b..524b7894 100644
--- a/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java
+++ b/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java
@@ -13,7 +13,7 @@ import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.telegram.telegrambots.api.Constants;
-import org.telegram.telegrambots.api.methods.SetWebhook;
+import org.telegram.telegrambots.api.methods.updates.SetWebhook;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.bots.TelegramWebhookBot;
import org.telegram.telegrambots.updatesreceivers.UpdatesThread;
@@ -25,7 +25,7 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief TODO
+ * @brief Bots manager
* @date 14 of January of 2016
*/
public class TelegramBotsApi {
diff --git a/src/main/java/org/telegram/telegrambots/api/Constants.java b/src/main/java/org/telegram/telegrambots/api/Constants.java
index 8c05d9de..2a20856e 100644
--- a/src/main/java/org/telegram/telegrambots/api/Constants.java
+++ b/src/main/java/org/telegram/telegrambots/api/Constants.java
@@ -3,10 +3,9 @@ package org.telegram.telegrambots.api;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief TODO
+ * @brief Constants needed for Telegram Bots API
* @date 20 of June of 2015
*/
public class Constants {
public static final String BASEURL = "https://api.telegram.org/bot";
- public static final int SOCKET_TIMEOUT = 30 * 1000;
}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java b/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java
new file mode 100644
index 00000000..fc383254
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/AnswerCallbackQuery.java
@@ -0,0 +1,89 @@
+package org.telegram.telegrambots.api.methods;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to send answers to callback queries sent from inline keyboards. The answer
+ * will be displayed to the user as a notification at the top of the chat screen or as an alert. On
+ * success, True is returned.
+ * @date 10 of April of 2016
+ */
+public class AnswerCallbackQuery extends BotApiMethod {
+ public static final String PATH = "answercallbackquery";
+
+ private static final String CALLBACKQUERYID_FIELD = "callback_query_id";
+ private static final String TEXT_FIELD = "text";
+ private static final String SHOWALERT_FIELD = "show_alert";
+
+ private String callbackQueryId; ///< Unique identifier for the query to be answered
+ private String text; ///< Text of the notification. If not specified, nothing will be shown to the user
+ 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.
+
+
+ public AnswerCallbackQuery() {
+ super();
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(CALLBACKQUERYID_FIELD, callbackQueryId);
+ if (text != null) {
+ jsonObject.put(TEXT_FIELD, text);
+ }
+ if (showAlert != null) {
+ jsonObject.put(SHOWALERT_FIELD, showAlert);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return answer.getBoolean("result");
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ gen.writeStringField(CALLBACKQUERYID_FIELD, callbackQueryId);
+ if (text != null) {
+ gen.writeStringField(TEXT_FIELD, text);
+ }
+ if (showAlert != null) {
+ gen.writeBooleanField(SHOWALERT_FIELD, showAlert);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "AnswerInlineQuery{" +
+ "callbackQueryId='" + callbackQueryId + '\'' +
+ ", text=" + text +
+ ", showAlert=" + showAlert + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java b/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java
index 865e64c1..882d6e37 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONArray;
import org.json.JSONObject;
-import org.telegram.telegrambots.api.objects.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import java.io.IOException;
import java.util.List;
@@ -20,16 +20,20 @@ import java.util.List;
public class AnswerInlineQuery extends BotApiMethod {
public static final String PATH = "answerInlineQuery";
- public static final String INLINEQUERYID_FIELD = "inline_query_id";
- public static final String RESULTS_FIELD = "results";
- public static final String CACHETIME_FIELD = "cache_time";
- public static final String ISPERSONAL_FIELD = "is_personal";
- public static final String NEXTOFFSET_FIELD = "next_offset";
+ private static final String INLINEQUERYID_FIELD = "inline_query_id";
+ private static final String RESULTS_FIELD = "results";
+ private static final String CACHETIME_FIELD = "cache_time";
+ private static final String ISPERSONAL_FIELD = "is_personal";
+ private static final String NEXTOFFSET_FIELD = "next_offset";
+ private static final String SWITCH_PM_TEXT_FIELD = "switch_pm_text";
+ private static final String SWITCH_PM_PARAMETER_FIELD = "switch_pm_parameter";
private String inlineQueryId; ///< Unique identifier for answered query
private List results; ///< A JSON-serialized array of results for the inline query
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
- private String nextOffset; ///< Optional Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
+ private String nextOffset; ///< Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
+ private String switchPmText; ///< Optional. If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
+ private String switchPmParameter; ///< Optional. Parameter for the start message sent to the bot when user presses the switch button
public AnswerInlineQuery() {
super();
@@ -75,6 +79,22 @@ public class AnswerInlineQuery extends BotApiMethod {
this.nextOffset = nextOffset;
}
+ public String getSwitchPmText() {
+ return switchPmText;
+ }
+
+ public void setSwitchPmText(String switchPmText) {
+ this.switchPmText = switchPmText;
+ }
+
+ public String getSwitchPmParameter() {
+ return switchPmParameter;
+ }
+
+ public void setSwitchPmParameter(String switchPmParameter) {
+ this.switchPmParameter = switchPmParameter;
+ }
+
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
@@ -93,6 +113,12 @@ public class AnswerInlineQuery extends BotApiMethod {
if (nextOffset != null) {
jsonObject.put(NEXTOFFSET_FIELD, nextOffset);
}
+ if (switchPmText != null) {
+ jsonObject.put(SWITCH_PM_TEXT_FIELD, switchPmText);
+ }
+ if (switchPmParameter != null) {
+ jsonObject.put(SWITCH_PM_PARAMETER_FIELD, switchPmParameter);
+ }
return jsonObject;
}
@@ -127,6 +153,12 @@ public class AnswerInlineQuery extends BotApiMethod {
if (nextOffset != null) {
gen.writeStringField(NEXTOFFSET_FIELD, nextOffset);
}
+ if (switchPmText != null) {
+ gen.writeStringField(SWITCH_PM_TEXT_FIELD, switchPmText);
+ }
+ if (switchPmParameter != null) {
+ gen.writeStringField(SWITCH_PM_PARAMETER_FIELD, switchPmParameter);
+ }
gen.writeEndObject();
gen.flush();
@@ -144,6 +176,8 @@ public class AnswerInlineQuery extends BotApiMethod {
", results=" + results +
", cacheTime=" + cacheTime +
", isPersonal=" + isPersonal +
+ ", switchPmText=" + switchPmText +
+ ", switchPmParameter=" + switchPmParameter +
", nextOffset='" + nextOffset + '\'' +
'}';
}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java b/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java
index c626a266..8c8c66b8 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java
@@ -18,9 +18,9 @@ import java.io.IOException;
public class GetUserProfilePhotos extends BotApiMethod {
public static final String PATH = "getuserprofilephotos";
- public static final String USERID_FIELD = "user_id";
- public static final String OFFSET_FIELD = "offset";
- public static final String LIMIT_FIELD = "limit";
+ private static final String USERID_FIELD = "user_id";
+ private static final String OFFSET_FIELD = "offset";
+ private static final String LIMIT_FIELD = "limit";
private Integer userId; ///< Unique identifier of the target user
/**
* Sequential number of the first photo to be returned. By default, all photos are returned.
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/ParseMode.java b/src/main/java/org/telegram/telegrambots/api/methods/ParseMode.java
new file mode 100644
index 00000000..169d03a3
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/ParseMode.java
@@ -0,0 +1,12 @@
+package org.telegram.telegrambots.api.methods;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Type of parse modes for text in messages
+ * @date 10 of April of 2016
+ */
+public class ParseMode {
+ public static final String MARKDOWN = "Markdown";
+ public static final String HTML = "html";
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/KickChatMember.java b/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/KickChatMember.java
new file mode 100644
index 00000000..6b29c1bf
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/KickChatMember.java
@@ -0,0 +1,95 @@
+package org.telegram.telegrambots.api.methods.groupadministration;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to kick a user from a group or a supergroup. In the case of supergroups,
+ * the user will not be able to return to the group on their own using invite links, etc., unless
+ * unbanned first. The bot must be an administrator in the group for this to work. Returns True on
+ * success.
+ * @note This will method only work if the ‘All Members Are Admins’ setting is off in the target
+ * group. Otherwise members may only be removed by the group's creator or by the member that added
+ * them.
+ * @date 10 of April of 2016
+ */
+public class KickChatMember extends BotApiMethod {
+ public static final String PATH = "kickchatmember";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String USER_ID_FIELD = "user_id";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private Integer userId; ///< Unique identifier of the target user
+
+ public KickChatMember() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(USER_ID_FIELD, userId);
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return answer.getBoolean("result");
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(USER_ID_FIELD, userId);
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "SendMessage{" +
+ "chatId='" + chatId + '\'' +
+ ", userId='" + userId +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/UnbanChatMember.java b/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/UnbanChatMember.java
new file mode 100644
index 00000000..032f886b
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/groupadministration/UnbanChatMember.java
@@ -0,0 +1,91 @@
+package org.telegram.telegrambots.api.methods.groupadministration;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to unban a previously kicked user in a supergroup. The user will not
+ * return to the group automatically, but will be able to join via link, etc. The bot must be an
+ * administrator in the group for this to work. Returns True on success.
+ * @date 10 of April of 2016
+ */
+public class UnbanChatMember extends BotApiMethod {
+ public static final String PATH = "unbanchatmember";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String USER_ID_FIELD = "user_id";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private Integer userId; ///< Unique identifier of the target user
+
+ public UnbanChatMember() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(USER_ID_FIELD, userId);
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return answer.getBoolean("result");
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(USER_ID_FIELD, userId);
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "SendMessage{" +
+ "chatId='" + chatId + '\'' +
+ ", userId='" + userId +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java
similarity index 82%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java
index 3ae4c837..10689142 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java
@@ -1,23 +1,21 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Use this method to send audio files,
- * Use this method to send audio files, if you want Telegram clients to display them in the music player.
- * Your audio must be in an .mp3 format. On success, the sent Message is returned.
- * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
- *
+ * @brief Use this method to send audio files, Use this method to send audio files, if you want
+ * Telegram clients to display them in the music player. Your audio must be in an .mp3 format. On
+ * success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
+ * size, this limit may be changed in the future.
* @note For sending voice notes, use sendVoice method instead.
- *
* @date 16 of July of 2015
*/
public class SendAudio {
public static final String PATH = "sendaudio";
- public static final String DURATION_FIELD = "duration";
+ public static final String DURATION_FIELD = "duration";
public static final String CHATID_FIELD = "chat_id";
public static final String AUDIO_FIELD = "audio";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
@@ -25,15 +23,14 @@ public class SendAudio {
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PERFOMER_FIELD = "performer";
public static final String TITLE_FIELD = "title";
+
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@@ -46,9 +43,9 @@ public class SendAudio {
super();
}
- public Integer getDuration(){
- return this.duration;
- }
+ public Integer getDuration() {
+ return this.duration;
+ }
public void setDuration(Integer duration) {
this.duration = duration;
@@ -68,8 +65,8 @@ public class SendAudio {
/**
* Use this method to set the audio to an audio existing in Telegram system
- * @param audio File_id of the audio to send
*
+ * @param audio File_id of the audio to send
* @note The file_id must have already been received or sent by your bot
*/
public void setAudio(String audio) {
@@ -79,7 +76,8 @@ public class SendAudio {
/**
* Use this method to set the audio to a new file
- * @param audio Path to the new file in your server
+ *
+ * @param audio Path to the new file in your server
* @param audioName Name of the file itself
*/
public void setNewAudio(String audio, String audioName) {
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendChatAction.java
similarity index 76%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendChatAction.java
index e78dec18..5dd3e4af 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendChatAction.java
@@ -1,22 +1,23 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Use this method when you need to tell the user that something is happening on the bot's side.
- * The status is set for 5 seconds or less (when a message arrives from your bot,
- * Telegram clients clear its typing status).
+ * @brief Use this method when you need to tell the user that something is happening on the bot's
+ * side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram
+ * clients clear its typing status).
* @date 20 of June of 2015
*/
-public class SendChatAction extends BotApiMethod{
+public class SendChatAction extends BotApiMethod {
public static final String PATH = "sendChatAction";
@@ -24,14 +25,10 @@ public class SendChatAction extends BotApiMethod{
public static final String ACTION_FIELD = "action";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
- * Type of action to broadcast.
- * Choose one, depending on what the user is about to receive:
- * 'typing' for text messages
- * 'upload_photo' for photos
- * 'record_video' or 'upload_video' for videos
- * 'record_audio' or 'upload_audio' for audio files
- * 'upload_document' for general files,
- * 'find_location' for location data.
+ * Type of action to broadcast. Choose one, depending on what the user is about to receive:
+ * 'typing' for text messages 'upload_photo' for photos 'record_video' or 'upload_video' for
+ * videos 'record_audio' or 'upload_audio' for audio files 'upload_document' for general files,
+ * 'find_location' for location data.
*/
private String action;
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendContact.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendContact.java
new file mode 100644
index 00000000..0751a65b
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendContact.java
@@ -0,0 +1,178 @@
+package org.telegram.telegrambots.api.methods.send;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.objects.Message;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to send information about user contact. On success, the sent Message is
+ * returned.
+ * @date 10 of April of 2016
+ */
+public class SendContact extends BotApiMethod {
+ public static final String PATH = "sendContact";
+
+ public static final String CHATID_FIELD = "chat_id";
+ public static final String PHONE_NUMBER_FIELD = "phone_number";
+ public static final String FIRST_NAME_FIELD = "first_name";
+ public static final String LAST_NAME_FIELD = "last_name";
+ public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private String phoneNumber; ///< User's phone number
+ private String firstName; ///< User's first name
+ private String lastName; ///< Optional. User's last name
+ /**
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
+ */
+ private Boolean disableNotification;
+ private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
+ private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getReplayToMessageId() {
+ return replayToMessageId;
+ }
+
+ public void setReplayToMessageId(Integer replayToMessageId) {
+ this.replayToMessageId = replayToMessageId;
+ }
+
+ public ReplyKeyboard getReplayMarkup() {
+ return replayMarkup;
+ }
+
+ public void setReplayMarkup(ReplyKeyboard replayMarkup) {
+ this.replayMarkup = replayMarkup;
+ }
+
+ public Boolean getDisableNotification() {
+ return disableNotification;
+ }
+
+ public void enableNotification() {
+ this.disableNotification = false;
+ }
+
+ public void disableNotification() {
+ this.disableNotification = true;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Message deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return new Message(answer.getJSONObject("result"));
+ }
+ return null;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
+ jsonObject.put(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ jsonObject.put(LAST_NAME_FIELD, lastName);
+ }
+ if (disableNotification != null) {
+ jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
+ }
+ if (replayToMessageId != null) {
+ jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
+ }
+ if (replayMarkup != null) {
+ jsonObject.put(REPLYMARKUP_FIELD, replayMarkup.toJson());
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
+ gen.writeStringField(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ gen.writeStringField(LAST_NAME_FIELD, lastName);
+ }
+ if (disableNotification != null) {
+ gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
+ }
+ if (replayToMessageId != null) {
+ gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
+ }
+ if (replayMarkup != null) {
+ gen.writeObjectField(REPLYMARKUP_FIELD, replayMarkup);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "SendLocation{" +
+ "chatId='" + chatId + '\'' +
+ ", phoneNumber=" + phoneNumber +
+ ", firstName=" + firstName +
+ ", lastName=" + lastName +
+ ", replayToMessageId=" + replayToMessageId +
+ ", replayMarkup=" + replayMarkup +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendDocument.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java
similarity index 91%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendDocument.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java
index 83bb9b51..91a08c4c 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendDocument.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java
@@ -1,6 +1,6 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
@@ -12,22 +12,20 @@ public class SendDocument {
public static final String PATH = "senddocument";
public static final String CHATID_FIELD = "chat_id";
- private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
public static final String DOCUMENT_FIELD = "document";
- private String document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers
public static final String CAPTION_FIELD = "caption";
- private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
+ private String document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers
+ private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewDocument;
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendLocation.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendLocation.java
similarity index 85%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendLocation.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendLocation.java
index badbe8d7..bf01e1ba 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendLocation.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendLocation.java
@@ -1,12 +1,13 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException;
@@ -19,23 +20,21 @@ import java.io.IOException;
public class SendLocation extends BotApiMethod {
public static final String PATH = "sendlocation";
- public static final String CHATID_FIELD = "chat_id";
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public static final String LATITUDE_FIELD = "latitude";
private Float latitude; ///< Latitude of location
- public static final String LONGITUDE_FIELD = "longitude";
private Float longitude; ///< Longitude of location
- public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public String getChatId() {
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendMessage.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendMessage.java
similarity index 81%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendMessage.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendMessage.java
index ccb11b4f..332f174a 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendMessage.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendMessage.java
@@ -1,12 +1,14 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.methods.ParseMode;
import org.telegram.telegrambots.api.objects.Message;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException;
@@ -19,25 +21,23 @@ import java.io.IOException;
public class SendMessage extends BotApiMethod {
public static final String PATH = "sendmessage";
- public static final String CHATID_FIELD = "chat_id";
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String TEXT_FIELD = "text";
+ private static final String PARSEMODE_FIELD = "parse_mode";
+ private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
+ private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public static final String TEXT_FIELD = "text";
private String text; ///< Text of the message to be sent
- public static final String PARSEMODE_FIELD = "parse_mode";
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
- public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public SendMessage() {
@@ -80,16 +80,20 @@ public class SendMessage extends BotApiMethod {
return disableWebPagePreview;
}
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
- }
-
public Boolean getDisableNotification() {
return disableNotification;
}
+ public void disableWebPagePreview() {
+ disableWebPagePreview = true;
+ }
+
+ public void enableWebPagePreview() {
+ disableWebPagePreview = null;
+ }
+
public void enableNotification() {
- this.disableNotification = false;
+ this.disableNotification = null;
}
public void disableNotification() {
@@ -98,7 +102,7 @@ public class SendMessage extends BotApiMethod {
public void enableMarkdown(boolean enable) {
if (enable) {
- this.parseMode = "Markdown";
+ this.parseMode = ParseMode.MARKDOWN;
} else {
this.parseMode = null;
}
@@ -106,7 +110,7 @@ public class SendMessage extends BotApiMethod {
public void enableHtml(boolean enable) {
if (enable) {
- this.parseMode = "html";
+ this.parseMode = ParseMode.HTML;
} else {
this.parseMode = null;
}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendPhoto.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java
similarity index 91%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendPhoto.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java
index 0a369854..1ea1b3a8 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendPhoto.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java
@@ -1,6 +1,6 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
@@ -12,22 +12,20 @@ public class SendPhoto {
public static final String PATH = "sendphoto";
public static final String CHATID_FIELD = "chat_id";
- private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String PHOTO_FIELD = "photo";
- private String photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers
public static final String CAPTION_FIELD = "photo";
- private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private String photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers
+ private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewPhoto; ///< True if the photo must be uploaded from a file, file if it is a fileId
@@ -50,6 +48,11 @@ public class SendPhoto {
return photo;
}
+ public void setPhoto(String photo) {
+ this.photo = photo;
+ this.isNewPhoto = false;
+ }
+
public String getCaption() {
return caption;
}
@@ -94,11 +97,6 @@ public class SendPhoto {
this.disableNotification = true;
}
- public void setPhoto(String photo) {
- this.photo = photo;
- this.isNewPhoto = false;
- }
-
public void setNewPhoto(String photo, String photoName) {
this.photo = photo;
this.isNewPhoto = true;
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendSticker.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java
similarity index 87%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendSticker.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java
index f1d4c9dd..cb150961 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendSticker.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java
@@ -1,31 +1,29 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief TODO
+ * @brief Use this method to send .webp stickers. On success, the sent Message is returned.
* @date 20 of June of 2015
*/
public class SendSticker {
public static final String PATH = "sendsticker";
public static final String CHATID_FIELD = "chat_id";
- private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String STICKER_FIELD = "sticker";
- private String sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private String sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewSticker;
@@ -47,6 +45,11 @@ public class SendSticker {
return sticker;
}
+ public void setSticker(String sticker) {
+ this.sticker = sticker;
+ this.isNewSticker = false;
+ }
+
public Integer getReplayToMessageId() {
return replayToMessageId;
}
@@ -63,11 +66,6 @@ public class SendSticker {
this.replayMarkup = replayMarkup;
}
- public void setSticker(String sticker) {
- this.sticker = sticker;
- this.isNewSticker = false;
- }
-
public void setSticker(String sticker, String stickerName) {
this.sticker = sticker;
this.isNewSticker = true;
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendVenue.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVenue.java
new file mode 100644
index 00000000..bbb5d223
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVenue.java
@@ -0,0 +1,204 @@
+package org.telegram.telegrambots.api.methods.send;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.objects.Message;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to send information about a venue. On success, the sent Message is
+ * returned.
+ * @date 10 of April of 2016
+ */
+public class SendVenue extends BotApiMethod {
+ public static final String PATH = "sendVenue";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String TITLE_FIELD = "title";
+ private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ private static final String ADDRESS_FIELD = "address";
+ private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
+ private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private Float latitude; ///< Latitude of venue location
+ private Float longitude; ///< Longitude of venue location
+ private String title; ///< Title of the venue
+ /**
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
+ */
+ private Boolean disableNotification;
+ private String address; ///< Address of the venue
+ private String foursquareId; ///< Optional. Foursquare identifier of the venue
+ private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
+ private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Float getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(Float latitude) {
+ this.latitude = latitude;
+ }
+
+ public Float getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(Float longitude) {
+ this.longitude = longitude;
+ }
+
+ public Integer getReplayToMessageId() {
+ return replayToMessageId;
+ }
+
+ public void setReplayToMessageId(Integer replayToMessageId) {
+ this.replayToMessageId = replayToMessageId;
+ }
+
+ public ReplyKeyboard getReplayMarkup() {
+ return replayMarkup;
+ }
+
+ public void setReplayMarkup(ReplyKeyboard replayMarkup) {
+ this.replayMarkup = replayMarkup;
+ }
+
+ public Boolean getDisableNotification() {
+ return disableNotification;
+ }
+
+ public void enableNotification() {
+ this.disableNotification = false;
+ }
+
+ public void disableNotification() {
+ this.disableNotification = true;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getFoursquareId() {
+ return foursquareId;
+ }
+
+ public void setFoursquareId(String foursquareId) {
+ this.foursquareId = foursquareId;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Message deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return new Message(answer.getJSONObject("result"));
+ }
+ return null;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(LATITUDE_FIELD, latitude);
+ jsonObject.put(LONGITUDE_FIELD, longitude);
+ jsonObject.put(TITLE_FIELD, title);
+ jsonObject.put(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ if (disableNotification != null) {
+ jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
+ }
+ if (replayToMessageId != null) {
+ jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
+ }
+ if (replayMarkup != null) {
+ jsonObject.put(REPLYMARKUP_FIELD, replayMarkup.toJson());
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(LATITUDE_FIELD, latitude);
+ gen.writeNumberField(LONGITUDE_FIELD, longitude);
+ gen.writeStringField(TITLE_FIELD, title);
+ gen.writeStringField(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ if (disableNotification != null) {
+ gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
+ }
+ if (replayToMessageId != null) {
+ gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
+ }
+ if (replayMarkup != null) {
+ gen.writeObjectField(REPLYMARKUP_FIELD, replayMarkup);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "SendLocation{" +
+ "chatId='" + chatId + '\'' +
+ ", latitude=" + latitude +
+ ", longitude=" + longitude +
+ ", title=" + title +
+ ", address=" + address +
+ ", foursquareId=" + foursquareId +
+ ", replayToMessageId=" + replayToMessageId +
+ ", replayMarkup=" + replayMarkup +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendVideo.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java
similarity index 89%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendVideo.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java
index 1885c93a..89620a35 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendVideo.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java
@@ -1,41 +1,38 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Use this method to send video files,
- * Telegram clients support mp4 videos (other formats may be sent as Document).
- * On success, the sent Message is returned.
+ * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats
+ * may be sent as Document). On success, the sent Message is returned.
* @date 20 of June of 2015
*/
public class SendVideo {
public static final String PATH = "sendvideo";
public static final String CHATID_FIELD = "chat_id";
- private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String VIDEO_FIELD = "video";
- private String video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers
public static final String DURATION_FIELD = "duration";
- private Integer duration; ///< Optional. Duration of sent video in seconds
public static final String CAPTION_FIELD = "caption";
- private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
public static final String WIDTH_FIELD = "width";
- private Integer width; ///< Optional. Video width
public static final String HEIGHT_FIELD = "height";
- private Integer height; ///< OptionaL. Video height
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private String video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers
+ private Integer duration; ///< Optional. Duration of sent video in seconds
+ private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
+ private Integer width; ///< Optional. Video width
+ private Integer height; ///< OptionaL. Video height
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewVideo; ///< True to upload a new video, false to use a fileId
@@ -57,6 +54,11 @@ public class SendVideo {
return video;
}
+ public void setVideo(String video) {
+ this.video = video;
+ this.isNewVideo = false;
+ }
+
public Integer getDuration() {
return duration;
}
@@ -125,11 +127,6 @@ public class SendVideo {
this.height = height;
}
- public void setVideo(String video) {
- this.video = video;
- this.isNewVideo = false;
- }
-
public void setNewVideo(String video, String videoName) {
this.video = video;
this.isNewVideo = true;
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendVoice.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java
similarity index 88%
rename from src/main/java/org/telegram/telegrambots/api/methods/SendVoice.java
rename to src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java
index 6bf5e52a..0a8456a3 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SendVoice.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java
@@ -1,13 +1,12 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.send;
-import org.telegram.telegrambots.api.objects.ReplyKeyboard;
+import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Use this method to send voice notes, if you want Telegram clients to display
- * the file as a playable voice message.
- * For this to work, your audio must be in an .ogg file encoded with OPUS
+ * @brief Use this method to send voice notes, if you want Telegram clients to display the file as a
+ * playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
* (other formats may be sent as Audio or Document).
* @date 16 of July of 2015
*/
@@ -15,22 +14,20 @@ public class SendVoice {
public static final String PATH = "sendvoice";
public static final String CHATID_FIELD = "chat_id";
- private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
public static final String AUDIO_FIELD = "audio";
- private String audio; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ public static final String REPLYMARKUP_FIELD = "reply_markup";
+ public static final String DURATION_FIELD = "duration";
+ private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
+ private String audio; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
/**
- * Optional. Sends the message silently.
- * iOS users will not receive a notification,
- * Android users will receive a notification with no sound.
- * Other apps coming soon
+ * Optional. Sends the message silently. iOS users will not receive a notification, Android
+ * users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
- public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
- public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
- public static final String DURATION_FIELD = "duration";
private Integer duration; ///< Optional. Duration of sent audio in seconds
private boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/GetUpdates.java b/src/main/java/org/telegram/telegrambots/api/methods/updates/GetUpdates.java
similarity index 63%
rename from src/main/java/org/telegram/telegrambots/api/methods/GetUpdates.java
rename to src/main/java/org/telegram/telegrambots/api/methods/updates/GetUpdates.java
index 6195ab66..3dcb2155 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/GetUpdates.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/updates/GetUpdates.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.updates;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IToJson;
@@ -6,31 +6,30 @@ import org.telegram.telegrambots.api.interfaces.IToJson;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Use this method to receive incoming updates using long polling (wiki).
- * An Array of Update objects is returned.
+ * @brief Use this method to receive incoming updates using long polling (wiki). An Array of Update
+ * objects is returned.
* @date 20 of June of 2015
*/
public class GetUpdates implements IToJson {
public static final String PATH = "getupdates";
- public static final String OFFSET_FIELD = "offset";
+ private static final String OFFSET_FIELD = "offset";
+ private static final String LIMIT_FIELD = "limit";
+ private static final String TIMEOUT_FIELD = "timeout";
/**
- * Optional. Identifier of the first update to be returned.
- * Must be greater by one than the highest among the identifiers
- * of previously received updates. By default, updates starting with the
- * earliest unconfirmed update are returned. An update is considered confirmed as soon as
- * getUpdates is called with an offset higher than its update_id. The negative offset can
- * be specified to retrieve updates starting from -offset update from the end of
- * the updates queue. All previous updates will forgotten.
+ * Optional. Identifier of the first update to be returned. Must be greater by one than the
+ * highest among the identifiers of previously received updates. By default, updates starting
+ * with the earliest unconfirmed update are returned. An update is considered confirmed as soon
+ * as getUpdates is called with an offset higher than its update_id. The negative offset can be
+ * specified to retrieve updates starting from -offset update from the end of the updates queue.
+ * All previous updates will forgotten.
*/
private Integer offset;
- public static final String LIMIT_FIELD = "limit";
/**
- * Optional Limits the number of updates to be retrieved.
- * Values between 1—100 are accepted. Defaults to 100
+ * Optional Limits the number of updates to be retrieved. Values between 1—100 are accepted.
+ * Defaults to 100
*/
private Integer limit;
- public static final String TIMEOUT_FIELD = "timeout";
/**
* Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
*/
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SetWebhook.java b/src/main/java/org/telegram/telegrambots/api/methods/updates/SetWebhook.java
similarity index 91%
rename from src/main/java/org/telegram/telegrambots/api/methods/SetWebhook.java
rename to src/main/java/org/telegram/telegrambots/api/methods/updates/SetWebhook.java
index 46f05549..99ebdca7 100644
--- a/src/main/java/org/telegram/telegrambots/api/methods/SetWebhook.java
+++ b/src/main/java/org/telegram/telegrambots/api/methods/updates/SetWebhook.java
@@ -1,20 +1,20 @@
-package org.telegram.telegrambots.api.methods;
+package org.telegram.telegrambots.api.methods.updates;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to specify a url and receive incoming updates via an outgoing webhook.
* Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url,
- * containing a JSON-serialized Update. In case of an unsuccessful request,
- * we will give up after a reasonable amount of attempts.
+ * containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a
+ * reasonable amount of attempts.
* @date 20 of June of 2015
*/
public class SetWebhook {
public static final String PATH = "setwebhook";
public static final String URL_FIELD = "url";
- private String url; ///< Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration
public static final String CERTIFICATE_FIELD = "certificate";
+ private String url; ///< Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration
private String certificateFile; ///< Optional. Upload your public key certificate so that the root certificate in use can be checked
public SetWebhook() {
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageCaption.java b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageCaption.java
new file mode 100644
index 00000000..a3e895b2
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageCaption.java
@@ -0,0 +1,156 @@
+package org.telegram.telegrambots.api.methods.updatingmessages;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.objects.Message;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline
+ * bots). On success, the edited Message is returned
+ * @date 10 of April of 2016
+ */
+public class EditMessageCaption extends BotApiMethod {
+ public static final String PATH = "editmessagecaption";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
+ private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+
+ /**
+ * Required if inline_message_id is not specified. Unique identifier for the chat to send the
+ * message to (Or username for channels)
+ */
+ private String chatId;
+ /**
+ * Required if inline_message_id is not specified. Unique identifier of the sent message
+ */
+ private Integer messageId;
+ /**
+ * Required if chat_id and message_id are not specified. Identifier of the inline message
+ */
+ private String inlineMessageId;
+ private String caption; ///< Optional. New caption of the message
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
+
+ public EditMessageCaption() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(Integer messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getInlineMessageId() {
+ return inlineMessageId;
+ }
+
+ public void setInlineMessageId(String inlineMessageId) {
+ this.inlineMessageId = inlineMessageId;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ if (inlineMessageId == null) {
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(MESSAGEID_FIELD, messageId);
+ } else {
+ jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Message deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return new Message(answer.getJSONObject("result"));
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ if (inlineMessageId == null) {
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(MESSAGEID_FIELD, messageId);
+ } else {
+ gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "EditMessageCaption{" +
+ "chatId=" + chatId +
+ ", messageId=" + messageId +
+ ", inlineMessageId=" + inlineMessageId +
+ ", caption=" + caption +
+ ", replyMarkup=" + replyMarkup +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java
new file mode 100644
index 00000000..12349cb2
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageReplyMarkup.java
@@ -0,0 +1,139 @@
+package org.telegram.telegrambots.api.methods.updatingmessages;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.objects.Message;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot
+ * (for inline bots). On success, the edited Message is returned.
+ * @date 10 of April of 2016
+ */
+public class EditMessageReplyMarkup extends BotApiMethod {
+ public static final String PATH = "editmessagereplymarkup";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
+ private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+
+ /**
+ * Required if inline_message_id is not specified. Unique identifier for the chat to send the
+ * message to (Or username for channels)
+ */
+ private String chatId;
+ /**
+ * Required if inline_message_id is not specified. Unique identifier of the sent message
+ */
+ private Integer messageId;
+ /**
+ * Required if chat_id and message_id are not specified. Identifier of the inline message
+ */
+ private String inlineMessageId;
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
+
+ public EditMessageReplyMarkup() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(Integer messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getInlineMessageId() {
+ return inlineMessageId;
+ }
+
+ public void setInlineMessageId(String inlineMessageId) {
+ this.inlineMessageId = inlineMessageId;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ if (inlineMessageId == null) {
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(MESSAGEID_FIELD, messageId);
+ } else {
+ jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Message deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return new Message(answer.getJSONObject("result"));
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ if (inlineMessageId == null) {
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(MESSAGEID_FIELD, messageId);
+ } else {
+ gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "EditMessageReplyMarkup{" +
+ "chatId=" + chatId +
+ ", messageId=" + messageId +
+ ", inlineMessageId=" + inlineMessageId +
+ ", replyMarkup=" + replyMarkup +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java
new file mode 100644
index 00000000..64f4dee4
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/methods/updatingmessages/EditMessageText.java
@@ -0,0 +1,202 @@
+package org.telegram.telegrambots.api.methods.updatingmessages;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.BotApiMethod;
+import org.telegram.telegrambots.api.methods.ParseMode;
+import org.telegram.telegrambots.api.objects.Message;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Use this method to edit text messages sent by the bot or via the bot (for inline bots). On
+ * success, the edited Message is returned.
+ * @date 10 of April of 2016
+ */
+public class EditMessageText extends BotApiMethod {
+ public static final String PATH = "editmessagetext";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
+ private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
+ private static final String TEXT_FIELD = "text";
+ private static final String PARSE_MODE_FIELD = "parse_mode";
+ private static final String DISABLE_WEB_PREVIEW_FIELD = "disable_web_page_preview";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+
+ /**
+ * Required if inline_message_id is not specified. Unique identifier for the chat to send the
+ * message to (Or username for channels)
+ */
+ private String chatId;
+ /**
+ * Required if inline_message_id is not specified. Unique identifier of the sent message
+ */
+ private Integer messageId;
+ /**
+ * Required if chat_id and message_id are not specified. Identifier of the inline message
+ */
+ private String inlineMessageId;
+ /**
+ * New text of the message
+ */
+ private String text;
+ /**
+ * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width
+ * text or inline URLs in your bot's message.
+ */
+ private String parseMode;
+ private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
+
+ public EditMessageText() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public void setChatId(String chatId) {
+ this.chatId = chatId;
+ }
+
+ public Integer getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(Integer messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getInlineMessageId() {
+ return inlineMessageId;
+ }
+
+ public void setInlineMessageId(String inlineMessageId) {
+ this.inlineMessageId = inlineMessageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public void disableWebPagePreview() {
+ disableWebPagePreview = true;
+ }
+
+ public void enableWebPagePreview() {
+ disableWebPagePreview = null;
+ }
+
+ public void enableMarkdown(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.MARKDOWN;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ public void enableHtml(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.HTML;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ if (inlineMessageId == null) {
+ jsonObject.put(CHATID_FIELD, chatId);
+ jsonObject.put(MESSAGEID_FIELD, messageId);
+ } else {
+ jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ jsonObject.put(TEXT_FIELD, text);
+ if (parseMode != null) {
+ jsonObject.put(PARSE_MODE_FIELD, parseMode);
+ }
+ if (disableWebPagePreview != null) {
+ jsonObject.put(DISABLE_WEB_PREVIEW_FIELD, disableWebPagePreview);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public String getPath() {
+ return PATH;
+ }
+
+ @Override
+ public Message deserializeResponse(JSONObject answer) {
+ if (answer.getBoolean("ok")) {
+ return new Message(answer.getJSONObject("result"));
+ }
+ return null;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(METHOD_FIELD, PATH);
+ if (inlineMessageId == null) {
+ gen.writeStringField(CHATID_FIELD, chatId);
+ gen.writeNumberField(MESSAGEID_FIELD, messageId);
+ } else {
+ gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ gen.writeStringField(TEXT_FIELD, text);
+ if (parseMode != null) {
+ gen.writeStringField(PARSE_MODE_FIELD, parseMode);
+ }
+ if (disableWebPagePreview != null) {
+ gen.writeBooleanField(DISABLE_WEB_PREVIEW_FIELD, disableWebPagePreview);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "EditMessageText{" +
+ "chatId=" + chatId +
+ ", messageId=" + messageId +
+ ", inlineMessageId=" + inlineMessageId +
+ ", text=" + text +
+ ", parseMode=" + parseMode +
+ ", disableWebPagePreview=" + disableWebPagePreview +
+ ", replyMarkup=" + replyMarkup +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Audio.java b/src/main/java/org/telegram/telegrambots/api/objects/Audio.java
index d596f5f4..20f80443 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Audio.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Audio.java
@@ -18,12 +18,12 @@ import java.io.IOException;
*/
public class Audio implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
- public static final String DURATION_FIELD = "duration";
- public static final String MIMETYPE_FIELD = "mime_type";
- public static final String FILESIZE_FIELD = "file_size";
- public static final String TITLE_FIELD = "title";
- public static final String PERFORMER_FIELD = "performer";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String DURATION_FIELD = "duration";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String FILESIZE_FIELD = "file_size";
+ private static final String TITLE_FIELD = "title";
+ private static final String PERFORMER_FIELD = "performer";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
@JsonProperty(DURATION_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/CallbackQuery.java b/src/main/java/org/telegram/telegrambots/api/objects/CallbackQuery.java
new file mode 100644
index 00000000..13ea8a33
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/CallbackQuery.java
@@ -0,0 +1,98 @@
+package org.telegram.telegrambots.api.objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents an incoming callback query from a callback button in an inline
+ * keyboard. If the button that originated the query was attached to a message sent by the bot, the
+ * field message will be presented. If the button was attached to a message sent via the bot (in
+ * inline mode), the field inline_message_id will be presented.
+ * @date 10 of April of 2016
+ */
+public class CallbackQuery implements IBotApiObject {
+
+ private static final String ID_FIELD = "id";
+ private static final String FROM_FIELD = "from";
+ private static final String MESSAGE_FIELD = "message";
+ private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
+ private static final String DATA_FIELD = "data";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier for this query
+ @JsonProperty(FROM_FIELD)
+ private User from; ///< Sender
+ @JsonProperty(MESSAGE_FIELD)
+ /**
+ * Optional.
+ * Message with the callback button that originated the query.
+ *
+ * @note The message content and message date will not be available if the message is too old
+ */
+ private Message message;
+ @JsonProperty(INLINE_MESSAGE_ID_FIELD)
+ private String inlineMessageId; ///< Optional. Identifier of the message sent via the bot in inline mode, that originated the query
+ @JsonProperty(DATA_FIELD)
+ /**
+ * Data associated with the callback button.
+ * @note Be aware that a bad client can send arbitrary data in this field
+ */
+ private String data;
+
+ public CallbackQuery() {
+ super();
+ }
+
+ public CallbackQuery(JSONObject jsonObject) {
+ super();
+ this.id = jsonObject.getString(ID_FIELD);
+ this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
+ if (jsonObject.has(MESSAGE_FIELD)) {
+ this.message = new Message(jsonObject.getJSONObject(MESSAGE_FIELD));
+ }
+ if (jsonObject.has(INLINE_MESSAGE_ID_FIELD)) {
+ this.inlineMessageId = jsonObject.getString(INLINE_MESSAGE_ID_FIELD);
+ }
+ data = jsonObject.getString(DATA_FIELD);
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeObjectField(FROM_FIELD, from);
+ if (message != null) {
+ gen.writeObjectField(MESSAGE_FIELD, message);
+ }
+ if (inlineMessageId != null) {
+ gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
+ gen.writeStringField(DATA_FIELD, data);
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "Contact{" +
+ "id='" + id + '\'' +
+ ", from='" + from + '\'' +
+ ", message='" + message + '\'' +
+ ", inlineMessageId='" + inlineMessageId + '\'' +
+ ", data=" + data +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Chat.java b/src/main/java/org/telegram/telegrambots/api/objects/Chat.java
index c969f24f..065aac32 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Chat.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Chat.java
@@ -17,12 +17,12 @@ import java.io.IOException;
* @date 24 of June of 2015
*/
public class Chat implements IBotApiObject {
- public static final String ID_FIELD = "id";
- public static final String TYPE_FIELD = "type";
- public static final String TITLE_FIELD = "title";
- public static final String FIRSTNAME_FIELD = "first_name";
- public static final String LASTNAME_FIELD = "last_name";
- public static final String USERNAME_FIELD = "username";
+ private static final String ID_FIELD = "id";
+ private static final String TYPE_FIELD = "type";
+ private static final String TITLE_FIELD = "title";
+ private static final String FIRSTNAME_FIELD = "first_name";
+ private static final String LASTNAME_FIELD = "last_name";
+ private static final String USERNAME_FIELD = "username";
private static final String USERCHATTYPE = "private";
private static final String GROUPCHATTYPE = "group";
private static final String CHANNELCHATTYPE = "channel";
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Contact.java b/src/main/java/org/telegram/telegrambots/api/objects/Contact.java
index bee4d1c8..cc679e8b 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Contact.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Contact.java
@@ -18,10 +18,10 @@ import java.io.IOException;
*/
public class Contact implements IBotApiObject {
- public static final String PHONENUMBER_FIELD = "phone_number";
- public static final String FIRSTNAME_FIELD = "first_name";
- public static final String LASTNAME_FIELD = "last_name";
- public static final String USERID_FIELD = "user_id";
+ private static final String PHONENUMBER_FIELD = "phone_number";
+ private static final String FIRSTNAME_FIELD = "first_name";
+ private static final String LASTNAME_FIELD = "last_name";
+ private static final String USERID_FIELD = "user_id";
@JsonProperty(PHONENUMBER_FIELD)
private String phoneNumber; ///< Contact's phone number
@JsonProperty(FIRSTNAME_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Document.java b/src/main/java/org/telegram/telegrambots/api/objects/Document.java
index ac99134e..d8ddf177 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Document.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Document.java
@@ -19,11 +19,11 @@ import java.io.IOException;
*/
public class Document implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
- public static final String THUMB_FIELD = "thumb";
- public static final String FILENAME_FIELD = "file_name";
- public static final String MIMETYPE_FIELD = "mime_type";
- public static final String FILESIZE_FIELD = "file_size";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String THUMB_FIELD = "thumb";
+ private static final String FILENAME_FIELD = "file_name";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
@JsonProperty(THUMB_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/EntityType.java b/src/main/java/org/telegram/telegrambots/api/objects/EntityType.java
new file mode 100644
index 00000000..f6308e80
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/EntityType.java
@@ -0,0 +1,24 @@
+package org.telegram.telegrambots.api.objects;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Types of messages entities
+ * @date 10 of April of 2016
+ */
+public class EntityType {
+ public static final String MENTION = "mention"; ///< @username
+ public static final String HASHTAG = "hashtag"; ///< #hashtag
+ public static final String BOTCOMMAND = "bot_command"; ///< /botcommand
+ public static final String URL = "url"; ///< http://url.url
+ public static final String EMAIL = "email"; ///< email@email.com
+ public static final String BOLD = "bold"; ///< Bold text
+ public static final String ITALIC = "italic"; ///< Italic text
+ public static final String CODE = "code"; ///< Monowidth string
+ public static final String PRE = "pre"; ///< Monowidth block
+ public static final String TEXTLINK = "text_link"; ///< Clickable urls
+
+ private EntityType() {
+ }
+}
+
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/File.java b/src/main/java/org/telegram/telegrambots/api/objects/File.java
index 8fb48f37..7b7a3289 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/File.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/File.java
@@ -17,9 +17,9 @@ import java.io.IOException;
* @date 24 of June of 2015
*/
public class File implements IBotApiObject {
- public static final String FILE_ID = "file_id";
- public static final String FILE_SIZE_FIELD = "file_size";
- public static final String FILE_PATH_FIELD = "file_path";
+ private static final String FILE_ID = "file_id";
+ private static final String FILE_SIZE_FIELD = "file_size";
+ private static final String FILE_PATH_FIELD = "file_path";
@JsonProperty(FILE_ID)
private String fileId; ///< Unique identifier for this file
@JsonProperty(FILE_SIZE_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Location.java b/src/main/java/org/telegram/telegrambots/api/objects/Location.java
index a8944999..4602745d 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Location.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Location.java
@@ -18,8 +18,8 @@ import java.io.IOException;
*/
public class Location implements IBotApiObject {
- public static final String LONGITUDE_FIELD = "longitude";
- public static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String LATITUDE_FIELD = "latitude";
@JsonProperty(LONGITUDE_FIELD)
private Double longitude; ///< Longitude as defined by sender
@JsonProperty(LATITUDE_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Message.java b/src/main/java/org/telegram/telegrambots/api/objects/Message.java
index 59f2e571..b404e2ba 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Message.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Message.java
@@ -20,38 +20,41 @@ import java.util.List;
* @date 20 of June of 2015
*/
public class Message implements IBotApiObject {
- public static final String MESSAGEID_FIELD = "message_id";
- public static final String FROM_FIELD = "from";
- public static final String DATE_FIELD = "date";
- public static final String CHAT_FIELD = "chat";
- public static final String FORWARDFROM_FIELD = "forward_from";
- public static final String FORWARDDATE_FIELD = "forward_date";
- public static final String TEXT_FIELD = "text";
- public static final String AUDIO_FIELD = "audio";
- public static final String DOCUMENT_FIELD = "document";
- public static final String PHOTO_FIELD = "photo";
- public static final String STICKER_FIELD = "sticker";
- public static final String VIDEO_FIELD = "video";
- public static final String CONTACT_FIELD = "contact";
- public static final String LOCATION_FIELD = "location";
- public static final String NEWCHATPARTICIPANT_FIELD = "new_chat_participant";
- public static final String LEFTCHATPARTICIPANT_FIELD = "left_chat_participant";
- public static final String NEWCHATTITLE_FIELD = "new_chat_title";
- public static final String NEWCHATPHOTO_FIELD = "new_chat_photo";
- public static final String DELETECHATPHOTO_FIELD = "delete_chat_photo";
- public static final String GROUPCHATCREATED_FIELD = "group_chat_created";
- public static final String REPLYTOMESSAGE_FIELD = "reply_to_message";
- public static final String VOICE_FIELD = "voice";
- public static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created";
- public static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
- public static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
- public static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
+ private static final String FROM_FIELD = "from";
+ private static final String DATE_FIELD = "date";
+ private static final String CHAT_FIELD = "chat";
+ private static final String FORWARDFROM_FIELD = "forward_from";
+ private static final String FORWARDDATE_FIELD = "forward_date";
+ private static final String TEXT_FIELD = "text";
+ private static final String ENTITIES_FIELD = "entities";
+ private static final String AUDIO_FIELD = "audio";
+ private static final String DOCUMENT_FIELD = "document";
+ private static final String PHOTO_FIELD = "photo";
+ private static final String STICKER_FIELD = "sticker";
+ private static final String VIDEO_FIELD = "video";
+ private static final String CONTACT_FIELD = "contact";
+ private static final String LOCATION_FIELD = "location";
+ private static final String VENUE_FIELD = "venue";
+ private static final String PINNED_MESSAGE_FIELD = "pinned_message";
+ private static final String NEWCHATMEMBER_FIELD = "new_chat_member";
+ private static final String LEFTCHATMEMBER_FIELD = "left_chat_member";
+ private static final String NEWCHATTITLE_FIELD = "new_chat_title";
+ private static final String NEWCHATPHOTO_FIELD = "new_chat_photo";
+ private static final String DELETECHATPHOTO_FIELD = "delete_chat_photo";
+ private static final String GROUPCHATCREATED_FIELD = "group_chat_created";
+ private static final String REPLYTOMESSAGE_FIELD = "reply_to_message";
+ private static final String VOICE_FIELD = "voice";
+ private static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created";
+ private static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
+ private static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
+ private static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@JsonProperty(FROM_FIELD)
private User from; ///< Optional. Sender, can be empty for messages sent to channels
@JsonProperty(DATE_FIELD)
- private Integer date; ///< Date the message was sent in Unix time
+ private Integer date; ///< Optional. Date the message was sent in Unix time
@JsonProperty(CHAT_FIELD)
private Chat chat; ///< Conversation the message belongs to
@JsonProperty(FORWARDFROM_FIELD)
@@ -60,6 +63,12 @@ public class Message implements IBotApiObject {
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
@JsonProperty(TEXT_FIELD)
private String text; ///< Optional. For text messages, the actual UTF-8 text of the message
+ @JsonProperty(ENTITIES_FIELD)
+ /**
+ * Optional. For text messages, special entities like usernames, URLs,
+ * bot commands, etc. that appear in the text
+ */
+ private List entities;
@JsonProperty(AUDIO_FIELD)
private Audio audio; ///< Optional. Message is an audio file, information about the file
@JsonProperty(DOCUMENT_FIELD)
@@ -74,10 +83,14 @@ public class Message implements IBotApiObject {
private Contact contact; ///< Optional. Message is a shared contact, information about the contact
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Optional. Message is a shared location, information about the location
- @JsonProperty(NEWCHATPARTICIPANT_FIELD)
- private User newChatParticipant; ///< Optional. A new member was added to the group, information about them (this member may be bot itself)
- @JsonProperty(LEFTCHATPARTICIPANT_FIELD)
- private User leftChatParticipant; ///< Optional. A member was removed from the group, information about them (this member may be bot itself)
+ @JsonProperty(VENUE_FIELD)
+ private Venue venue; ///< Optional. Message is a venue, information about the venue
+ @JsonProperty(PINNED_MESSAGE_FIELD)
+ private Message pinnedMessage; ///< Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
+ @JsonProperty(NEWCHATMEMBER_FIELD)
+ private User newChatMember; ///< Optional. A new member was added to the group, information about them (this member may be bot itself)
+ @JsonProperty(LEFTCHATMEMBER_FIELD)
+ private User leftChatMember; ///< Optional. A member was removed from the group, information about them (this member may be bot itself)
@JsonProperty(NEWCHATTITLE_FIELD)
private String newChatTitle; ///< Optional. A chat title was changed to this value
@JsonProperty(NEWCHATPHOTO_FIELD)
@@ -109,7 +122,9 @@ public class Message implements IBotApiObject {
if (jsonObject.has(FROM_FIELD)) {
this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
}
- this.date = jsonObject.getInt(DATE_FIELD);
+ if (jsonObject.has(DATE_FIELD)) {
+ this.date = jsonObject.getInt(DATE_FIELD);
+ }
this.chat = new Chat(jsonObject.getJSONObject(CHAT_FIELD));
if (jsonObject.has(FORWARDFROM_FIELD)) {
this.forwardFrom = new User(jsonObject.getJSONObject(FORWARDFROM_FIELD));
@@ -120,6 +135,13 @@ public class Message implements IBotApiObject {
if (jsonObject.has(TEXT_FIELD)) {
this.text = jsonObject.getString(TEXT_FIELD);
}
+ if (jsonObject.has(ENTITIES_FIELD)) {
+ this.entities = new ArrayList<>();
+ JSONArray entities = jsonObject.getJSONArray(ENTITIES_FIELD);
+ for (int i = 0; i < entities.length(); i++) {
+ this.entities.add(new MessageEntity(entities.getJSONObject(i)));
+ }
+ }
if (jsonObject.has(AUDIO_FIELD)) {
this.audio = new Audio(jsonObject.getJSONObject(AUDIO_FIELD));
}
@@ -145,14 +167,20 @@ public class Message implements IBotApiObject {
if (jsonObject.has(LOCATION_FIELD)) {
this.location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
}
+ if (jsonObject.has(VENUE_FIELD)) {
+ venue = new Venue(jsonObject.getJSONObject(VENUE_FIELD));
+ }
+ if (jsonObject.has(PINNED_MESSAGE_FIELD)) {
+ pinnedMessage = new Message(jsonObject.getJSONObject(PINNED_MESSAGE_FIELD));
+ }
if (jsonObject.has(VOICE_FIELD)) {
this.voice = new Voice(jsonObject.getJSONObject(VOICE_FIELD));
}
- if (jsonObject.has(NEWCHATPARTICIPANT_FIELD)) {
- this.newChatParticipant = new User(jsonObject.getJSONObject(NEWCHATPARTICIPANT_FIELD));
+ if (jsonObject.has(NEWCHATMEMBER_FIELD)) {
+ this.newChatMember = new User(jsonObject.getJSONObject(NEWCHATMEMBER_FIELD));
}
- if (jsonObject.has(LEFTCHATPARTICIPANT_FIELD)) {
- this.leftChatParticipant = new User(jsonObject.getJSONObject(LEFTCHATPARTICIPANT_FIELD));
+ if (jsonObject.has(LEFTCHATMEMBER_FIELD)) {
+ this.leftChatMember = new User(jsonObject.getJSONObject(LEFTCHATMEMBER_FIELD));
}
if (jsonObject.has(REPLYTOMESSAGE_FIELD)) {
this.replyToMessage = new Message(jsonObject.getJSONObject(REPLYTOMESSAGE_FIELD));
@@ -327,20 +355,20 @@ public class Message implements IBotApiObject {
this.location = location;
}
- public User getNewChatParticipant() {
- return newChatParticipant;
+ public User getNewChatMember() {
+ return newChatMember;
}
- public void setNewChatParticipant(User newChatParticipant) {
- this.newChatParticipant = newChatParticipant;
+ public void setNewChatMember(User newChatMember) {
+ this.newChatMember = newChatMember;
}
- public User getLeftChatParticipant() {
- return leftChatParticipant;
+ public User getLeftChatMember() {
+ return leftChatMember;
}
- public void setLeftChatParticipant(User leftChatParticipant) {
- this.leftChatParticipant = leftChatParticipant;
+ public void setLeftChatMember(User leftChatMember) {
+ this.leftChatMember = leftChatMember;
}
public String getNewChatTitle() {
@@ -438,12 +466,14 @@ public class Message implements IBotApiObject {
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
-
gen.writeNumberField(MESSAGEID_FIELD, messageId);
- gen.writeObjectField(FROM_FIELD, from);
- gen.writeNumberField(DATE_FIELD, date);
+ if (from != null) {
+ gen.writeObjectField(FROM_FIELD, from);
+ }
+ if (date != null) {
+ gen.writeNumberField(DATE_FIELD, date);
+ }
gen.writeObjectField(CHAT_FIELD, chat);
-
if (forwardFrom != null) {
gen.writeObjectField(FORWARDFROM_FIELD, forwardFrom);
}
@@ -478,14 +508,17 @@ public class Message implements IBotApiObject {
if (location != null) {
gen.writeObjectField(LOCATION_FIELD, location);
}
+ if (venue != null) {
+ gen.writeObjectField(VENUE_FIELD, venue);
+ }
if (voice != null) {
gen.writeObjectField(VOICE_FIELD, voice);
}
- if (newChatParticipant != null) {
- gen.writeObjectField(NEWCHATPARTICIPANT_FIELD, newChatParticipant);
+ if (newChatMember != null) {
+ gen.writeObjectField(NEWCHATMEMBER_FIELD, newChatMember);
}
- if (leftChatParticipant != null) {
- gen.writeObjectField(LEFTCHATPARTICIPANT_FIELD, leftChatParticipant);
+ if (leftChatMember != null) {
+ gen.writeObjectField(LEFTCHATMEMBER_FIELD, leftChatMember);
}
if (replyToMessage != null) {
gen.writeObjectField(REPLYTOMESSAGE_FIELD, replyToMessage);
@@ -544,8 +577,9 @@ public class Message implements IBotApiObject {
", video=" + video +
", contact=" + contact +
", location=" + location +
- ", newChatParticipant=" + newChatParticipant +
- ", leftChatParticipant=" + leftChatParticipant +
+ ", venue=" + venue +
+ ", newChatMember=" + newChatMember +
+ ", leftChatMember=" + leftChatMember +
", newChatTitle='" + newChatTitle + '\'' +
", newChatPhoto=" + newChatPhoto +
", deleteChatPhoto=" + deleteChatPhoto +
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/MessageEntity.java b/src/main/java/org/telegram/telegrambots/api/objects/MessageEntity.java
new file mode 100644
index 00000000..b436f51f
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/MessageEntity.java
@@ -0,0 +1,105 @@
+package org.telegram.telegrambots.api.objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents one special entity in a text message. For example, hashtags,
+ * usernames, URL.
+ * @date 20 of June of 2015
+ */
+public class MessageEntity implements IBotApiObject {
+
+ private static final String TYPE_FIELD = "type";
+ private static final String OFFSET_FIELD = "offset";
+ private static final String LENGTH_FIELD = "length";
+ private static final String URL_FIELD = "url";
+ @JsonProperty(TYPE_FIELD)
+ /**
+ * Type of the entity. One of
+ * mention (@username),
+ * hashtag,
+ * bot_command,
+ * url,
+ * email,
+ * bold (bold text),
+ * italic (italic text),
+ * code (monowidth string),
+ * pre (monowidth block),
+ * text_link (for clickable text URLs)
+ */
+ private String type;
+ @JsonProperty(OFFSET_FIELD)
+ private Integer offset; ///< Offset in UTF-16 code units to the start of the entity
+ @JsonProperty(LENGTH_FIELD)
+ private Integer length; ///< Length of the entity in UTF-16 code units
+ @JsonProperty(URL_FIELD)
+ private String url; ///< Optional. For “text_link” only, url that will be opened after user taps on the text
+
+ public MessageEntity() {
+ super();
+ }
+
+ public MessageEntity(JSONObject jsonObject) {
+ super();
+ this.type = jsonObject.getString(TYPE_FIELD);
+ this.offset = jsonObject.getInt(OFFSET_FIELD);
+ this.length = jsonObject.getInt(LENGTH_FIELD);
+ if (EntityType.TEXTLINK.equals(type)) {
+ this.url = jsonObject.getString(URL_FIELD);
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public Integer getOffset() {
+ return offset;
+ }
+
+ public Integer getLength() {
+ return length;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeNumberField(OFFSET_FIELD, offset);
+ gen.writeNumberField(LENGTH_FIELD, length);
+ if (url != null && EntityType.TEXTLINK.equals(type)) {
+ gen.writeStringField(URL_FIELD, url);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "PhotoSize{" +
+ "type='" + type + '\'' +
+ ", offset=" + offset +
+ ", length=" + length +
+ ", url=" + url +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/PhotoSize.java b/src/main/java/org/telegram/telegrambots/api/objects/PhotoSize.java
index 5939ef85..3db4f6e9 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/PhotoSize.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/PhotoSize.java
@@ -18,19 +18,19 @@ import java.io.IOException;
*/
public class PhotoSize implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String WIDTH_FIELD = "width";
+ private static final String HEIGHT_FIELD = "height";
+ private static final String FILESIZE_FIELD = "file_size";
+ private static final String FILEPATH_FIELD = "file_path";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
- public static final String WIDTH_FIELD = "width";
@JsonProperty(WIDTH_FIELD)
private Integer width; ///< Photo width
- public static final String HEIGHT_FIELD = "height";
@JsonProperty(HEIGHT_FIELD)
private Integer height; ///< Photo height
- public static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size
- private static final String FILEPATH_FIELD = "file_path";
@JsonProperty(FILEPATH_FIELD)
private String filePath; ///< Undocumented field. Optional. Can contain the path to download the file direclty without calling to getFile
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java b/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java
index b8a0a1d8..400b1cce 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java
@@ -18,11 +18,11 @@ import java.io.IOException;
*/
public class Sticker implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
- public static final String WIDTH_FIELD = "width";
- public static final String HEIGHT_FIELD = "height";
- public static final String THUMB_FIELD = "thumb";
- public static final String FILESIZE_FIELD = "file_size";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String WIDTH_FIELD = "width";
+ private static final String HEIGHT_FIELD = "height";
+ private static final String THUMB_FIELD = "thumb";
+ private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
@JsonProperty(WIDTH_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Update.java b/src/main/java/org/telegram/telegrambots/api/objects/Update.java
index a766ed5f..ade89d87 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Update.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Update.java
@@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.objects.inlinequery.ChosenInlineQuery;
+import org.telegram.telegrambots.api.objects.inlinequery.InlineQuery;
import java.io.IOException;
@@ -18,10 +20,11 @@ import java.io.IOException;
* @date 20 of June of 2015
*/
public class Update implements IBotApiObject {
- public static final String UPDATEID_FIELD = "update_id";
- public static final String MESSAGE_FIELD = "message";
- public static final String INLINEQUERY_FIELD = "inline_query";
- public static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
+ private static final String UPDATEID_FIELD = "update_id";
+ private static final String MESSAGE_FIELD = "message";
+ private static final String INLINEQUERY_FIELD = "inline_query";
+ private static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
+ private static final String CALLBACKQUERY_FIELD = "callback_query";
@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
@JsonProperty(MESSAGE_FIELD)
@@ -30,10 +33,8 @@ public class Update implements IBotApiObject {
private InlineQuery inlineQuery; ///< Optional. New incoming inline query
@JsonProperty(CHOSENINLINEQUERY_FIELD)
private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner
-
- /*
- ChosenInlineResult
- */
+ @JsonProperty(CALLBACKQUERY_FIELD)
+ private CallbackQuery callbackQuery; ///< Optional. New incoming callback query
public Update() {
super();
@@ -51,6 +52,9 @@ public class Update implements IBotApiObject {
if (jsonObject.has(CHOSENINLINEQUERY_FIELD)) {
this.chosenInlineQuery = new ChosenInlineQuery(jsonObject.getJSONObject(CHOSENINLINEQUERY_FIELD));
}
+ if (jsonObject.has(CALLBACKQUERY_FIELD)) {
+ callbackQuery = new CallbackQuery(jsonObject.getJSONObject(CALLBACKQUERY_FIELD));
+ }
}
public Integer getUpdateId() {
@@ -69,6 +73,10 @@ public class Update implements IBotApiObject {
return chosenInlineQuery;
}
+ public CallbackQuery getCallbackQuery() {
+ return callbackQuery;
+ }
+
public boolean hasMessage() {
return message != null;
}
@@ -81,6 +89,10 @@ public class Update implements IBotApiObject {
return chosenInlineQuery != null;
}
+ public boolean hasCallbackQuery() {
+ return callbackQuery != null;
+ }
+
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
@@ -94,6 +106,9 @@ public class Update implements IBotApiObject {
if (chosenInlineQuery != null) {
gen.writeObjectField(CHOSENINLINEQUERY_FIELD, chosenInlineQuery);
}
+ if (callbackQuery != null) {
+ gen.writeObjectField(CALLBACKQUERY_FIELD, callbackQuery);
+ }
gen.writeEndObject();
gen.flush();
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/User.java b/src/main/java/org/telegram/telegrambots/api/objects/User.java
index 57969237..701aea85 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/User.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/User.java
@@ -18,10 +18,10 @@ import java.io.IOException;
*/
public class User implements IBotApiObject {
- public static final String ID_FIELD = "id";
- public static final String FIRSTNAME_FIELD = "first_name";
- public static final String LASTNAME_FIELD = "last_name";
- public static final String USERNAME_FIELD = "username";
+ private static final String ID_FIELD = "id";
+ private static final String FIRSTNAME_FIELD = "first_name";
+ private static final String LASTNAME_FIELD = "last_name";
+ private static final String USERNAME_FIELD = "username";
@JsonProperty(ID_FIELD)
private Integer id; ///< Unique identifier for this user or bot
@JsonProperty(FIRSTNAME_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java b/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java
index c5551b7d..6369a9b5 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java
@@ -21,8 +21,8 @@ import java.util.List;
*/
public class UserProfilePhotos implements IBotApiObject {
- public static final String TOTALCOUNT_FIELD = "total_count";
- public static final String PHOTOS_FIELD = "photos";
+ private static final String TOTALCOUNT_FIELD = "total_count";
+ private static final String PHOTOS_FIELD = "photos";
@JsonProperty(TOTALCOUNT_FIELD)
private Integer totalCount; ///< Total number of profile pictures the target user has
@JsonProperty(PHOTOS_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Venue.java b/src/main/java/org/telegram/telegrambots/api/objects/Venue.java
new file mode 100644
index 00000000..7bfd6b4b
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Venue.java
@@ -0,0 +1,92 @@
+package org.telegram.telegrambots.api.objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents a venue.
+ * @date 10 of April of 2016
+ */
+public class Venue implements IBotApiObject {
+ private static final String LOCATION_FIELD = "location";
+ private static final String TITLE_FIELD = "title";
+ private static final String ADDRESS_FIELD = "address";
+ private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
+
+ @JsonProperty(LOCATION_FIELD)
+ private Location location; ///< Venue location
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Name of the venue
+ @JsonProperty(ADDRESS_FIELD)
+ private String address; ///< Address of the venue
+ @JsonProperty(FOURSQUARE_ID_FIELD)
+ private String foursquareId; ///< Optional. Foursquare identifier of the venue
+
+
+ public Venue() {
+ super();
+ }
+
+ public Venue(JSONObject jsonObject) {
+ super();
+ location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
+ title = jsonObject.getString(TITLE_FIELD);
+ address = jsonObject.getString(ADDRESS_FIELD);
+ if (jsonObject.has(FOURSQUARE_ID_FIELD)) {
+ foursquareId = jsonObject.getString(FOURSQUARE_ID_FIELD);
+ }
+ }
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public String getFoursquareId() {
+ return foursquareId;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeObjectField(LOCATION_FIELD, location);
+ gen.writeStringField(TITLE_FIELD, title);
+ gen.writeStringField(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "Venue{" +
+ "location=" + location +
+ ", title=" + title +
+ ", address=" + address +
+ ", foursquareId=" + foursquareId +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Video.java b/src/main/java/org/telegram/telegrambots/api/objects/Video.java
index 844a262e..9ccccf35 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Video.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Video.java
@@ -18,13 +18,13 @@ import java.io.IOException;
*/
public class Video implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
- public static final String WIDTH_FIELD = "width";
- public static final String HEIGHT_FIELD = "height";
- public static final String DURATION_FIELD = "duration";
- public static final String THUMB_FIELD = "thumb";
- public static final String MIMETYPE_FIELD = "mime_type";
- public static final String FILESIZE_FIELD = "file_size";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String WIDTH_FIELD = "width";
+ private static final String HEIGHT_FIELD = "height";
+ private static final String DURATION_FIELD = "duration";
+ private static final String THUMB_FIELD = "thumb";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
@JsonProperty(WIDTH_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Voice.java b/src/main/java/org/telegram/telegrambots/api/objects/Voice.java
index ae82b653..ffa4a640 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/Voice.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/Voice.java
@@ -17,10 +17,10 @@ import java.io.IOException;
* @date 16 of July of 2015
*/
public class Voice implements IBotApiObject {
- public static final String FILEID_FIELD = "file_id";
- public static final String DURATION_FIELD = "duration";
- public static final String MIMETYPE_FIELD = "mime_type";
- public static final String FILESIZE_FIELD = "file_size";
+ private static final String FILEID_FIELD = "file_id";
+ private static final String DURATION_FIELD = "duration";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file
@JsonProperty(DURATION_FIELD)
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/ChosenInlineQuery.java
similarity index 53%
rename from src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/ChosenInlineQuery.java
index 974aaea4..f5ead3fb 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/ChosenInlineQuery.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -7,24 +7,39 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.objects.Location;
+import org.telegram.telegrambots.api.objects.User;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief This object represents a result of an inline query that was chosen by the user and sent to their chat partner.
+ * @brief Represents a result of an inline query that was chosen by the user and sent to their chat
+ * partner.
* @date 01 of January of 2016
*/
public class ChosenInlineQuery implements IBotApiObject {
- public static final String RESULTID_FIELD = "result_id";
- public static final String FROM_FIELD = "from";
- public static final String QUERY_FIELD = "query";
+ private static final String RESULTID_FIELD = "result_id";
+ private static final String FROM_FIELD = "from";
+ private static final String LOCATION_FIELD = "location";
+ private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
+ private static final String QUERY_FIELD = "query";
@JsonProperty(RESULTID_FIELD)
private String resultId; ///< The unique identifier for the result that was chosen.
@JsonProperty(FROM_FIELD)
private User from; ///< The user that chose the result.
+ @JsonProperty(LOCATION_FIELD)
+ private Location location; ///< Optional. Sender location, only for bots that require user location
+ @JsonProperty(INLINE_MESSAGE_ID_FIELD)
+ /**
+ * Optional.
+ * Identifier of the sent inline message.
+ * Available only if there is an inline keyboard attached to the message.
+ * Will be also received in callback queries and can be used to edit the message.
+ */
+ private String inlineMessageId;
@JsonProperty(QUERY_FIELD)
private String query; ///< The query that was used to obtain the result.
@@ -36,6 +51,12 @@ public class ChosenInlineQuery implements IBotApiObject {
super();
this.resultId = jsonObject.getString(RESULTID_FIELD);
this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
+ if (jsonObject.has(LOCATION_FIELD)) {
+ location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
+ }
+ if (jsonObject.has(INLINE_MESSAGE_ID_FIELD)) {
+ inlineMessageId = jsonObject.getString(INLINE_MESSAGE_ID_FIELD);
+ }
this.query = jsonObject.getString(QUERY_FIELD);
}
@@ -51,11 +72,25 @@ public class ChosenInlineQuery implements IBotApiObject {
return query;
}
+ public Location getLocation() {
+ return location;
+ }
+
+ public String getInlineMessageId() {
+ return inlineMessageId;
+ }
+
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(RESULTID_FIELD, resultId);
gen.writeObjectField(FROM_FIELD, from);
+ if (location != null) {
+ gen.writeObjectField(LOCATION_FIELD, location);
+ }
+ if (inlineMessageId != null) {
+ gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
+ }
gen.writeStringField(QUERY_FIELD, query);
gen.writeEndObject();
gen.flush();
@@ -71,6 +106,8 @@ public class ChosenInlineQuery implements IBotApiObject {
return "ChosenInlineQuery{" +
"resultId='" + resultId + '\'' +
", from=" + from +
+ ", location=" + location +
+ ", inlineMessageId=" + inlineMessageId +
", query='" + query + '\'' +
'}';
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/InlineQuery.java
similarity index 67%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/InlineQuery.java
index 13fe16ae..60ec2317 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/InlineQuery.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -7,25 +7,30 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.objects.Location;
+import org.telegram.telegrambots.api.objects.User;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief This object represents an incoming inline query.
- * When the user sends an empty query, your bot could return some default or trending results.
+ * @brief This object represents an incoming inline query. When the user sends an empty query, your
+ * bot could return some default or trending results.
* @date 01 of January of 2016
*/
public class InlineQuery implements IBotApiObject {
- public static final String ID_FIELD = "id";
- public static final String FROM_FIELD = "from";
- public static final String QUERY_FIELD = "query";
- public static final String OFFSET_FIELD = "offset";
+ private static final String ID_FIELD = "id";
+ private static final String FROM_FIELD = "from";
+ private static final String LOCATION_FIELD = "location";
+ private static final String QUERY_FIELD = "query";
+ private static final String OFFSET_FIELD = "offset";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier for this query
@JsonProperty(FROM_FIELD)
private User from; ///< Sender
+ @JsonProperty(LOCATION_FIELD)
+ private Location location; ///< Optional. Sender location, only for bots that request user location
@JsonProperty(QUERY_FIELD)
private String query; ///< Text of the query
@JsonProperty(OFFSET_FIELD)
@@ -39,6 +44,9 @@ public class InlineQuery implements IBotApiObject {
super();
this.id = jsonObject.getString(ID_FIELD);
this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
+ if (jsonObject.has(LOCATION_FIELD)) {
+ location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
+ }
this.query = jsonObject.getString(QUERY_FIELD);
this.offset = jsonObject.getString(OFFSET_FIELD);
}
@@ -48,6 +56,9 @@ public class InlineQuery implements IBotApiObject {
gen.writeStartObject();
gen.writeStringField(ID_FIELD, id);
gen.writeObjectField(FROM_FIELD, from);
+ if (location != null) {
+ gen.writeObjectField(LOCATION_FIELD, location);
+ }
gen.writeStringField(QUERY_FIELD, query);
gen.writeStringField(OFFSET_FIELD, offset);
gen.writeEndObject();
@@ -62,6 +73,10 @@ public class InlineQuery implements IBotApiObject {
return from;
}
+ public Location getLocation() {
+ return location;
+ }
+
public String getQuery() {
return query;
}
@@ -80,6 +95,7 @@ public class InlineQuery implements IBotApiObject {
return "InlineQuery{" +
"id='" + id + '\'' +
", from=" + from +
+ ", location=" + location +
", query='" + query + '\'' +
", offset='" + offset + '\'' +
'}';
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java
new file mode 100644
index 00000000..f4515340
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java
@@ -0,0 +1,96 @@
+package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents the content of a contact message to be sent as the result of an inline query
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InputContactMessageContent implements InputMessageContent {
+
+ private static final String PHONE_NUMBER_FIELD = "phone_number";
+ private static final String FIRST_NAME_FIELD = "first_name";
+ private static final String LAST_NAME_FIELD = "last_name";
+ @JsonProperty(PHONE_NUMBER_FIELD)
+ private String phoneNumber; ///< Contact's phone number
+ @JsonProperty(FIRST_NAME_FIELD)
+ private String firstName; ///< Contact's first name
+ @JsonProperty(LAST_NAME_FIELD)
+ private String lastName; ///< Optional. Contact's last name
+
+ public InputContactMessageContent() {
+ super();
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
+ jsonObject.put(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ jsonObject.put(LAST_NAME_FIELD, lastName);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
+ gen.writeStringField(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ gen.writeStringField(LAST_NAME_FIELD, lastName);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InputContactMessageContent{" +
+ "phoneNumber='" + phoneNumber + '\'' +
+ ", firstName='" + firstName + '\'' +
+ ", lastName='" + lastName + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java
new file mode 100644
index 00000000..59bb84c1
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java
@@ -0,0 +1,78 @@
+package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents the content of a location message to be sent as the result of an inline query.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InputLocationMessageContent implements InputMessageContent {
+
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ @JsonProperty(LATITUDE_FIELD)
+ private Float latitude; ///< Latitude of the location in degrees
+ @JsonProperty(LONGITUDE_FIELD)
+ private Float longitude; ///< Longitude of the location in degrees
+
+ public InputLocationMessageContent() {
+ super();
+ }
+
+ public Float getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(Float latitude) {
+ this.latitude = latitude;
+ }
+
+ public Float getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(Float longitude) {
+ this.longitude = longitude;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(LATITUDE_FIELD, latitude);
+ jsonObject.put(LONGITUDE_FIELD, longitude);
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeNumberField(LATITUDE_FIELD, latitude);
+ gen.writeNumberField(LONGITUDE_FIELD, longitude);
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InputLocationMessageContent{" +
+ "latitude='" + latitude + '\'' +
+ ", longitude='" + longitude + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputMessageContent.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputMessageContent.java
new file mode 100644
index 00000000..c9e59e77
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputMessageContent.java
@@ -0,0 +1,14 @@
+package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
+
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.interfaces.IToJson;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents the content of a message to be sent as a result of an inline
+ * query.
+ * @date 10 of April of 2016
+ */
+public interface InputMessageContent extends IBotApiObject, IToJson {
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java
new file mode 100644
index 00000000..47960b6a
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java
@@ -0,0 +1,116 @@
+package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.methods.ParseMode;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents the content of a text message to be sent as the result of an inline query.
+ * @date 10 of April of 2016
+ */
+public class InputTextMessageContent implements InputMessageContent {
+
+ private static final String MESSAGETEXT_FIELD = "message_text";
+ private static final String PARSEMODE_FIELD = "parse_mode";
+ private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
+ @JsonProperty(MESSAGETEXT_FIELD)
+ private String messageText; ///< Text of a message to be sent, 1-4096 characters
+ @JsonProperty(PARSEMODE_FIELD)
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
+ @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
+ private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
+
+ public InputTextMessageContent() {
+ super();
+ }
+
+ public String getMessageText() {
+ return messageText;
+ }
+
+ public void setMessageText(String messageText) {
+ this.messageText = messageText;
+ }
+
+ public String getParseMode() {
+ return parseMode;
+ }
+
+ public void enableMarkdown(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.MARKDOWN;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ public void enableHtml(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.HTML;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ public Boolean getDisableWebPagePreview() {
+ return disableWebPagePreview;
+ }
+
+ public void disableWebPagePreview() {
+ disableWebPagePreview = true;
+ }
+
+ public void enableWebPagePreview() {
+ disableWebPagePreview = null;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
+ if (parseMode != null) {
+ jsonObject.put(PARSEMODE_FIELD, this.parseMode);
+ }
+ if (disableWebPagePreview != null) {
+ jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(MESSAGETEXT_FIELD, messageText);
+ if (parseMode != null) {
+ gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
+ }
+ if (disableWebPagePreview != null) {
+ gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InputTextMessageContent{" +
+ ", messageText='" + messageText + '\'' +
+ ", parseMode='" + parseMode + '\'' +
+ ", disableWebPagePreview=" + disableWebPagePreview +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java
new file mode 100644
index 00000000..f2f02115
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java
@@ -0,0 +1,124 @@
+package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents the content of a venue message to be sent as the result of an inline query.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InputVenueMessageContent implements InputMessageContent {
+
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String TITLE_FIELD = "title";
+ private static final String ADDRESS_FIELD = "address";
+ private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
+ @JsonProperty(LATITUDE_FIELD)
+ private Float latitude; ///< Latitude of the venue in degrees
+ @JsonProperty(LONGITUDE_FIELD)
+ private Float longitude; ///< Longitude of the venue in degrees
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Name of the venue
+ @JsonProperty(ADDRESS_FIELD)
+ private String address; ///< Address of the venue
+ @JsonProperty(FOURSQUARE_ID_FIELD)
+ private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known
+
+ public InputVenueMessageContent() {
+ super();
+ }
+
+ public Float getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(Float latitude) {
+ this.latitude = latitude;
+ }
+
+ public Float getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(Float longitude) {
+ this.longitude = longitude;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getFoursquareId() {
+ return foursquareId;
+ }
+
+ public void setFoursquareId(String foursquareId) {
+ this.foursquareId = foursquareId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(LATITUDE_FIELD, latitude);
+ jsonObject.put(LONGITUDE_FIELD, longitude);
+ jsonObject.put(TITLE_FIELD, title);
+ jsonObject.put(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeNumberField(LATITUDE_FIELD, latitude);
+ gen.writeNumberField(LONGITUDE_FIELD, longitude);
+ gen.writeStringField(TITLE_FIELD, title);
+ gen.writeStringField(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InputVenueMessageContent{" +
+ "latitude='" + latitude + '\'' +
+ ", longitude='" + longitude + '\'' +
+ ", title='" + title + '\'' +
+ ", address='" + address + '\'' +
+ ", foursquareId='" + foursquareId + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResult.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResult.java
similarity index 83%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResult.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResult.java
index 6480f4f2..f2110710 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResult.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResult.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.interfaces.IToJson;
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultArticle.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultArticle.java
similarity index 63%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultArticle.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultArticle.java
index d8305831..fa7a9c6a 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultArticle.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultArticle.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
@@ -17,40 +19,37 @@ import java.io.IOException;
*/
public class InlineQueryResultArticle implements InlineQueryResult {
- public static final String TYPE_FIELD = "type";
+ private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
- private final String type = "article"; ///< Type of the result, must be “article”
- public static final String ID_FIELD = "id";
+ private static final String type = "article"; ///< Type of the result, must be “article”
+ private static final String ID_FIELD = "id";
+ private static final String TITLE_FIELD = "title";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String URL_FIELD = "url";
+ private static final String HIDEURL_FIELD = "hide_url";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String THUMBWIDTH_FIELD = "thumb_width";
+ private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD)
- private String id; ///< Unique identifier of this result
- public static final String TITLE_FIELD = "title";
+ private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(TITLE_FIELD)
private String title; ///< Title of the result
- public static final String MESSAGETEXT_FIELD = "message_text";
- @JsonProperty(MESSAGETEXT_FIELD)
- private String messageText; ///< Text of a message to be sent, 1-4096 characters
- public static final String PARSEMODE_FIELD = "parse_mode";
- @JsonProperty(PARSEMODE_FIELD)
- private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
- @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
- private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
- public static final String URL_FIELD = "url";
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Content of the message to be sent
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(URL_FIELD)
private String url; ///< Optional. URL of the result
- public static final String HIDEURL_FIELD = "hide_url";
@JsonProperty(HIDEURL_FIELD)
private Boolean hideUrl; ///< Optional. Pass True, if you don't want the URL to be shown in the message
- public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
- public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. Url of the thumbnail for the result
- public static final String THUMBWIDTH_FIELD = "thumb_width";
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
- public static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@@ -74,44 +73,20 @@ public class InlineQueryResultArticle implements InlineQueryResult {
this.title = title;
}
- public String getMessageText() {
- return messageText;
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
}
- public void setMessageText(String messageText) {
- this.messageText = messageText;
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
}
- public String getParseMode() {
- return parseMode;
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
}
- public void setParseMode(String parseMode) {
- this.parseMode = parseMode;
- }
-
- public void enableMarkdown(boolean enable) {
- if (enable) {
- this.parseMode = "Markdown";
- } else {
- this.parseMode = null;
- }
- }
-
- public void enableHtml(boolean enable) {
- if (enable) {
- this.parseMode = "html";
- } else {
- this.parseMode = null;
- }
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
}
public String getUrl() {
@@ -169,12 +144,9 @@ public class InlineQueryResultArticle implements InlineQueryResult {
jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(TITLE_FIELD, this.title);
- jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
- if (parseMode != null) {
- jsonObject.put(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (url != null) {
jsonObject.put(URL_FIELD, this.url);
@@ -204,13 +176,9 @@ public class InlineQueryResultArticle implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(TITLE_FIELD, title);
- gen.writeStringField(MESSAGETEXT_FIELD, messageText);
-
- if (parseMode != null) {
- gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (url != null) {
gen.writeStringField(URL_FIELD, this.url);
@@ -246,9 +214,8 @@ public class InlineQueryResultArticle implements InlineQueryResult {
"type='" + type + '\'' +
", id='" + id + '\'' +
", title='" + title + '\'' +
- ", messageText='" + messageText + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
", url='" + url + '\'' +
", hideUrl=" + hideUrl +
", description='" + description + '\'' +
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultAudio.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultAudio.java
new file mode 100644
index 00000000..73c1c92c
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultAudio.java
@@ -0,0 +1,180 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to an mp3 audio file. By default, this audio file will be sent by the
+ * user. Alternatively, you can use input_message_content to send a message with the specified
+ * content instead of the audio.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultAudio implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "audio"; ///< Type of the result, must be "audio"
+ private static final String ID_FIELD = "id";
+ private static final String AUDIOURL_FIELD = "audio_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String PERFORMER_FIELD = "performer";
+ private static final String AUDIO_DURATION_FIELD = "audio_duration";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result
+ @JsonProperty(AUDIOURL_FIELD)
+ private String audioUrl; ///< A valid URL for the audio file
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(PERFORMER_FIELD)
+ private String performer; ///< Optional. Performer
+ @JsonProperty(AUDIO_DURATION_FIELD)
+ private Integer audioDuration; ///< Optional. Audio duration in seconds
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the audio
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getAudioUrl() {
+ return audioUrl;
+ }
+
+ public void setAudioUrl(String audioUrl) {
+ this.audioUrl = audioUrl;
+ }
+
+ public String getPerformer() {
+ return performer;
+ }
+
+ public void setPerformer(String performer) {
+ this.performer = performer;
+ }
+
+ public Integer getAudioDuration() {
+ return audioDuration;
+ }
+
+ public void setAudioDuration(Integer audioDuration) {
+ this.audioDuration = audioDuration;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(AUDIOURL_FIELD, audioUrl);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, title);
+ }
+ if (performer != null) {
+ jsonObject.put(PERFORMER_FIELD, performer);
+ }
+ if (audioDuration != null) {
+ jsonObject.put(AUDIO_DURATION_FIELD, audioDuration);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(AUDIOURL_FIELD, audioUrl);
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, title);
+ }
+ if (performer != null) {
+ gen.writeStringField(PERFORMER_FIELD, performer);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (audioDuration != null) {
+ gen.writeNumberField(AUDIO_DURATION_FIELD, audioDuration);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultAudio{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", audioUrl='" + audioUrl + '\'' +
+ ", title='" + title + '\'' +
+ ", performer=" + performer +
+ ", audioDuration=" + audioDuration +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultContact.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultContact.java
new file mode 100644
index 00000000..bcfb6fb8
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultContact.java
@@ -0,0 +1,211 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a contact with a phone number. By default, this contact will be sent by the
+ * user. Alternatively, you can use input_message_content to send a message with the specified
+ * content instead of the contact.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultContact implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "contact"; ///< Type of the result, must be "contact"
+ private static final String ID_FIELD = "id";
+ private static final String PHONE_NUMBER_FIELD = "phone_number";
+ private static final String FIRST_NAME_FIELD = "first_name";
+ private static final String LAST_NAME_FIELD = "last_name";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String THUMBWIDTH_FIELD = "thumb_width";
+ private static final String THUMBHEIGHT_FIELD = "thumb_height";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(PHONE_NUMBER_FIELD)
+ private String phoneNumber; ///< Contact's phone number
+ @JsonProperty(FIRST_NAME_FIELD)
+ private String firstName; ///< Contact's first name
+ @JsonProperty(LAST_NAME_FIELD)
+ private String lastName; ///< Contact's last name
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
+ @JsonProperty(THUMBURL_FIELD)
+ private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
+ @JsonProperty(THUMBWIDTH_FIELD)
+ private Integer thumbWidth; ///< Optional. Thumbnail width
+ @JsonProperty(THUMBHEIGHT_FIELD)
+ private Integer thumbHeight; ///< Optional. Thumbnail height
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public Integer getThumbWidth() {
+ return thumbWidth;
+ }
+
+ public void setThumbWidth(Integer thumbWidth) {
+ this.thumbWidth = thumbWidth;
+ }
+
+ public Integer getThumbHeight() {
+ return thumbHeight;
+ }
+
+ public void setThumbHeight(Integer thumbHeight) {
+ this.thumbHeight = thumbHeight;
+ }
+
+ public String getThumbUrl() {
+ return thumbUrl;
+ }
+
+ public void setThumbUrl(String thumbUrl) {
+ this.thumbUrl = thumbUrl;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
+ jsonObject.put(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ jsonObject.put(LAST_NAME_FIELD, lastName);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
+ }
+ if (thumbHeight != null) {
+ jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
+ gen.writeStringField(FIRST_NAME_FIELD, firstName);
+ if (lastName != null) {
+ gen.writeStringField(LAST_NAME_FIELD, lastName);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
+ }
+ if (thumbHeight != null) {
+ gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultContact{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", phoneNumber='" + phoneNumber + '\'' +
+ ", firstName='" + firstName + '\'' +
+ ", thumbHeight=" + thumbHeight +
+ ", thumbWidth=" + thumbWidth +
+ ", thumbUrl='" + thumbUrl + '\'' +
+ ", lastName='" + lastName + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultDocument.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultDocument.java
new file mode 100644
index 00000000..c72344d7
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultDocument.java
@@ -0,0 +1,244 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a file. By default, this file will be sent by the user with an
+ * optional caption. Alternatively, you can use input_message_content to send a message with the
+ * specified content instead of the file.
+ * @note Currently, only .PDF and .ZIP files can be sent using this method.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 01 of January of 2016
+ */
+public class InlineQueryResultDocument implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "document"; ///< Type of the result, must be "document"
+ private static final String ID_FIELD = "id";
+ private static final String TITLE_FIELD = "title";
+ private static final String DOCUMENTURL_FIELD = "document_url";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String THUMBWIDTH_FIELD = "thumb_width";
+ private static final String THUMBHEIGHT_FIELD = "thumb_height";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(DOCUMENTURL_FIELD)
+ private String documentUrl; ///< A valid URL for the file
+ @JsonProperty(MIMETYPE_FIELD)
+ private String mimeType; ///< Mime type of the content of the file, either “application/pdf” or “application/zip”
+ @JsonProperty(DESCRIPTION_FIELD)
+ private String description; ///< Optional. Short description of the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the document to be sent, 0-200 characters
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
+ @JsonProperty(THUMBURL_FIELD)
+ private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
+ @JsonProperty(THUMBWIDTH_FIELD)
+ private Integer thumbWidth; ///< Optional. Thumbnail width
+ @JsonProperty(THUMBHEIGHT_FIELD)
+ private Integer thumbHeight; ///< Optional. Thumbnail height
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ public void setMimeType(String mimeType) {
+ this.mimeType = mimeType;
+ }
+
+ public String getDocumentUrl() {
+ return documentUrl;
+ }
+
+ public void setDocumentUrl(String documentUrl) {
+ this.documentUrl = documentUrl;
+ }
+
+ public Integer getThumbWidth() {
+ return thumbWidth;
+ }
+
+ public void setThumbWidth(Integer thumbWidth) {
+ this.thumbWidth = thumbWidth;
+ }
+
+ public Integer getThumbHeight() {
+ return thumbHeight;
+ }
+
+ public void setThumbHeight(Integer thumbHeight) {
+ this.thumbHeight = thumbHeight;
+ }
+
+ public String getThumbUrl() {
+ return thumbUrl;
+ }
+
+ public void setThumbUrl(String thumbUrl) {
+ this.thumbUrl = thumbUrl;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(MIMETYPE_FIELD, mimeType);
+ jsonObject.put(TITLE_FIELD, title);
+ jsonObject.put(DOCUMENTURL_FIELD, documentUrl);
+ if (description != null) {
+ jsonObject.put(DESCRIPTION_FIELD, this.description);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
+ }
+ if (thumbHeight != null) {
+ jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(MIMETYPE_FIELD, mimeType);
+ gen.writeStringField(TITLE_FIELD, title);
+ gen.writeStringField(DOCUMENTURL_FIELD, documentUrl);
+ if (description != null) {
+ gen.writeStringField(DESCRIPTION_FIELD, description);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
+ }
+ if (thumbHeight != null) {
+ gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultDocument{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", mimeType='" + mimeType + '\'' +
+ ", documentUrl='" + documentUrl + '\'' +
+ ", thumbHeight=" + thumbHeight +
+ ", thumbWidth=" + thumbWidth +
+ ", thumbUrl='" + thumbUrl + '\'' +
+ ", title='" + title + '\'' +
+ ", description='" + description + '\'' +
+ ", caption='" + caption + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultGif.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultGif.java
similarity index 59%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultGif.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultGif.java
index b6598322..9701212c 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultGif.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultGif.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -6,51 +6,51 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption.
- * Alternatively, you can provide message_text to send it instead of the animation.
+ * @brief Represents a link to an animated GIF file. By default, this animated GIF file will be sent
+ * by the user with optional caption. Alternatively, you can use input_message_content to send a
+ * message with the specified content instead of the animation.
* @date 01 of January of 2016
*/
public class InlineQueryResultGif implements InlineQueryResult {
- public static final String TYPE_FIELD = "type";
+ private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
- private final String type = "gif"; ///< Type of the result, must be "gif"
- public static final String ID_FIELD = "id";
+ private static final String type = "gif"; ///< Type of the result, must be "gif"
+ private static final String ID_FIELD = "id";
+ private static final String GIFURL_FIELD = "gif_url";
+ private static final String GIFWIDTH_FIELD = "gif_width";
+ private static final String GIFHEIGHT_FIELD = "gif_height";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
- private String id; ///< Unique identifier of this result
- public static final String GIFURL_FIELD = "gif_url";
+ private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(GIFURL_FIELD)
private String gifUrl; ///< A valid URL for the GIF file. File size must not exceed 1MB
- public static final String GIFWIDTH_FIELD = "gif_width";
@JsonProperty(GIFWIDTH_FIELD)
private Integer gifWidth; ///< Optional. Width of the GIF
- public static final String GIFHEIGHT_FIELD = "gif_height";
@JsonProperty(GIFHEIGHT_FIELD)
private Integer gifHeight; ///< Optional. Height of the GIF
- public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of a static thumbnail for the result (jpeg or gif)
- public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
- public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the GIF file to be sent
- public static final String MESSAGETEXT_FIELD = "message_text";
- @JsonProperty(MESSAGETEXT_FIELD)
- private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters
- public static final String PARSEMODE_FIELD = "parse_mode";
- @JsonProperty(PARSEMODE_FIELD)
- private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
- @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
- private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public String getType() {
return type;
@@ -72,40 +72,20 @@ public class InlineQueryResultGif implements InlineQueryResult {
this.title = title;
}
- public String getMessageText() {
- return messageText;
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
}
- public void setMessageText(String messageText) {
- this.messageText = messageText;
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
}
- public String getParseMode() {
- return parseMode;
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
}
- public void enableMarkdown(boolean enable) {
- if (enable) {
- this.parseMode = "Markdown";
- } else {
- this.parseMode = null;
- }
- }
-
- public void enableHtml(boolean enable) {
- if (enable) {
- this.parseMode = "html";
- } else {
- this.parseMode = null;
- }
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
}
public String getGifUrl() {
@@ -151,16 +131,9 @@ public class InlineQueryResultGif implements InlineQueryResult {
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
-
jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(GIFURL_FIELD, this.gifUrl);
- if (parseMode != null) {
- jsonObject.put(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (gifWidth != null) {
jsonObject.put(GIFWIDTH_FIELD, this.gifWidth);
}
@@ -176,10 +149,12 @@ public class InlineQueryResultGif implements InlineQueryResult {
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
-
return jsonObject;
}
@@ -189,13 +164,6 @@ public class InlineQueryResultGif implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(GIFURL_FIELD, this.gifUrl);
-
- if (parseMode != null) {
- gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (gifWidth != null) {
gen.writeNumberField(GIFWIDTH_FIELD, this.gifWidth);
}
@@ -211,10 +179,12 @@ public class InlineQueryResultGif implements InlineQueryResult {
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- gen.writeStringField(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
-
gen.writeEndObject();
gen.flush();
}
@@ -235,9 +205,8 @@ public class InlineQueryResultGif implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
- ", messageText='" + messageText + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultLocation.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultLocation.java
new file mode 100644
index 00000000..7ca7c562
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultLocation.java
@@ -0,0 +1,207 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a location on a map. By default, the location will be sent by the user.
+ * Alternatively, you can use input_message_content to send a message with the specified content
+ * instead of the location.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultLocation implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "location"; ///< Type of the result, must be "location"
+ private static final String ID_FIELD = "id";
+ private static final String TITLE_FIELD = "title";
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String THUMBWIDTH_FIELD = "thumb_width";
+ private static final String THUMBHEIGHT_FIELD = "thumb_height";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Location title
+ @JsonProperty(LATITUDE_FIELD)
+ private String latitude; ///< Location latitude in degrees
+ @JsonProperty(LONGITUDE_FIELD)
+ private String longitude; ///< Location longitude in degrees
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
+ @JsonProperty(THUMBURL_FIELD)
+ private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
+ @JsonProperty(THUMBWIDTH_FIELD)
+ private Integer thumbWidth; ///< Optional. Thumbnail width
+ @JsonProperty(THUMBHEIGHT_FIELD)
+ private Integer thumbHeight; ///< Optional. Thumbnail height
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public String getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+ public Integer getThumbWidth() {
+ return thumbWidth;
+ }
+
+ public void setThumbWidth(Integer thumbWidth) {
+ this.thumbWidth = thumbWidth;
+ }
+
+ public Integer getThumbHeight() {
+ return thumbHeight;
+ }
+
+ public void setThumbHeight(Integer thumbHeight) {
+ this.thumbHeight = thumbHeight;
+ }
+
+ public String getThumbUrl() {
+ return thumbUrl;
+ }
+
+ public void setThumbUrl(String thumbUrl) {
+ this.thumbUrl = thumbUrl;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(LATITUDE_FIELD, latitude);
+ jsonObject.put(TITLE_FIELD, title);
+ jsonObject.put(LONGITUDE_FIELD, longitude);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
+ }
+ if (thumbHeight != null) {
+ jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(LONGITUDE_FIELD, longitude);
+ gen.writeStringField(LATITUDE_FIELD, latitude);
+ gen.writeStringField(TITLE_FIELD, title);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
+ }
+ if (thumbHeight != null) {
+ gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultLocation{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", mimeType='" + latitude + '\'' +
+ ", documentUrl='" + longitude + '\'' +
+ ", thumbHeight=" + thumbHeight +
+ ", thumbWidth=" + thumbWidth +
+ ", thumbUrl='" + thumbUrl + '\'' +
+ ", title='" + title + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultMpeg4Gif.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java
similarity index 59%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultMpeg4Gif.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java
index 5c51354c..973c0866 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultMpeg4Gif.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -6,52 +6,51 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
- * By default, this animated MPEG-4 file will be sent by the user with optional caption.
- * Alternatively, you can provide message_text to send it instead of the animation.
+ * @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default,
+ * this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can
+ * use input_message_content to send a message with the specified content instead of the animation.
* @date 01 of January of 2016
*/
public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
- public static final String TYPE_FIELD = "type";
+ private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
- private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
- public static final String ID_FIELD = "id";
+ private static final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
+ private static final String ID_FIELD = "id";
+ private static final String MPEG4URL_FIELD = "mpeg4_url";
+ private static final String MPEG4WIDTH_FIELD = "mpeg4_width";
+ private static final String MPEG4HEIGHT_FIELD = "mpeg4_height";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
- private String id; ///< Unique identifier of this result
- public static final String MPEG4URL_FIELD = "mpeg4_url";
+ private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(MPEG4URL_FIELD)
private String mpeg4Url; ///< A valid URL for the MP4 file. File size must not exceed 1MB
- public static final String MPEG4WIDTH_FIELD = "mpeg4_width";
@JsonProperty(MPEG4WIDTH_FIELD)
private Integer mpeg4Width; ///< Optional. Video width
- public static final String MPEG4HEIGHT_FIELD = "mpeg4_height";
@JsonProperty(MPEG4HEIGHT_FIELD)
private Integer mpeg4Height; ///< Optional. Video height
- public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the static thumbnail (jpeg or gif) for the result
- public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
- public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the MPEG-4 file to be sent
- public static final String MESSAGETEXT_FIELD = "message_text";
- @JsonProperty(MESSAGETEXT_FIELD)
- private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters
- public static final String PARSEMODE_FIELD = "parse_mode";
- @JsonProperty(PARSEMODE_FIELD)
- private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
- @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
- private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public String getType() {
return type;
@@ -73,40 +72,20 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
this.title = title;
}
- public String getMessageText() {
- return messageText;
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
}
- public void setMessageText(String messageText) {
- this.messageText = messageText;
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
}
- public String getParseMode() {
- return parseMode;
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
}
- public void enableMarkdown(boolean enable) {
- if (enable) {
- this.parseMode = "Markdown";
- } else {
- this.parseMode = null;
- }
- }
-
- public void enableHtml(boolean enable) {
- if (enable) {
- this.parseMode = "html";
- } else {
- this.parseMode = null;
- }
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
}
public String getMpeg4Url() {
@@ -156,12 +135,6 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(MPEG4URL_FIELD, this.mpeg4Url);
- if (parseMode != null) {
- jsonObject.put(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (mpeg4Width != null) {
jsonObject.put(MPEG4WIDTH_FIELD, this.mpeg4Width);
}
@@ -177,8 +150,11 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
@@ -190,13 +166,6 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(MPEG4URL_FIELD, this.mpeg4Url);
-
- if (parseMode != null) {
- gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (mpeg4Width != null) {
gen.writeNumberField(MPEG4WIDTH_FIELD, this.mpeg4Width);
}
@@ -212,10 +181,12 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- gen.writeStringField(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
-
gen.writeEndObject();
gen.flush();
}
@@ -236,9 +207,8 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
- ", messageText='" + messageText + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultPhoto.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultPhoto.java
similarity index 62%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultPhoto.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultPhoto.java
index 727d47df..ba657623 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultPhoto.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultPhoto.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -6,59 +6,59 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Represents a link to a photo. By default, this photo will be sent by the user with optional caption.
- * Alternatively, you can provide message_text to send it instead of photo.
+ * @brief Represents a link to a photo. By default, this photo will be sent by the user with
+ * optional caption. Alternatively, you can use input_message_content to send a message with the
+ * specified content instead of the photo.
* @date 01 of January of 2016
*/
public class InlineQueryResultPhoto implements InlineQueryResult {
- public static final String TYPE_FIELD = "type";
+ private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
- private final String type = "photo"; ///< Type of the result, must be “photo”
- public static final String ID_FIELD = "id";
+ private static final String type = "photo"; ///< Type of the result, must be “photo”
+ private static final String ID_FIELD = "id";
+ private static final String PHOTOURL_FIELD = "photo_url";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String PHOTOWIDTH_FIELD = "photo_width";
+ private static final String PHOTOHEIGHT_FIELD = "photo_height";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
- private String id; ///< Unique identifier of this result
- public static final String PHOTOURL_FIELD = "photo_url";
+ private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(PHOTOURL_FIELD)
private String photoUrl; ///< A valid URL of the photo. Photo size must not exceed 5MB
- public static final String MIMETYPE_FIELD = "mime_type";
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. MIME type of the photo, defaults to image/jpeg
- public static final String PHOTOWIDTH_FIELD = "photo_width";
@JsonProperty(PHOTOWIDTH_FIELD)
private Integer photoWidth; ///< Optional. Width of the photo
- public static final String PHOTOHEIGHT_FIELD = "photo_height";
@JsonProperty(PHOTOHEIGHT_FIELD)
private Integer photoHeight; ///< Optional. Height of the photo
- public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail for the photo
- public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
- public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
- public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the photo to be sent
- public static final String MESSAGETEXT_FIELD = "message_text";
- @JsonProperty(MESSAGETEXT_FIELD)
- private String messageText; ///< Optional. Text of a message to be sent instead of the photo, 1-4096 characters
- public static final String PARSEMODE_FIELD = "parse_mode";
- @JsonProperty(PARSEMODE_FIELD)
- private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
- @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
- private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
- public String getType() {
+ public static String getType() {
return type;
}
@@ -78,40 +78,20 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
this.title = title;
}
- public String getMessageText() {
- return messageText;
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
}
- public void setMessageText(String messageText) {
- this.messageText = messageText;
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
}
- public String getParseMode() {
- return parseMode;
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
}
- public void enableMarkdown(boolean enable) {
- if (enable) {
- this.parseMode = "Markdown";
- } else {
- this.parseMode = null;
- }
- }
-
- public void enableHtml(boolean enable) {
- if (enable) {
- this.parseMode = "html";
- } else {
- this.parseMode = null;
- }
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
}
public String getPhotoUrl() {
@@ -174,15 +154,9 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
- jsonObject.put(TYPE_FIELD, this.type);
+ jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(PHOTOURL_FIELD, this.photoUrl);
- if (parseMode != null) {
- jsonObject.put(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (mimeType != null) {
jsonObject.put(MIMETYPE_FIELD, this.mimeType);
}
@@ -201,14 +175,14 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
- if (description != null) {
- jsonObject.put(DESCRIPTION_FIELD, this.description);
- }
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
@@ -220,12 +194,6 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(PHOTOURL_FIELD, this.photoUrl);
- if (parseMode != null) {
- gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (mimeType != null) {
gen.writeStringField(MIMETYPE_FIELD, this.mimeType);
}
@@ -247,8 +215,11 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
- if (messageText != null) {
- gen.writeStringField(MESSAGETEXT_FIELD, this.messageText);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
@@ -273,9 +244,8 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
- ", messageText='" + messageText + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVenue.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVenue.java
new file mode 100644
index 00000000..2d101dbf
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVenue.java
@@ -0,0 +1,238 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a venue. By default, the venue will be sent by the user. Alternatively, you can
+ * use input_message_content to send a message with the specified content instead of the venue.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultVenue implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "venue"; ///< Type of the result, must be "venue"
+ private static final String ID_FIELD = "id";
+ private static final String TITLE_FIELD = "title";
+ private static final String LATITUDE_FIELD = "latitude";
+ private static final String LONGITUDE_FIELD = "longitude";
+ private static final String ADDRESS_FIELD = "address";
+ private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String THUMBWIDTH_FIELD = "thumb_width";
+ private static final String THUMBHEIGHT_FIELD = "thumb_height";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Location title
+ @JsonProperty(LATITUDE_FIELD)
+ private String latitude; ///< Venue latitude in degrees
+ @JsonProperty(LONGITUDE_FIELD)
+ private String longitude; ///< Venue longitude in degrees
+ @JsonProperty(ADDRESS_FIELD)
+ private String address; ///< Address of the venue
+ @JsonProperty(FOURSQUARE_ID_FIELD)
+ private String foursquareId; ///< Optional. Foursquare identifier of the venue if known
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
+ @JsonProperty(THUMBURL_FIELD)
+ private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
+ @JsonProperty(THUMBWIDTH_FIELD)
+ private Integer thumbWidth; ///< Optional. Thumbnail width
+ @JsonProperty(THUMBHEIGHT_FIELD)
+ private Integer thumbHeight; ///< Optional. Thumbnail height
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public String getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+ public Integer getThumbWidth() {
+ return thumbWidth;
+ }
+
+ public void setThumbWidth(Integer thumbWidth) {
+ this.thumbWidth = thumbWidth;
+ }
+
+ public Integer getThumbHeight() {
+ return thumbHeight;
+ }
+
+ public void setThumbHeight(Integer thumbHeight) {
+ this.thumbHeight = thumbHeight;
+ }
+
+ public String getThumbUrl() {
+ return thumbUrl;
+ }
+
+ public void setThumbUrl(String thumbUrl) {
+ this.thumbUrl = thumbUrl;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getFoursquareId() {
+ return foursquareId;
+ }
+
+ public void setFoursquareId(String foursquareId) {
+ this.foursquareId = foursquareId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(LATITUDE_FIELD, latitude);
+ jsonObject.put(TITLE_FIELD, title);
+ jsonObject.put(LONGITUDE_FIELD, longitude);
+ jsonObject.put(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
+ }
+ if (thumbHeight != null) {
+ jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(LONGITUDE_FIELD, longitude);
+ gen.writeStringField(LATITUDE_FIELD, latitude);
+ gen.writeStringField(TITLE_FIELD, title);
+ gen.writeStringField(ADDRESS_FIELD, address);
+ if (foursquareId != null) {
+ gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (thumbUrl != null) {
+ gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
+ }
+ if (thumbWidth != null) {
+ gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
+ }
+ if (thumbHeight != null) {
+ gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
+ }
+
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultVenue{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", mimeType='" + latitude + '\'' +
+ ", documentUrl='" + longitude + '\'' +
+ ", thumbHeight=" + thumbHeight +
+ ", thumbWidth=" + thumbWidth +
+ ", thumbUrl='" + thumbUrl + '\'' +
+ ", title='" + title + '\'' +
+ ", foursquareId='" + foursquareId + '\'' +
+ ", address='" + address + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultVideo.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java
similarity index 65%
rename from src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultVideo.java
rename to src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java
index b8ca5384..e01e0ff8 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQueryResultVideo.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
@@ -13,51 +15,53 @@ import java.io.IOException;
* @author Ruben Bermudez
* @version 1.0
* @brief Represents link to a page containing an embedded video player or a video file.
+ * Alternatively, you can use input_message_content to send a message with the specified content
+ * instead of the video.
* @date 01 of January of 2016
*/
public class InlineQueryResultVideo implements InlineQueryResult {
- public static final String TYPE_FIELD = "type";
+ private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
- private final String type = "video"; ///< Type of the result, must be "video"
- public static final String ID_FIELD = "id";
+ private static final String type = "video"; ///< Type of the result, must be "video"
+ private static final String ID_FIELD = "id";
+ private static final String MIMETYPE_FIELD = "mime_type";
+ private static final String VIDEOURL_FIELD = "video_url";
+ private static final String VIDEOWIDTH_FIELD = "video_width";
+ private static final String VIDEOHEIGHT_FIELD = "video_height";
+ private static final String VIDEODURATION_FIELD = "video_duration";
+ private static final String THUMBURL_FIELD = "thumb_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result
- public static final String MIMETYPE_FIELD = "mime_type";
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Mime type of the content of video url, i.e. “text/html” or “video/mp4”
- public static final String VIDEOURL_FIELD = "video_url";
@JsonProperty(VIDEOURL_FIELD)
private String videoUrl; ///< A valid URL for the embedded video player or video file
- public static final String VIDEOWIDTH_FIELD = "video_width";
@JsonProperty(VIDEOWIDTH_FIELD)
private Integer videoWidth; ///< Optional. Video width
- public static final String VIDEOHEIGHT_FIELD = "video_height";
@JsonProperty(VIDEOHEIGHT_FIELD)
private Integer videoHeight; ///< Optional. Video height
- public static final String VIDEODURATION_FIELD = "video_duration";
@JsonProperty(VIDEODURATION_FIELD)
private Integer videoDuration; ///< Optional. Video duration in seconds
- public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video
- public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
- public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
- public static final String MESSAGETEXT_FIELD = "message_text";
- @JsonProperty(MESSAGETEXT_FIELD)
- private String messageText; ///< Optional. Text of a message to be sent instead of the video, 1-4096 characters
- public static final String PARSEMODE_FIELD = "parse_mode";
- @JsonProperty(PARSEMODE_FIELD)
- private String parseMode; ///< Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
- public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
- @JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
- private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the video to be sent, 0-200 characters
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
- public String getType() {
+ public static String getType() {
return type;
}
@@ -77,40 +81,20 @@ public class InlineQueryResultVideo implements InlineQueryResult {
this.title = title;
}
- public String getMessageText() {
- return messageText;
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
}
- public void setMessageText(String messageText) {
- this.messageText = messageText;
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
}
- public String getParseMode() {
- return parseMode;
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
}
- public void enableMarkdown(boolean enable) {
- if (enable) {
- this.parseMode = "Markdown";
- } else {
- this.parseMode = null;
- }
- }
-
- public void enableHtml(boolean enable) {
- if (enable) {
- this.parseMode = "html";
- } else {
- this.parseMode = null;
- }
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
- this.disableWebPagePreview = disableWebPagePreview;
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
}
public String getMimeType() {
@@ -169,25 +153,24 @@ public class InlineQueryResultVideo implements InlineQueryResult {
this.description = description;
}
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
- jsonObject.put(TYPE_FIELD, this.type);
+ jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VIDEOURL_FIELD, this.videoUrl);
if (mimeType != null) {
jsonObject.put(MIMETYPE_FIELD, this.mimeType);
}
- if (messageText != null) {
- jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
- }
- if (parseMode != null) {
- jsonObject.put(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (videoWidth != null) {
jsonObject.put(VIDEOWIDTH_FIELD, this.videoWidth);
}
@@ -206,6 +189,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
return jsonObject;
}
@@ -219,15 +211,6 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (mimeType != null) {
gen.writeStringField(MIMETYPE_FIELD, this.mimeType);
}
- if (messageText != null) {
- gen.writeStringField(MESSAGETEXT_FIELD, this.messageText);
- }
- if (parseMode != null) {
- gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
- }
- if (disableWebPagePreview != null) {
- gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
- }
if (videoWidth != null) {
gen.writeNumberField(VIDEOWIDTH_FIELD, this.videoWidth);
}
@@ -246,6 +229,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, this.description);
}
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
gen.writeEndObject();
gen.flush();
@@ -269,9 +261,9 @@ public class InlineQueryResultVideo implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
- ", messageText='" + messageText + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
+ ", caption='" + caption + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVoice.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVoice.java
new file mode 100644
index 00000000..23268a73
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVoice.java
@@ -0,0 +1,160 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a voice recording in an .ogg container encoded with OPUS. By default,
+ * this voice recording will be sent by the user. Alternatively, you can use input_message_content
+ * to send a message with the specified content instead of the the voice message.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultVoice implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "voice"; ///< Type of the result, must be "voice"
+ private static final String ID_FIELD = "id";
+ private static final String VOICEURL_FIELD = "voice_url";
+ private static final String TITLE_FIELD = "title";
+ private static final String VOICE_DURATION_FIELD = "voice_duration";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(VOICEURL_FIELD)
+ private String voiceUrl; ///< A valid URL for the voice recording
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Recording title
+ @JsonProperty(VOICE_DURATION_FIELD)
+ private Integer voiceDuration; ///< Optional. Recording duration in seconds
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the voice recording
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public Integer getVoiceDuration() {
+ return voiceDuration;
+ }
+
+ public void setVoiceDuration(Integer voiceDuration) {
+ this.voiceDuration = voiceDuration;
+ }
+
+ public String getVoiceUrl() {
+ return voiceUrl;
+ }
+
+ public void setVoiceUrl(String voiceUrl) {
+ this.voiceUrl = voiceUrl;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(VOICE_DURATION_FIELD, voiceUrl);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (voiceDuration != null) {
+ jsonObject.put(VOICE_DURATION_FIELD, voiceDuration);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(VOICEURL_FIELD, voiceUrl);
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (voiceDuration != null) {
+ gen.writeNumberField(VOICE_DURATION_FIELD, voiceDuration);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultVoice{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", voiceDuration='" + voiceDuration + '\'' +
+ ", voiceUrl=" + voiceUrl +
+ ", title='" + title + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedAudio.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedAudio.java
new file mode 100644
index 00000000..4a60879a
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedAudio.java
@@ -0,0 +1,126 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to an mp3 audio file stored on the Telegram servers. By default, this
+ * audio file will be sent by the user. Alternatively, you can use input_message_content to send a
+ * message with the specified content instead of the audio.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedAudio implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "audio"; ///< Type of the result, must be "audio"
+ private static final String ID_FIELD = "id";
+ private static final String AUDIO_FILE_ID_FIELD = "audio_file_id";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result
+ @JsonProperty(AUDIO_FILE_ID_FIELD)
+ private String audioFileId; ///< A valid file identifier for the audio file
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the audio
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getAudioFileId() {
+ return audioFileId;
+ }
+
+ public void setAudioFileId(String audioFileId) {
+ this.audioFileId = audioFileId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(AUDIO_FILE_ID_FIELD, audioFileId);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(AUDIO_FILE_ID_FIELD, audioFileId);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedAudio{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", audioFileId='" + audioFileId + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedDocument.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedDocument.java
new file mode 100644
index 00000000..9c60eff2
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedDocument.java
@@ -0,0 +1,176 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a file stored on the Telegram servers. By default, this file will be
+ * sent by the user with an optional caption. Alternatively, you can use input_message_content to
+ * send a message with the specified content instead of the file.
+ * @note Currently, only pdf-files and zip archives can be sent using this method.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedDocument implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "document"; ///< Type of the result, must be "document"
+ private static final String ID_FIELD = "id";
+ private static final String TITLE_FIELD = "title";
+ private static final String DOCUMENT_FILE_ID_FIELD = "document_file_id";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(DOCUMENT_FILE_ID_FIELD)
+ private String documentFileId; ///< A valid file identifier for the file
+ @JsonProperty(DESCRIPTION_FIELD)
+ private String description; ///< Optional. Short description of the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the document to be sent, 0-200 characters
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public String getDocumentFileId() {
+ return documentFileId;
+ }
+
+ public void setDocumentFileId(String documentFileId) {
+ this.documentFileId = documentFileId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, id);
+ jsonObject.put(DOCUMENT_FILE_ID_FIELD, documentFileId);
+ jsonObject.put(TITLE_FIELD, title);
+ if (description != null) {
+ jsonObject.put(DESCRIPTION_FIELD, this.description);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, caption);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(DOCUMENT_FILE_ID_FIELD, documentFileId);
+ gen.writeStringField(TITLE_FIELD, title);
+ if (description != null) {
+ gen.writeStringField(DESCRIPTION_FIELD, description);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, caption);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedDocument{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", documentFileId='" + documentFileId + '\'' +
+ ", caption='" + caption + '\'' +
+ ", title='" + title + '\'' +
+ ", description='" + description + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedGif.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedGif.java
new file mode 100644
index 00000000..702303aa
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedGif.java
@@ -0,0 +1,159 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to an animated GIF file stored on the Telegram servers. By default, this
+ * animated GIF file will be sent by the user with an optional caption. Alternatively, you can use
+ * input_message_content to send a message with specified content instead of the animation.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedGif implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "gif"; ///< Type of the result, must be "gif"
+ private static final String ID_FIELD = "id";
+ private static final String GIF_FILE_ID_FIELD = "gif_file_id";
+ private static final String TITLE_FIELD = "title";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(GIF_FILE_ID_FIELD)
+ private String gifFileId; ///< A valid file identifier for the GIF file
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the GIF file to be sent
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getGifFileId() {
+ return gifFileId;
+ }
+
+ public void setGifFileId(String gifFileId) {
+ this.gifFileId = gifFileId;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(GIF_FILE_ID_FIELD, gifFileId);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(GIF_FILE_ID_FIELD, gifFileId);
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedGif{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", gifUrl='" + gifFileId + '\'' +
+ ", title='" + title + '\'' +
+ ", caption='" + caption + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedMpeg4Gif.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedMpeg4Gif.java
new file mode 100644
index 00000000..4a9d4225
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedMpeg4Gif.java
@@ -0,0 +1,160 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default,
+ * this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can
+ * use input_message_content to send a message with the specified content instead of the animation.
+ * @date 01 of January of 2016
+ */
+public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
+ private static final String ID_FIELD = "id";
+ private static final String MPEG4_FILE_ID_FIELD = "mpeg4_file_id";
+ private static final String TITLE_FIELD = "title";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(MPEG4_FILE_ID_FIELD)
+ private String mpeg4FileId; ///< A valid file identifier for the MP4 file
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the MPEG-4 file to be sent
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getMpeg4FileId() {
+ return mpeg4FileId;
+ }
+
+ public void setMpeg4FileId(String mpeg4FileId) {
+ this.mpeg4FileId = mpeg4FileId;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(MPEG4_FILE_ID_FIELD, mpeg4FileId);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(MPEG4_FILE_ID_FIELD, mpeg4FileId);
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedMpeg4Gif{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", mpeg4Url='" + mpeg4FileId + '\'' +
+ ", title='" + title + '\'' +
+ ", caption='" + caption + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedPhoto.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedPhoto.java
new file mode 100644
index 00000000..08734fe3
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedPhoto.java
@@ -0,0 +1,183 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a photo stored on the Telegram servers. By default, this photo will
+ * be sent by the user with an optional caption. Alternatively, you can use input_message_content to
+ * send a message with the specified content instead of the photo.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedPhoto implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "photo"; ///< Type of the result, must be “photo”
+ private static final String ID_FIELD = "id";
+ private static final String PHOTOFILEID_FIELD = "photo_file_id";
+ private static final String TITLE_FIELD = "title";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(PHOTOFILEID_FIELD)
+ private String photoFileId; ///< A valid file identifier of the photo
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(DESCRIPTION_FIELD)
+ private String description; ///< Optional. Short description of the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the photo to be sent
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getPhotoFileId() {
+ return photoFileId;
+ }
+
+ public void setPhotoFileId(String photoFileId) {
+ this.photoFileId = photoFileId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(PHOTOFILEID_FIELD, photoFileId);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (description != null) {
+ jsonObject.put(DESCRIPTION_FIELD, this.description);
+ }
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+
+ return jsonObject;
+ }
+
+ /*
+ reply_markup InlineKeyboardMarkup Optional. Inline keyboard attached to the message
+input_message_content InputMessageContent Optional. Content of the message to be sent instead of the photo
+ */
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(PHOTOFILEID_FIELD, photoFileId);
+ if (description != null) {
+ gen.writeStringField(DESCRIPTION_FIELD, this.description);
+ }
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, this.caption);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedPhoto{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", photoFileId='" + photoFileId + '\'' +
+ ", title='" + title + '\'' +
+ ", description='" + description + '\'' +
+ ", caption='" + caption + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedSticker.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedSticker.java
new file mode 100644
index 00000000..e84b0f7a
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedSticker.java
@@ -0,0 +1,125 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a sticker stored on the Telegram servers. By default, this sticker
+ * will be sent by the user. Alternatively, you can use input_message_content to send a message with
+ * the specified content instead of the sticker.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedSticker implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "sticker"; ///< Type of the result, must be "sticker"
+ private static final String ID_FIELD = "id";
+ private static final String STICKER_FILE_ID_FIELD = "sticker_file_id";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(STICKER_FILE_ID_FIELD)
+ private String stickerFileId; ///< A valid file identifier of the sticker
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the sticker
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getStickerFileId() {
+ return stickerFileId;
+ }
+
+ public void setStickerFileId(String stickerFileId) {
+ this.stickerFileId = stickerFileId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(STICKER_FILE_ID_FIELD, stickerFileId);
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(STICKER_FILE_ID_FIELD, stickerFileId);
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedGif{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", gifUrl='" + stickerFileId + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVideo.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVideo.java
new file mode 100644
index 00000000..0ed1f356
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVideo.java
@@ -0,0 +1,177 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a video file stored on the Telegram servers. By default, this video
+ * file will be sent by the user with an optional caption. Alternatively, you can use
+ * input_message_content to send a message with the specified content instead of the video.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedVideo implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "video"; ///< Type of the result, must be "video"
+ private static final String ID_FIELD = "id";
+ private static final String VIDEO_FILE_ID_FIELD = "video_file_id";
+ private static final String TITLE_FIELD = "title";
+ private static final String DESCRIPTION_FIELD = "description";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result
+ @JsonProperty(VIDEO_FILE_ID_FIELD)
+ private String videoFileId; ///< A valid file identifier for the video file
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Optional. Title for the result
+ @JsonProperty(DESCRIPTION_FIELD)
+ private String description; ///< Optional. Short description of the result
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. Caption of the video to be sent, 0-200 characters
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getVideoFileId() {
+ return videoFileId;
+ }
+
+ public void setVideoFileId(String videoFileId) {
+ this.videoFileId = videoFileId;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(VIDEO_FILE_ID_FIELD, videoFileId);
+ if (caption != null) {
+ jsonObject.put(CAPTION_FIELD, caption);
+ }
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (description != null) {
+ jsonObject.put(DESCRIPTION_FIELD, this.description);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(VIDEO_FILE_ID_FIELD, videoFileId);
+ if (caption != null) {
+ gen.writeStringField(CAPTION_FIELD, caption);
+ }
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (description != null) {
+ gen.writeStringField(DESCRIPTION_FIELD, this.description);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedVideo{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", caption='" + caption + '\'' +
+ ", videoFileId='" + videoFileId + '\'' +
+ ", title='" + title + '\'' +
+ ", description='" + description + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVoice.java b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVoice.java
new file mode 100644
index 00000000..e8376494
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/inlinequery/result/chached/InlineQueryResultCachedVoice.java
@@ -0,0 +1,143 @@
+package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
+import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Represents a link to a voice message stored on the Telegram servers. By default, this
+ * voice message will be sent by the user. Alternatively, you can use input_message_content to send
+ * a message with the specified content instead of the voice message.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * ignore them.
+ * @date 10 of April of 2016
+ */
+public class InlineQueryResultCachedVoice implements InlineQueryResult {
+
+ private static final String TYPE_FIELD = "type";
+ @JsonProperty(TYPE_FIELD)
+ private static final String type = "voice"; ///< Type of the result, must be "voice"
+ private static final String ID_FIELD = "id";
+ private static final String VOICE_FILE_ID_FIELD = "voice_file_id";
+ private static final String TITLE_FIELD = "title";
+ private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
+ private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ @JsonProperty(ID_FIELD)
+ private String id; ///< Unique identifier of this result, 1-64 bytes
+ @JsonProperty(VOICE_FILE_ID_FIELD)
+ private String voiceFileId; ///< A valid file identifier for the voice message
+ @JsonProperty(TITLE_FIELD)
+ private String title; ///< Recording title
+ @JsonProperty(INPUTMESSAGECONTENT_FIELD)
+ private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the voice recording
+ @JsonProperty(REPLY_MARKUP_FIELD)
+ private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
+
+ public static String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public InputMessageContent getInputMessageContent() {
+ return inputMessageContent;
+ }
+
+ public void setInputMessageContent(InputMessageContent inputMessageContent) {
+ this.inputMessageContent = inputMessageContent;
+ }
+
+ public InlineKeyboardMarkup getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ }
+
+ public String getVoiceFileId() {
+ return voiceFileId;
+ }
+
+ public void setVoiceFileId(String voiceFileId) {
+ this.voiceFileId = voiceFileId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TYPE_FIELD, type);
+ jsonObject.put(ID_FIELD, this.id);
+ jsonObject.put(VOICE_FILE_ID_FIELD, voiceFileId);
+ if (title != null) {
+ jsonObject.put(TITLE_FIELD, this.title);
+ }
+ if (replyMarkup != null) {
+ jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TYPE_FIELD, type);
+ gen.writeStringField(ID_FIELD, id);
+ gen.writeStringField(VOICE_FILE_ID_FIELD, voiceFileId);
+ if (title != null) {
+ gen.writeStringField(TITLE_FIELD, this.title);
+ }
+ if (replyMarkup != null) {
+ gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
+ }
+ if (inputMessageContent != null) {
+ gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineQueryResultCachedVoice{" +
+ "type='" + type + '\'' +
+ ", id='" + id + '\'' +
+ ", voiceFileId='" + voiceFileId + '\'' +
+ ", title='" + title + '\'' +
+ ", inputMessageContent='" + inputMessageContent + '\'' +
+ ", replyMarkup='" + replyMarkup + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ForceReplyKeyboard.java
similarity index 78%
rename from src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java
rename to src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ForceReplyKeyboard.java
index 442c84d6..9381e0c6 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ForceReplyKeyboard.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -12,26 +12,26 @@ import java.io.IOException;
/**
* @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.
+ * @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 {
- public static final String FORCEREPLY_FIELD = "force_reply";
- public static final String SELECTIVE_FIELD = "selective";
+ 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'
+ * 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.
+ * 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;
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/InlineKeyboardMarkup.java
similarity index 75%
rename from src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java
rename to src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/InlineKeyboardMarkup.java
index 846c9d45..7531621c 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/InlineKeyboardMarkup.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -15,15 +15,18 @@ import java.util.List;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief This object represents a custom keyboard with reply options.
- * @date 20 of June of 2015
+ * @brief This object represents an inline keyboard that appears right next to the message it
+ * belongs to
+ * @note Inline keyboards are currently being tested and are only available in one-on-one chats
+ * (i.e., user-bot or user-user in the case of inline bots).
+ * @date 10 of April of 2016
*/
-public class ReplyKeyboardMarkup implements ReplyKeyboard {
+public class InlineKeyboardMarkup implements ReplyKeyboard {
- public static final String KEYBOARD_FIELD = "keyboard";
- public static final String RESIZEKEYBOARD_FIELD = "resize_keyboard";
- public static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard";
- public static final String SELECTIVE_FIELD = "selective";
+ private static final String KEYBOARD_FIELD = "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)
private List> keyboard; ///< Array of button rows, each represented by an Array of Strings
@JsonProperty(RESIZEKEYBOARD_FIELD)
@@ -32,25 +35,24 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
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.
+ * 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 ReplyKeyboardMarkup() {
+ public InlineKeyboardMarkup() {
super();
keyboard = new ArrayList>();
}
- public ReplyKeyboardMarkup(JSONObject jsonObject) {
+ public InlineKeyboardMarkup(JSONObject jsonObject) {
super();
this.keyboard = new ArrayList>();
JSONArray keyboard = jsonObject.getJSONArray(KEYBOARD_FIELD);
- for (int i=0; i< keyboard.length(); i++) {
+ for (int i = 0; i < keyboard.length(); i++) {
JSONArray keyboardRow = keyboard.getJSONArray(i);
List row = new ArrayList();
- for (int j=0; j < keyboardRow.length(); j++) {
+ for (int j = 0; j < keyboardRow.length(); j++) {
row.add(keyboardRow.getString(j));
}
this.keyboard.add(row);
@@ -105,21 +107,21 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
for (List innerRow : this.keyboard) {
JSONArray innerJSONKeyboard = new JSONArray();
- for (String element: innerRow) {
+ for (String element : innerRow) {
innerJSONKeyboard.put(element);
}
jsonkeyboard.put(innerJSONKeyboard);
}
- jsonObject.put(ReplyKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
+ jsonObject.put(InlineKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
if (this.oneTimeKeyboad != null) {
- jsonObject.put(ReplyKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
+ jsonObject.put(InlineKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
}
if (this.resizeKeyboard != null) {
- jsonObject.put(ReplyKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
+ jsonObject.put(InlineKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
}
if (this.selective != null) {
- jsonObject.put(ReplyKeyboardMarkup.SELECTIVE_FIELD, this.selective);
+ jsonObject.put(InlineKeyboardMarkup.SELECTIVE_FIELD, this.selective);
}
return jsonObject;
@@ -131,7 +133,7 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
gen.writeArrayFieldStart(KEYBOARD_FIELD);
for (List innerRow : keyboard) {
gen.writeStartArray();
- for (String element: innerRow) {
+ for (String element : innerRow) {
gen.writeString(element);
}
gen.writeEndArray();
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboard.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboard.java
similarity index 83%
rename from src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboard.java
rename to src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboard.java
index 7fad3cbe..657e86c7 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboard.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboard.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.replykeyboard;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.interfaces.IToJson;
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardHide.java
similarity index 76%
rename from src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java
rename to src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardHide.java
index 3c4b6aed..031ed42b 100644
--- a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardHide.java
@@ -1,4 +1,4 @@
-package org.telegram.telegrambots.api.objects;
+package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -12,24 +12,22 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Upon receiving a message with this object,
- * Telegram clients will hide the current custom keyboard and display the default letter-keyboard.
- * By default, custom keyboards are displayed until a new keyboard is sent by a bot.
- * An exception is made for one-time keyboards that are hidden immediately after the user presses a button
- * (@see ReplyKeyboardMarkup).
+ * @brief Upon receiving a message with this object, Telegram clients will hide the current custom
+ * keyboard and display the default letter-keyboard. By default, custom keyboards are displayed
+ * until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are
+ * hidden immediately after the user presses a button (@see ReplyKeyboardMarkup).
* @date 20 of June of 2015
*/
public class ReplyKeyboardHide implements ReplyKeyboard {
- public static final String HIDEKEYBOARD_FIELD = "hide_keyboard";
- public static final String SELECTIVE_FIELD = "selective";
+ private static final String HIDEKEYBOARD_FIELD = "hide_keyboard";
+ private static final String SELECTIVE_FIELD = "selective";
@JsonProperty(HIDEKEYBOARD_FIELD)
private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard
/**
* 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.
+ * 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;
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardMarkup.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardMarkup.java
new file mode 100644
index 00000000..04ab7363
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/ReplyKeyboardMarkup.java
@@ -0,0 +1,147 @@
+package org.telegram.telegrambots.api.objects.replykeyboard;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardButton;
+import org.telegram.telegrambots.api.objects.replykeyboard.buttons.KeyboardRow;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents a custom keyboard with reply options.
+ * @date 20 of June of 2015
+ */
+public class ReplyKeyboardMarkup implements ReplyKeyboard {
+
+ private static final String KEYBOARD_FIELD = "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)
+ private List 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.
+ @JsonProperty(SELECTIVE_FIELD)
+ /**
+ * 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 ReplyKeyboardMarkup() {
+ super();
+ keyboard = new ArrayList<>();
+ }
+
+ public List getKeyboard() {
+ return keyboard;
+ }
+
+ public void setKeyboard(List 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
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ JSONArray jsonkeyboard = new JSONArray();
+
+ for (KeyboardRow innerRow : this.keyboard) {
+ JSONArray innerJSONKeyboard = new JSONArray();
+ for (KeyboardButton button : innerRow) {
+ innerJSONKeyboard.put(button);
+ }
+ jsonkeyboard.put(innerJSONKeyboard);
+ }
+ jsonObject.put(ReplyKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
+
+ if (this.oneTimeKeyboad != null) {
+ jsonObject.put(ReplyKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
+ }
+ if (this.resizeKeyboard != null) {
+ jsonObject.put(ReplyKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
+ }
+ if (this.selective != null) {
+ jsonObject.put(ReplyKeyboardMarkup.SELECTIVE_FIELD, this.selective);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeArrayFieldStart(KEYBOARD_FIELD);
+ for (KeyboardRow innerRow : keyboard) {
+ gen.writeStartArray();
+ for (KeyboardButton button : innerRow) {
+ gen.writeObject(button);
+ }
+ 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.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "ReplyKeyboardMarkup{" +
+ "keyboard=" + keyboard +
+ ", resizeKeyboard=" + resizeKeyboard +
+ ", oneTimeKeyboad=" + oneTimeKeyboad +
+ ", selective=" + selective +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/InlineKeyboardButton.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/InlineKeyboardButton.java
new file mode 100644
index 00000000..33db6e75
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/InlineKeyboardButton.java
@@ -0,0 +1,146 @@
+package org.telegram.telegrambots.api.objects.replykeyboard.buttons;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.interfaces.IToJson;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents one button of an inline keyboard. You must use exactly one of the
+ * optional fields.
+ * @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
+ * display unsupported message.
+ * @date 10 of April of 2016
+ */
+public class InlineKeyboardButton implements IBotApiObject, IToJson {
+
+ private static final String TEXT_FIELD = "text";
+ private static final String URL_FIELD = "url";
+ private static final String CALLBACK_DATA_FIELD = "callback_data";
+ private static final String SWITCH_INLINE_QUERY_FIELD = "switch_inline_query";
+ @JsonProperty(TEXT_FIELD)
+ private String text; ///< Label text on the button
+ @JsonProperty(URL_FIELD)
+ private String url; ///< Optional. HTTP url to be opened when button is pressed
+ @JsonProperty(CALLBACK_DATA_FIELD)
+ private String callbackData; ///< Optional. Data to be sent in a callback query to the bot when button is pressed
+ @JsonProperty(SWITCH_INLINE_QUERY_FIELD)
+ /**
+ * Optional.
+ * If set, pressing the button will prompt the user to select one of their chats,
+ * open that chat and insert the bot‘s username and the specified inline query in the input field.
+ * Can be empty, in which case just the bot’s username will be inserted.
+ * @Note: This offers an easy way for users to start using your bot in inline mode when
+ * they are currently in a private chat with it.
+ * Especially useful when combined with switch_pm… actions – in this case the user will
+ * be automatically returned to the chat they switched from, skipping the chat selection screen.
+ */
+ private String switchInlineQuery;
+
+ public InlineKeyboardButton() {
+ super();
+ }
+
+ public InlineKeyboardButton(JSONObject jsonObject) {
+ super();
+ text = jsonObject.getString(TEXT_FIELD);
+ if (jsonObject.has(URL_FIELD)) {
+ url = jsonObject.getString(URL_FIELD);
+ }
+ if (jsonObject.has(CALLBACK_DATA_FIELD)) {
+ callbackData = jsonObject.getString(CALLBACK_DATA_FIELD);
+ }
+ if (jsonObject.has(SWITCH_INLINE_QUERY_FIELD)) {
+ switchInlineQuery = jsonObject.getString(SWITCH_INLINE_QUERY_FIELD);
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getCallbackData() {
+ return callbackData;
+ }
+
+ public void setCallbackData(String callbackData) {
+ this.callbackData = callbackData;
+ }
+
+ public String getSwitchInlineQuery() {
+ return switchInlineQuery;
+ }
+
+ public void setSwitchInlineQuery(String switchInlineQuery) {
+ this.switchInlineQuery = switchInlineQuery;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TEXT_FIELD, text);
+ if (url != null) {
+ jsonObject.put(URL_FIELD, url);
+ }
+ if (callbackData != null) {
+ jsonObject.put(CALLBACK_DATA_FIELD, callbackData);
+ }
+ if (switchInlineQuery != null) {
+ jsonObject.put(SWITCH_INLINE_QUERY_FIELD, switchInlineQuery);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TEXT_FIELD, text);
+ if (url != null) {
+ gen.writeStringField(URL_FIELD, url);
+ }
+ if (callbackData != null) {
+ gen.writeStringField(CALLBACK_DATA_FIELD, callbackData);
+ }
+ if (switchInlineQuery != null) {
+ gen.writeStringField(SWITCH_INLINE_QUERY_FIELD, switchInlineQuery);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "InlineKeyboardButton{" +
+ "text=" + text +
+ ", url=" + url +
+ ", callbackData=" + callbackData +
+ ", switchInlineQuery=" + switchInlineQuery +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardButton.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardButton.java
new file mode 100644
index 00000000..af075ca6
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardButton.java
@@ -0,0 +1,141 @@
+package org.telegram.telegrambots.api.objects.replykeyboard.buttons;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+
+import org.json.JSONObject;
+import org.telegram.telegrambots.api.interfaces.IBotApiObject;
+import org.telegram.telegrambots.api.interfaces.IToJson;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief This object represents one button of the reply keyboard. For simple text buttons String
+ * can be used instead of this object to specify text of the button.
+ * @note Optional fields are mutually exclusive.
+ * @note request_contact and request_location options will only work in Telegram versions released
+ * after 9 April, 2016. Older clients will ignore them.
+ * @date 10 of April of 2016
+ */
+public class KeyboardButton implements IBotApiObject, IToJson {
+
+ private static final String TEXT_FIELD = "text";
+ private static final String REQUEST_CONTACT_FIELD = "request_contact";
+ private static final String REQUEST_LOCATION_FIELD = "request_location";
+ @JsonProperty(TEXT_FIELD)
+ /**
+ * Text of the button.
+ * If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed
+ */
+ private String text;
+ @JsonProperty(REQUEST_CONTACT_FIELD)
+ /**
+ * Optional.
+ * If True, the user's phone number will be sent as a contact when the button is pressed.
+ * Available in private chats only
+ */
+ private Boolean requestContact;
+ @JsonProperty(REQUEST_LOCATION_FIELD)
+ /**
+ * Optional.
+ * If True, the user's current location will be sent when the button is pressed.
+ * Available in private chats only
+ */
+ private Boolean requestLocation;
+
+ public KeyboardButton() {
+ super();
+ }
+
+ public KeyboardButton(String text) {
+ super();
+ this.text = text;
+ }
+
+ public KeyboardButton(JSONObject jsonObject) {
+ super();
+ text = jsonObject.getString(TEXT_FIELD);
+ if (jsonObject.has(REQUEST_CONTACT_FIELD)) {
+ requestContact = jsonObject.getBoolean(REQUEST_CONTACT_FIELD);
+ }
+ if (jsonObject.has(REQUEST_LOCATION_FIELD)) {
+ requestLocation = jsonObject.getBoolean(REQUEST_LOCATION_FIELD);
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Boolean getRequestContact() {
+ return requestContact;
+ }
+
+ public void setRequestContact(Boolean requestContact) {
+ if (requestContact != null) {
+ requestLocation = null;
+ }
+ this.requestContact = requestContact;
+ }
+
+ public Boolean getRequestLocation() {
+ return requestLocation;
+ }
+
+ public void setRequestLocation(Boolean requestLocation) {
+ if (requestLocation != null) {
+ requestContact = null;
+ }
+ this.requestLocation = requestLocation;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(TEXT_FIELD, text);
+ if (requestContact != null) {
+ jsonObject.put(REQUEST_CONTACT_FIELD, requestContact);
+ }
+ if (requestLocation != null) {
+ jsonObject.put(REQUEST_LOCATION_FIELD, requestLocation);
+ }
+
+ return jsonObject;
+ }
+
+ @Override
+ public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(TEXT_FIELD, text);
+ if (requestContact != null) {
+ gen.writeBooleanField(REQUEST_CONTACT_FIELD, requestContact);
+ }
+ if (requestLocation != null) {
+ gen.writeBooleanField(REQUEST_LOCATION_FIELD, requestLocation);
+ }
+ gen.writeEndObject();
+ gen.flush();
+ }
+
+ @Override
+ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(gen, serializers);
+ }
+
+ @Override
+ public String toString() {
+ return "KeyboardButton{" +
+ "text=" + text +
+ ", requestContact=" + requestContact +
+ ", requestLocation=" + requestLocation +
+ '}';
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardRow.java b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardRow.java
new file mode 100644
index 00000000..bc4bb772
--- /dev/null
+++ b/src/main/java/org/telegram/telegrambots/api/objects/replykeyboard/buttons/KeyboardRow.java
@@ -0,0 +1,39 @@
+package org.telegram.telegrambots.api.objects.replykeyboard.buttons;
+
+import java.util.ArrayList;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * @brief Row for ReplyKeyBoardMarkup
+ * @date 10 of April of 2016
+ */
+public class KeyboardRow extends ArrayList {
+ public boolean add(String text) {
+ return super.add(new KeyboardButton(text));
+ }
+
+ public void add(int index, String text) {
+ super.add(index, new KeyboardButton(text));
+ }
+
+ public boolean contains(String text) {
+ return super.contains(new KeyboardButton(text));
+ }
+
+ public int lastIndexOf(String text) {
+ return super.lastIndexOf(new KeyboardButton(text));
+ }
+
+ public int indexOf(String text) {
+ return super.indexOf(new KeyboardButton(text));
+ }
+
+ public KeyboardButton set(int index, String text) {
+ return super.set(index, new KeyboardButton(text));
+ }
+
+ public boolean remove(String text) {
+ return super.remove(new KeyboardButton(text));
+ }
+}
diff --git a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java
index 5e81b4f6..7c3df6b3 100644
--- a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java
+++ b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java
@@ -18,21 +18,29 @@ import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.telegram.telegrambots.TelegramApiException;
import org.telegram.telegrambots.api.Constants;
+import org.telegram.telegrambots.api.methods.AnswerCallbackQuery;
import org.telegram.telegrambots.api.methods.AnswerInlineQuery;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.methods.ForwardMessage;
import org.telegram.telegrambots.api.methods.GetFile;
import org.telegram.telegrambots.api.methods.GetMe;
import org.telegram.telegrambots.api.methods.GetUserProfilePhotos;
-import org.telegram.telegrambots.api.methods.SendAudio;
-import org.telegram.telegrambots.api.methods.SendChatAction;
-import org.telegram.telegrambots.api.methods.SendDocument;
-import org.telegram.telegrambots.api.methods.SendLocation;
-import org.telegram.telegrambots.api.methods.SendMessage;
-import org.telegram.telegrambots.api.methods.SendPhoto;
-import org.telegram.telegrambots.api.methods.SendSticker;
-import org.telegram.telegrambots.api.methods.SendVideo;
-import org.telegram.telegrambots.api.methods.SendVoice;
+import org.telegram.telegrambots.api.methods.groupadministration.KickChatMember;
+import org.telegram.telegrambots.api.methods.groupadministration.UnbanChatMember;
+import org.telegram.telegrambots.api.methods.send.SendAudio;
+import org.telegram.telegrambots.api.methods.send.SendChatAction;
+import org.telegram.telegrambots.api.methods.send.SendContact;
+import org.telegram.telegrambots.api.methods.send.SendDocument;
+import org.telegram.telegrambots.api.methods.send.SendLocation;
+import org.telegram.telegrambots.api.methods.send.SendMessage;
+import org.telegram.telegrambots.api.methods.send.SendPhoto;
+import org.telegram.telegrambots.api.methods.send.SendSticker;
+import org.telegram.telegrambots.api.methods.send.SendVenue;
+import org.telegram.telegrambots.api.methods.send.SendVideo;
+import org.telegram.telegrambots.api.methods.send.SendVoice;
+import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageCaption;
+import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageReplyMarkup;
+import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageText;
import org.telegram.telegrambots.api.objects.File;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.User;
@@ -61,6 +69,8 @@ public abstract class AbsSender {
*/
public abstract String getBotToken();
+ // Send Requests
+
public Message sendMessage(SendMessage sendMessage) throws TelegramApiException {
if (sendMessage == null) {
throw new TelegramApiException("Parameter sendMessage can not be null");
@@ -69,7 +79,7 @@ public abstract class AbsSender {
return (Message) sendApiMethod(sendMessage);
}
- public Boolean sendAnswerInlineQuery(AnswerInlineQuery answerInlineQuery) throws TelegramApiException {
+ public Boolean answerInlineQuery(AnswerInlineQuery answerInlineQuery) throws TelegramApiException {
if (answerInlineQuery == null) {
throw new TelegramApiException("Parameter answerInlineQuery can not be null");
}
@@ -101,6 +111,64 @@ public abstract class AbsSender {
return (Message) sendApiMethod(sendLocation);
}
+ public Message sendVenue(SendVenue sendVenue) throws TelegramApiException {
+ if (sendVenue == null) {
+ throw new TelegramApiException("Parameter sendVenue can not be null");
+ }
+
+ return (Message) sendApiMethod(sendVenue);
+ }
+
+ public Message sendContact(SendContact sendContact) throws TelegramApiException {
+ if (sendContact == null) {
+ throw new TelegramApiException("Parameter sendContact can not be null");
+ }
+
+ return (Message) sendApiMethod(sendContact);
+ }
+
+ public Boolean kickMember(KickChatMember kickChatMember) throws TelegramApiException {
+ if (kickChatMember == null) {
+ throw new TelegramApiException("Parameter kickChatMember can not be null");
+ }
+ return (Boolean) sendApiMethod(kickChatMember);
+ }
+
+ public Boolean unbanMember(UnbanChatMember unbanChatMember) throws TelegramApiException {
+ if (unbanChatMember == null) {
+ throw new TelegramApiException("Parameter unbanChatMember can not be null");
+ }
+ return (Boolean) sendApiMethod(unbanChatMember);
+ }
+
+ public Message editMessageText(EditMessageText editMessageText) throws TelegramApiException {
+ if (editMessageText == null) {
+ throw new TelegramApiException("Parameter editMessageText can not be null");
+ }
+ return (Message) sendApiMethod(editMessageText);
+ }
+
+ public Message editMessageCaption(EditMessageCaption editMessageCaption) throws TelegramApiException {
+ if (editMessageCaption == null) {
+ throw new TelegramApiException("Parameter editMessageCaption can not be null");
+ }
+ return (Message) sendApiMethod(editMessageCaption);
+ }
+
+ public Message editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup) throws TelegramApiException {
+ if (editMessageReplyMarkup == null) {
+ throw new TelegramApiException("Parameter editMessageReplyMarkup can not be null");
+ }
+ return (Message) sendApiMethod(editMessageReplyMarkup);
+ }
+
+ public Boolean answerCallbackQuery(AnswerCallbackQuery answerCallbackQuery) throws TelegramApiException {
+ if (answerCallbackQuery == null) {
+ throw new TelegramApiException("Parameter answerCallbackQuery can not be null");
+ }
+ return (Boolean) sendApiMethod(answerCallbackQuery);
+ }
+
public UserProfilePhotos getUserProfilePhotos(GetUserProfilePhotos getUserProfilePhotos) throws TelegramApiException {
if (getUserProfilePhotos == null) {
throw new TelegramApiException("Parameter getUserProfilePhotos can not be null");
@@ -108,7 +176,7 @@ public abstract class AbsSender {
return (UserProfilePhotos) sendApiMethod(getUserProfilePhotos);
}
-
+
public File getFile(GetFile getFile) throws TelegramApiException{
if(getFile == null){
throw new TelegramApiException("Parameter getFile can not be null");
@@ -116,8 +184,7 @@ public abstract class AbsSender {
else if(getFile.getFileId() == null){
throw new TelegramApiException("Attribute file_id in parameter getFile can not be null");
}
- return (File)sendApiMethod(getFile);
-
+ return (File) sendApiMethod(getFile);
}
public User getMe() throws TelegramApiException {
@@ -126,6 +193,8 @@ public abstract class AbsSender {
return (User) sendApiMethod(getMe);
}
+ // Send Requests Async
+
public void sendMessageAsync(SendMessage sendMessage, SentCallback sentCallback) throws TelegramApiException {
if (sendMessage == null) {
throw new TelegramApiException("Parameter sendMessage can not be null");
@@ -138,7 +207,7 @@ public abstract class AbsSender {
sendApiMethodAsync(sendMessage, sentCallback);
}
- public void sendAnswerInlineQueryAsync(AnswerInlineQuery answerInlineQuery, SentCallback sentCallback) throws TelegramApiException {
+ public void answerInlineQueryAsync(AnswerInlineQuery answerInlineQuery, SentCallback sentCallback) throws TelegramApiException {
if (answerInlineQuery == null) {
throw new TelegramApiException("Parameter answerInlineQuery can not be null");
}
@@ -186,6 +255,95 @@ public abstract class AbsSender {
sendApiMethodAsync(sendLocation, sentCallback);
}
+ public void sendVenueAsync(SendVenue sendVenue, SentCallback sentCallback) throws TelegramApiException {
+ if (sendVenue == null) {
+ throw new TelegramApiException("Parameter sendVenue can not be null");
+ }
+
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(sendVenue, sentCallback);
+ }
+
+ public void sendContactAsync(SendContact sendContact, SentCallback sentCallback) throws TelegramApiException {
+ if (sendContact == null) {
+ throw new TelegramApiException("Parameter sendContact can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(sendContact, sentCallback);
+ }
+
+ public void kickMemberAsync(KickChatMember kickChatMember, SentCallback sentCallback) throws TelegramApiException {
+ if (kickChatMember == null) {
+ throw new TelegramApiException("Parameter kickChatMember can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(kickChatMember, sentCallback);
+ }
+
+ public void unbanMemberAsync(UnbanChatMember unbanChatMember, SentCallback sentCallback) throws TelegramApiException {
+ if (unbanChatMember == null) {
+ throw new TelegramApiException("Parameter unbanChatMember can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(unbanChatMember, sentCallback);
+ }
+
+ public void editMessageTextAsync(EditMessageText editMessageText, SentCallback sentCallback) throws TelegramApiException {
+ if (editMessageText == null) {
+ throw new TelegramApiException("Parameter editMessageText can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(editMessageText, sentCallback);
+ }
+
+ public void editMessageCaptionAsync(EditMessageCaption editMessageCaption, SentCallback sentCallback) throws TelegramApiException {
+ if (editMessageCaption == null) {
+ throw new TelegramApiException("Parameter editMessageCaption can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(editMessageCaption, sentCallback);
+ }
+
+ public void editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup, SentCallback sentCallback) throws TelegramApiException {
+ if (editMessageReplyMarkup == null) {
+ throw new TelegramApiException("Parameter editMessageReplyMarkup can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(editMessageReplyMarkup, sentCallback);
+ }
+
+ public void answerCallbackQueryAsync(AnswerCallbackQuery answerCallbackQuery, SentCallback sentCallback) throws TelegramApiException {
+ if (answerCallbackQuery == null) {
+ throw new TelegramApiException("Parameter answerCallbackQuery can not be null");
+ }
+ if (sentCallback == null) {
+ throw new TelegramApiException("Parameter sentCallback can not be null");
+ }
+
+ sendApiMethodAsync(answerCallbackQuery, sentCallback);
+ }
+
public void getUserProfilePhotosAsync(GetUserProfilePhotos getUserProfilePhotos, SentCallback sentCallback) throws TelegramApiException {
if (getUserProfilePhotos == null) {
throw new TelegramApiException("Parameter getUserProfilePhotos can not be null");
@@ -198,6 +356,16 @@ public abstract class AbsSender {
sendApiMethodAsync(getUserProfilePhotos, sentCallback);
}
+ public void getFileAsync(GetFile getFile, SentCallback sentCallback) throws TelegramApiException {
+ if (getFile == null) {
+ throw new TelegramApiException("Parameter getFile can not be null");
+ } else if (getFile.getFileId() == null) {
+ throw new TelegramApiException("Attribute file_id in parameter getFile can not be null");
+ }
+
+ sendApiMethodAsync(getFile, sentCallback);
+ }
+
public void getMeAsync(SentCallback sentCallback) throws TelegramApiException {
if (sentCallback == null) {
throw new TelegramApiException("Parameter sentCallback can not be null");
@@ -207,6 +375,8 @@ public abstract class AbsSender {
sendApiMethodAsync(getMe, sentCallback);
}
+ // Specific Send Requests
+
public Message sendDocument(SendDocument sendDocument) throws TelegramApiException {
String responseContent;
@@ -607,6 +777,8 @@ public abstract class AbsSender {
return new Message(jsonObject);
}
+ // Simplified methods
+
private void sendApiMethodAsync(BotApiMethod method, SentCallback callback) {
exe.submit(() -> {
try {
diff --git a/src/main/java/org/telegram/telegrambots/updatesreceivers/UpdatesThread.java b/src/main/java/org/telegram/telegrambots/updatesreceivers/UpdatesThread.java
index cbe9f650..dd964003 100644
--- a/src/main/java/org/telegram/telegrambots/updatesreceivers/UpdatesThread.java
+++ b/src/main/java/org/telegram/telegrambots/updatesreceivers/UpdatesThread.java
@@ -15,7 +15,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.telegram.telegrambots.api.Constants;
-import org.telegram.telegrambots.api.methods.GetUpdates;
+import org.telegram.telegrambots.api.methods.updates.GetUpdates;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.ITelegramLongPollingBot;
@@ -31,12 +31,14 @@ import java.util.concurrent.TimeUnit;
* @date 20 of June of 2015
*/
public class UpdatesThread {
+ private static final int SOCKET_TIMEOUT = 30 * 1000;
+
private final ITelegramLongPollingBot callback;
private final ReaderThread readerThread;
private final HandlerThread handlerThread;
+ private final ConcurrentLinkedDeque receivedUpdates = new ConcurrentLinkedDeque<>();
private int lastReceivedUpdate = 0;
private String token;
- private final ConcurrentLinkedDeque receivedUpdates = new ConcurrentLinkedDeque<>();
public UpdatesThread(String token, ITelegramLongPollingBot callback) {
this.token = token;
@@ -61,9 +63,9 @@ public class UpdatesThread {
//config
RequestConfig defaultRequestConfig = RequestConfig.custom().build();
RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig)
- .setSocketTimeout(Constants.SOCKET_TIMEOUT)
- .setConnectTimeout(Constants.SOCKET_TIMEOUT)
- .setConnectionRequestTimeout(Constants.SOCKET_TIMEOUT).build();
+ .setSocketTimeout(SOCKET_TIMEOUT)
+ .setConnectTimeout(SOCKET_TIMEOUT)
+ .setConnectionRequestTimeout(SOCKET_TIMEOUT).build();
//http client
HttpPost httpPost = new HttpPost(url);
try {