diff --git a/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java b/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java index f9569ec4..1a2bd37b 100644 --- a/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java +++ b/src/main/java/org/telegram/telegrambots/TelegramBotsApi.java @@ -1,8 +1,6 @@ package org.telegram.telegrambots; import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.NoopHostnameVerifier; @@ -82,37 +80,6 @@ public class TelegramBotsApi { webhook.startServer(); } - /** - * - * @param bot - */ - public void registerBot(TelegramLongPollingBot bot) throws TelegramApiException { - setWebhook(bot.getBotToken()); - new UpdatesThread(bot.getBotToken(), bot); - } - - /** - * - * @param bot - */ - public void registerBot(TelegramWebhookBot bot) throws TelegramApiException { - if (useWebhook) { - webhook.registerWebhook(bot); - setWebhook(bot.getBotToken()); - } - } - - /** - * - * @param botToken - */ - private void setWebhook(String botToken) throws TelegramApiException { - if (botToken == null) { - throw new TelegramApiException("Parameter botToken can not be null"); - } - setWebhook(extrenalUrl == null ? "" : extrenalUrl, botToken, pathToCertificate, publicCertificateName); - } - /** * * @param externalUrl @@ -160,4 +127,35 @@ public class TelegramBotsApi { throw new TelegramApiException("Error executing setWebook method", e); } } + + /** + * + * @param bot + */ + public void registerBot(TelegramLongPollingBot bot) throws TelegramApiException { + setWebhook(bot.getBotToken()); + new UpdatesThread(bot.getBotToken(), bot); + } + + /** + * + * @param bot + */ + public void registerBot(TelegramWebhookBot bot) throws TelegramApiException { + if (useWebhook) { + webhook.registerWebhook(bot); + setWebhook(bot.getBotToken()); + } + } + + /** + * + * @param botToken + */ + private void setWebhook(String botToken) throws TelegramApiException { + if (botToken == null) { + throw new TelegramApiException("Parameter botToken can not be null"); + } + setWebhook(extrenalUrl == null ? "" : extrenalUrl, botToken, pathToCertificate, publicCertificateName); + } } 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 8d37d3f5..865e64c1 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/AnswerInlineQuery.java @@ -3,6 +3,7 @@ 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.JSONArray; import org.json.JSONObject; import org.telegram.telegrambots.api.objects.InlineQueryResult; @@ -20,14 +21,14 @@ public class AnswerInlineQuery extends BotApiMethod { public static final String PATH = "answerInlineQuery"; public static final String INLINEQUERYID_FIELD = "inline_query_id"; - private String inlineQueryId; ///< Unique identifier for answered query public static final String RESULTS_FIELD = "results"; - private List results; ///< A JSON-serialized array of results for the inline query public static final String CACHETIME_FIELD = "cache_time"; - private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server public static final String ISPERSONAL_FIELD = "is_personal"; - 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 public static final String NEXTOFFSET_FIELD = "next_offset"; + 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. public AnswerInlineQuery() { diff --git a/src/main/java/org/telegram/telegrambots/api/methods/GetFile.java b/src/main/java/org/telegram/telegrambots/api/methods/GetFile.java index 3c2df8ef..53520a0d 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/GetFile.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/GetFile.java @@ -3,6 +3,7 @@ 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 org.telegram.telegrambots.api.objects.File; diff --git a/src/main/java/org/telegram/telegrambots/api/methods/GetMe.java b/src/main/java/org/telegram/telegrambots/api/methods/GetMe.java index a9f025b1..1fe159a0 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/GetMe.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/GetMe.java @@ -3,6 +3,7 @@ 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 org.telegram.telegrambots.api.objects.User; 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 45490c74..c626a266 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/GetUserProfilePhotos.java @@ -3,6 +3,7 @@ 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 org.telegram.telegrambots.api.objects.UserProfilePhotos; @@ -18,13 +19,13 @@ public class GetUserProfilePhotos extends BotApiMethod { public static final String PATH = "getuserprofilephotos"; public static final String USERID_FIELD = "user_id"; - private Integer userId; ///< Unique identifier of the target user public static final String OFFSET_FIELD = "offset"; + public 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. */ private Integer offset; - public static final String LIMIT_FIELD = "limit"; /** * Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. */ diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java b/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java index ac168d81..e78dec18 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/SendChatAction.java @@ -3,6 +3,7 @@ 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; @@ -20,8 +21,8 @@ public class SendChatAction extends BotApiMethod{ public static final String PATH = "sendChatAction"; 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 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: 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 bdafd217..d596f5f4 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Audio.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Audio.java @@ -4,6 +4,7 @@ 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; @@ -18,21 +19,21 @@ 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"; @JsonProperty(FILEID_FIELD) private String fileId; ///< Unique identifier for this file - public static final String DURATION_FIELD = "duration"; @JsonProperty(DURATION_FIELD) private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender - public static final String MIMETYPE_FIELD = "mime_type"; @JsonProperty(MIMETYPE_FIELD) private String mimeType; ///< Optional. MIME type of the file as defined by sender - public static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size - public static final String TITLE_FIELD = "title"; @JsonProperty(TITLE_FIELD) private String title; ///< Optional. Title of the audio as defined by sender or by audio tags - public static final String PERFORMER_FIELD = "performer"; @JsonProperty(PERFORMER_FIELD) private String performer; ///< Optional. Performer of the audio as defined by sender or by audio tags 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 6776b0b2..c969f24f 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Chat.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Chat.java @@ -4,6 +4,7 @@ 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; @@ -16,27 +17,26 @@ 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 USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; private static final String CHANNELCHATTYPE = "channel"; private static final String SUPERGROUPCHATTYPE = "supergroup"; - - public static final String ID_FIELD = "id"; @JsonProperty(ID_FIELD) private Long id; ///< Unique identifier for this chat, not exciding 1e13 by absolute value - public static final String TYPE_FIELD = "type"; @JsonProperty(TYPE_FIELD) private String type; ///< Type of the chat, one of “private”, “group” or “channel” - public static final String TITLE_FIELD = "title"; @JsonProperty(TITLE_FIELD) private String title; ///< Optional. Title of the chat, only for channels and group chat - public static final String FIRSTNAME_FIELD = "first_name"; @JsonProperty(FIRSTNAME_FIELD) private String firstName; ///< Optional. Username of the chat, only for private chats and channels if available - public static final String LASTNAME_FIELD = "last_name"; @JsonProperty(LASTNAME_FIELD) private String lastName; ///< Optional. Interlocutor's first name for private chats - public static final String USERNAME_FIELD = "username"; @JsonProperty(USERNAME_FIELD) private String userName; ///< Optional. Interlocutor's last name for private chats diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java b/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java index 8ea998e9..0265e533 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/ChosenInlineQuery.java @@ -4,6 +4,7 @@ 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; @@ -17,12 +18,12 @@ import java.io.IOException; */ public class ChosenInlineQuery implements IBotApiObject { public static final String RESULTID_FIELD = "id"; + public static final String FROM_FIELD = "from"; + public static final String QUERY_FIELD = "query"; @JsonProperty(RESULTID_FIELD) private String resultId; ///< The unique identifier for the result that was chosen. - public static final String FROM_FIELD = "from"; @JsonProperty(FROM_FIELD) private User from; ///< The user that chose the result. - public static final String QUERY_FIELD = "query"; @JsonProperty(QUERY_FIELD) private String query; ///< The query that was used to obtain the result. 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 1636be34..bee4d1c8 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Contact.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Contact.java @@ -4,6 +4,7 @@ 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; @@ -18,15 +19,15 @@ 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"; @JsonProperty(PHONENUMBER_FIELD) private String phoneNumber; ///< Contact's phone number - public static final String FIRSTNAME_FIELD = "first_name"; @JsonProperty(FIRSTNAME_FIELD) private String firstName; ///< Contact's first name - public static final String LASTNAME_FIELD = "last_name"; @JsonProperty(LASTNAME_FIELD) private String lastName; ///< Optional. Contact's last name - public static final String USERID_FIELD = "user_id"; @JsonProperty(USERID_FIELD) private Integer userID; ///< Optional. Contact's user identifier in Telegram 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 78a21b33..ac99134e 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Document.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Document.java @@ -4,6 +4,7 @@ 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; @@ -19,18 +20,18 @@ 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"; @JsonProperty(FILEID_FIELD) private String fileId; ///< Unique identifier for this file - public static final String THUMB_FIELD = "thumb"; @JsonProperty(THUMB_FIELD) private PhotoSize thumb; ///< Document thumbnail as defined by sender - public static final String FILENAME_FIELD = "file_name"; @JsonProperty(FILENAME_FIELD) private String fileName; ///< Optional. Original filename as defined by sender - public static final String MIMETYPE_FIELD = "mime_type"; @JsonProperty(MIMETYPE_FIELD) private String mimeType; ///< Optional. Mime type of a file as defined by sender - public static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size 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 5440b0ce..8fb48f37 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/File.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/File.java @@ -4,6 +4,7 @@ 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; @@ -17,12 +18,12 @@ import java.io.IOException; */ 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"; @JsonProperty(FILE_ID) private String fileId; ///< Unique identifier for this file - public static final String FILE_SIZE_FIELD = "file_size"; @JsonProperty(FILE_SIZE_FIELD) private Integer fileSize; ///< Optional. File size, if known - public static final String FILE_PATH_FIELD = "file_path"; @JsonProperty(FILE_PATH_FIELD) private String filePath; ///< Optional. File path. Use https://api.telegram.org/file/bot/ to get the file. diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java b/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java index 18149d9a..442c84d6 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/ForceReplyKeyboard.java @@ -4,6 +4,7 @@ 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; @@ -20,12 +21,12 @@ import java.io.IOException; public class ForceReplyKeyboard implements ReplyKeyboard { public static final String FORCEREPLY_FIELD = "force_reply"; + public static final String SELECTIVE_FIELD = "selective"; /** * Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply' */ @JsonProperty(FORCEREPLY_FIELD) private Boolean forceReply; - public static final String SELECTIVE_FIELD = "selective"; /** * Use this parameter if you want to force reply from specific users only. * Targets: diff --git a/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java b/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java index afd5a693..13fe16ae 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/InlineQuery.java @@ -4,6 +4,7 @@ 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; @@ -18,15 +19,15 @@ import java.io.IOException; */ 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"; @JsonProperty(ID_FIELD) private String id; ///< Unique identifier for this query - public static final String FROM_FIELD = "from"; @JsonProperty(FROM_FIELD) private User from; ///< Sender - public static final String QUERY_FIELD = "query"; @JsonProperty(QUERY_FIELD) private String query; ///< Text of the query - public static final String OFFSET_FIELD = "offset"; @JsonProperty(OFFSET_FIELD) private String offset; ///< Offset of the results to be returned, can be controlled by the bot 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 c59f963d..a8944999 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Location.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Location.java @@ -4,6 +4,7 @@ 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; @@ -18,9 +19,9 @@ import java.io.IOException; public class Location implements IBotApiObject { public static final String LONGITUDE_FIELD = "longitude"; + public static final String LATITUDE_FIELD = "latitude"; @JsonProperty(LONGITUDE_FIELD) private Double longitude; ///< Longitude as defined by sender - public static final String LATITUDE_FIELD = "latitude"; @JsonProperty(LATITUDE_FIELD) private Double latitude; ///< Latitude as defined by sender 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 443bcabf..59f2e571 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Message.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Message.java @@ -4,6 +4,7 @@ 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.interfaces.IBotApiObject; @@ -20,81 +21,81 @@ import java.util.List; */ 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"; @JsonProperty(MESSAGEID_FIELD) private Integer messageId; ///< Integer Unique message identifier - public static final String FROM_FIELD = "from"; @JsonProperty(FROM_FIELD) private User from; ///< Optional. Sender, can be empty for messages sent to channels - public static final String DATE_FIELD = "date"; @JsonProperty(DATE_FIELD) private Integer date; ///< Date the message was sent in Unix time - public static final String CHAT_FIELD = "chat"; @JsonProperty(CHAT_FIELD) private Chat chat; ///< Conversation the message belongs to - public static final String FORWARDFROM_FIELD = "forward_from"; @JsonProperty(FORWARDFROM_FIELD) private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message - public static final String FORWARDDATE_FIELD = "forward_date"; @JsonProperty(FORWARDDATE_FIELD) private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent - public static final String TEXT_FIELD = "text"; @JsonProperty(TEXT_FIELD) private String text; ///< Optional. For text messages, the actual UTF-8 text of the message - public static final String AUDIO_FIELD = "audio"; @JsonProperty(AUDIO_FIELD) private Audio audio; ///< Optional. Message is an audio file, information about the file - public static final String DOCUMENT_FIELD = "document"; @JsonProperty(DOCUMENT_FIELD) private Document document; ///< Optional. Message is a general file, information about the file - public static final String PHOTO_FIELD = "photo"; @JsonProperty(PHOTO_FIELD) private List photo; ///< Optional. Message is a photo, available sizes of the photo - public static final String STICKER_FIELD = "sticker"; @JsonProperty(STICKER_FIELD) private Sticker sticker; ///< Optional. Message is a sticker, information about the sticker - public static final String VIDEO_FIELD = "video"; @JsonProperty(VIDEO_FIELD) private Video video; ///< Optional. Message is a video, information about the video - public static final String CONTACT_FIELD = "contact"; @JsonProperty(CONTACT_FIELD) private Contact contact; ///< Optional. Message is a shared contact, information about the contact - public static final String LOCATION_FIELD = "location"; @JsonProperty(LOCATION_FIELD) private Location location; ///< Optional. Message is a shared location, information about the location - public static final String NEWCHATPARTICIPANT_FIELD = "new_chat_participant"; @JsonProperty(NEWCHATPARTICIPANT_FIELD) private User newChatParticipant; ///< Optional. A new member was added to the group, information about them (this member may be bot itself) - public static final String LEFTCHATPARTICIPANT_FIELD = "left_chat_participant"; @JsonProperty(LEFTCHATPARTICIPANT_FIELD) private User leftChatParticipant; ///< Optional. A member was removed from the group, information about them (this member may be bot itself) - public static final String NEWCHATTITLE_FIELD = "new_chat_title"; @JsonProperty(NEWCHATTITLE_FIELD) private String newChatTitle; ///< Optional. A chat title was changed to this value - public static final String NEWCHATPHOTO_FIELD = "new_chat_photo"; @JsonProperty(NEWCHATPHOTO_FIELD) private List newChatPhoto; ///< Optional. A chat photo was change to this value - public static final String DELETECHATPHOTO_FIELD = "delete_chat_photo"; @JsonProperty(DELETECHATPHOTO_FIELD) private Boolean deleteChatPhoto; ///< Optional. Informs that the chat photo was deleted - public static final String GROUPCHATCREATED_FIELD = "group_chat_created"; @JsonProperty(GROUPCHATCREATED_FIELD) private Boolean groupchatCreated; ///< Optional. Informs that the group has been created - public static final String REPLYTOMESSAGE_FIELD = "reply_to_message"; @JsonProperty(REPLYTOMESSAGE_FIELD) private Message replyToMessage; - public static final String VOICE_FIELD = "voice"; @JsonProperty(VOICE_FIELD) private Voice voice; ///< Optional. Message is a voice message, information about the file - public static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created"; @JsonProperty(SUPERGROUPCREATED_FIELD) private Boolean superGroupCreated; ///< Optional. Informs that the supergroup has been created - public static final String CHANNELCHATCREATED_FIELD = "channel_chat_created"; @JsonProperty(CHANNELCHATCREATED_FIELD) private Boolean channelChatCreated; ///< Optional. Informs that the channel has been created - public static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id"; @JsonProperty(MIGRATETOCHAT_FIELD) private Long migrateToChatId; ///< Optional. The chat has been migrated to a chat with specified identifier, not exceeding 1e13 by absolute value - public static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id"; @JsonProperty(MIGRATEFROMCHAT_FIELD) private Long migrateFromChatId; ///< Optional. The chat has been migrated from a chat with specified identifier, not exceeding 1e13 by absolute value diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java b/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java index 9b370618..3c4b6aed 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardHide.java @@ -4,6 +4,7 @@ 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; @@ -21,9 +22,9 @@ import java.io.IOException; public class ReplyKeyboardHide implements ReplyKeyboard { public static final String HIDEKEYBOARD_FIELD = "hide_keyboard"; + public static final String SELECTIVE_FIELD = "selective"; @JsonProperty(HIDEKEYBOARD_FIELD) private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard - public static final String SELECTIVE_FIELD = "selective"; /** * Optional. Use this parameter if you want to show the keyboard to specific users only. * Targets: diff --git a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java b/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java index e268566e..846c9d45 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/ReplyKeyboardMarkup.java @@ -4,6 +4,7 @@ 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; @@ -20,15 +21,15 @@ import java.util.List; public class ReplyKeyboardMarkup 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"; @JsonProperty(KEYBOARD_FIELD) private List> keyboard; ///< Array of button rows, each represented by an Array of Strings - public static final String RESIZEKEYBOARD_FIELD = "resize_keyboard"; @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. - public static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard"; @JsonProperty(ONETIMEKEYBOARD_FIELD) private Boolean oneTimeKeyboad; ///< Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false. - public static final String SELECTIVE_FIELD = "selective"; /** * Optional. Use this parameter if you want to show the keyboard to specific users only. * Targets: 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 2a76a5de..b8a0a1d8 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Sticker.java @@ -4,6 +4,7 @@ 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; @@ -18,18 +19,18 @@ 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"; @JsonProperty(FILEID_FIELD) private String fileId; ///< Unique identifier for this file - public static final String WIDTH_FIELD = "width"; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Sticker width - public static final String HEIGHT_FIELD = "height"; @JsonProperty(HEIGHT_FIELD) private Integer height; ///< Sticker height - public static final String THUMB_FIELD = "thumb"; @JsonProperty(THUMB_FIELD) private PhotoSize thumb; ///< Optional. Sticker thumbnail in .webp or .jpg format - public static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size 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 a3992945..a766ed5f 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Update.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Update.java @@ -4,6 +4,7 @@ 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; @@ -18,15 +19,15 @@ import java.io.IOException; */ 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"; @JsonProperty(UPDATEID_FIELD) private Integer updateId; - public static final String MESSAGE_FIELD = "message"; @JsonProperty(MESSAGE_FIELD) private Message message; ///< Optional. New incoming message of any kind — text, photo, sticker, etc. - public static final String INLINEQUERY_FIELD = "inline_query"; @JsonProperty(INLINEQUERY_FIELD) private InlineQuery inlineQuery; ///< Optional. New incoming inline query - public static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result"; @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 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 c7920f4d..57969237 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/User.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/User.java @@ -4,6 +4,7 @@ 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; @@ -18,15 +19,15 @@ 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"; @JsonProperty(ID_FIELD) private Integer id; ///< Unique identifier for this user or bot - public static final String FIRSTNAME_FIELD = "first_name"; @JsonProperty(FIRSTNAME_FIELD) private String firstName; ///< User‘s or bot’s first name - public static final String LASTNAME_FIELD = "last_name"; @JsonProperty(LASTNAME_FIELD) private String lastName; ///< Optional. User‘s or bot’s last name - public static final String USERNAME_FIELD = "username"; @JsonProperty(USERNAME_FIELD) private String userName; ///< Optional. User‘s or bot’s username 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 5d680abb..c5551b7d 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/UserProfilePhotos.java @@ -4,6 +4,7 @@ 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.interfaces.IBotApiObject; @@ -21,9 +22,9 @@ import java.util.List; public class UserProfilePhotos implements IBotApiObject { public static final String TOTALCOUNT_FIELD = "total_count"; + public static final String PHOTOS_FIELD = "photos"; @JsonProperty(TOTALCOUNT_FIELD) private Integer totalCount; ///< Total number of profile pictures the target user has - public static final String PHOTOS_FIELD = "photos"; @JsonProperty(PHOTOS_FIELD) private List> photos; ///< Requested profile pictures (in up to 4 sizes each) 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 0a741909..844a262e 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Video.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Video.java @@ -4,6 +4,7 @@ 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; @@ -18,24 +19,24 @@ 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"; @JsonProperty(FILEID_FIELD) private String fileId; ///< Unique identifier for this file - public static final String WIDTH_FIELD = "width"; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Video width as defined by sender - public static final String HEIGHT_FIELD = "height"; @JsonProperty(HEIGHT_FIELD) private Integer height; ///< Video height as defined by sender - public static final String DURATION_FIELD = "duration"; @JsonProperty(DURATION_FIELD) private Integer duration; ///< Duration of the video in seconds as defined by sender - public static final String THUMB_FIELD = "thumb"; @JsonProperty(THUMB_FIELD) private PhotoSize thumb; ///< Video thumbnail - public static final String MIMETYPE_FIELD = "mime_type"; @JsonProperty(MIMETYPE_FIELD) private String mimeType; ///< Optional. Mime type of a file as defined by sender - public static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size 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 4d695356..ae82b653 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Voice.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Voice.java @@ -4,6 +4,7 @@ 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; @@ -17,15 +18,15 @@ import java.io.IOException; */ 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"; @JsonProperty(FILEID_FIELD) private String fileId; ///< Unique identifier for this file - public static final String DURATION_FIELD = "duration"; @JsonProperty(DURATION_FIELD) private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender - public static final String MIMETYPE_FIELD = "mime_type"; @JsonProperty(MIMETYPE_FIELD) private String mimeType; ///< Optional. MIME type of the file as defined by sender - public static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< Optional. File size diff --git a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java index 216d0003..ab9b0227 100644 --- a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java +++ b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java @@ -2,7 +2,6 @@ package org.telegram.telegrambots.bots; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -22,6 +21,7 @@ import org.telegram.telegrambots.api.Constants; 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;