Added new api fields
This commit is contained in:
parent
c8e1e907ad
commit
f7d7ed14bb
@ -15,7 +15,7 @@ I recommend using getUpdates methods.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Just import add the library to your project using [Maven, Gradly, ...](https://jitpack.io/#rubenlagus/TelegramBots/v2.3.1) or download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.3.1)
|
Just import add the library to your project using [Maven, Gradly, ...](https://jitpack.io/#rubenlagus/TelegramBots/v2.3.2) or download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.3.2)
|
||||||
|
|
||||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>2.3.2</version>
|
||||||
|
|
||||||
<name>Telegram Bots</name>
|
<name>Telegram Bots</name>
|
||||||
<url>https://telegram.me/JavaBotsApi</url>
|
<url>https://telegram.me/JavaBotsApi</url>
|
||||||
|
@ -25,6 +25,7 @@ public class Message implements IBotApiObject {
|
|||||||
private static final String DATE_FIELD = "date";
|
private static final String DATE_FIELD = "date";
|
||||||
private static final String CHAT_FIELD = "chat";
|
private static final String CHAT_FIELD = "chat";
|
||||||
private static final String FORWARDFROM_FIELD = "forward_from";
|
private static final String FORWARDFROM_FIELD = "forward_from";
|
||||||
|
private static final String FORWARDFROMCHAT_FIELD = "forward_from_chat";
|
||||||
private static final String FORWARDDATE_FIELD = "forward_date";
|
private static final String FORWARDDATE_FIELD = "forward_date";
|
||||||
private static final String TEXT_FIELD = "text";
|
private static final String TEXT_FIELD = "text";
|
||||||
private static final String ENTITIES_FIELD = "entities";
|
private static final String ENTITIES_FIELD = "entities";
|
||||||
@ -59,6 +60,8 @@ public class Message implements IBotApiObject {
|
|||||||
private Chat chat; ///< Conversation the message belongs to
|
private Chat chat; ///< Conversation the message belongs to
|
||||||
@JsonProperty(FORWARDFROM_FIELD)
|
@JsonProperty(FORWARDFROM_FIELD)
|
||||||
private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message
|
private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message
|
||||||
|
@JsonProperty(FORWARDFROMCHAT_FIELD)
|
||||||
|
private Chat forwardedFromChat; ///< Optional. For messages forwarded from a channel, information about the original channel
|
||||||
@JsonProperty(FORWARDDATE_FIELD)
|
@JsonProperty(FORWARDDATE_FIELD)
|
||||||
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
|
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
|
||||||
@JsonProperty(TEXT_FIELD)
|
@JsonProperty(TEXT_FIELD)
|
||||||
@ -126,6 +129,9 @@ public class Message implements IBotApiObject {
|
|||||||
this.date = jsonObject.getInt(DATE_FIELD);
|
this.date = jsonObject.getInt(DATE_FIELD);
|
||||||
}
|
}
|
||||||
this.chat = new Chat(jsonObject.getJSONObject(CHAT_FIELD));
|
this.chat = new Chat(jsonObject.getJSONObject(CHAT_FIELD));
|
||||||
|
if (jsonObject.has(FORWARDFROMCHAT_FIELD)) {
|
||||||
|
this.forwardedFromChat = new Chat(jsonObject.getJSONObject(FORWARDFROMCHAT_FIELD));
|
||||||
|
}
|
||||||
if (jsonObject.has(FORWARDFROM_FIELD)) {
|
if (jsonObject.has(FORWARDFROM_FIELD)) {
|
||||||
this.forwardFrom = new User(jsonObject.getJSONObject(FORWARDFROM_FIELD));
|
this.forwardFrom = new User(jsonObject.getJSONObject(FORWARDFROM_FIELD));
|
||||||
}
|
}
|
||||||
@ -367,6 +373,10 @@ public class Message implements IBotApiObject {
|
|||||||
return location != null;
|
return location != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Chat getForwardedFromChat() {
|
||||||
|
return forwardedFromChat;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
gen.writeStartObject();
|
gen.writeStartObject();
|
||||||
@ -378,6 +388,9 @@ public class Message implements IBotApiObject {
|
|||||||
gen.writeNumberField(DATE_FIELD, date);
|
gen.writeNumberField(DATE_FIELD, date);
|
||||||
}
|
}
|
||||||
gen.writeObjectField(CHAT_FIELD, chat);
|
gen.writeObjectField(CHAT_FIELD, chat);
|
||||||
|
if (forwardedFromChat != null) {
|
||||||
|
gen.writeObjectField(FORWARDFROMCHAT_FIELD, forwardedFromChat);
|
||||||
|
}
|
||||||
if (forwardFrom != null) {
|
if (forwardFrom != null) {
|
||||||
gen.writeObjectField(FORWARDFROM_FIELD, forwardFrom);
|
gen.writeObjectField(FORWARDFROM_FIELD, forwardFrom);
|
||||||
}
|
}
|
||||||
@ -472,6 +485,7 @@ public class Message implements IBotApiObject {
|
|||||||
", date=" + date +
|
", date=" + date +
|
||||||
", chat=" + chat +
|
", chat=" + chat +
|
||||||
", forwardFrom=" + forwardFrom +
|
", forwardFrom=" + forwardFrom +
|
||||||
|
", forwardedFromChat=" + forwardedFromChat +
|
||||||
", forwardDate=" + forwardDate +
|
", forwardDate=" + forwardDate +
|
||||||
", text='" + text + '\'' +
|
", text='" + text + '\'' +
|
||||||
", audio=" + audio +
|
", audio=" + audio +
|
||||||
|
@ -23,6 +23,7 @@ public class Sticker implements IBotApiObject {
|
|||||||
private static final String HEIGHT_FIELD = "height";
|
private static final String HEIGHT_FIELD = "height";
|
||||||
private static final String THUMB_FIELD = "thumb";
|
private static final String THUMB_FIELD = "thumb";
|
||||||
private static final String FILESIZE_FIELD = "file_size";
|
private static final String FILESIZE_FIELD = "file_size";
|
||||||
|
private static final String EMOJI_FIELD = "emoji";
|
||||||
@JsonProperty(FILEID_FIELD)
|
@JsonProperty(FILEID_FIELD)
|
||||||
private String fileId; ///< Unique identifier for this file
|
private String fileId; ///< Unique identifier for this file
|
||||||
@JsonProperty(WIDTH_FIELD)
|
@JsonProperty(WIDTH_FIELD)
|
||||||
@ -33,6 +34,8 @@ public class Sticker implements IBotApiObject {
|
|||||||
private PhotoSize thumb; ///< Optional. Sticker thumbnail in .webp or .jpg format
|
private PhotoSize thumb; ///< Optional. Sticker thumbnail in .webp or .jpg format
|
||||||
@JsonProperty(FILESIZE_FIELD)
|
@JsonProperty(FILESIZE_FIELD)
|
||||||
private Integer fileSize; ///< Optional. File size
|
private Integer fileSize; ///< Optional. File size
|
||||||
|
@JsonProperty(EMOJI_FIELD)
|
||||||
|
private String emoji; ///< Optional. Emoji associated with the sticker
|
||||||
|
|
||||||
public Sticker() {
|
public Sticker() {
|
||||||
super();
|
super();
|
||||||
@ -49,6 +52,9 @@ public class Sticker implements IBotApiObject {
|
|||||||
if (jsonObject.has(FILESIZE_FIELD)) {
|
if (jsonObject.has(FILESIZE_FIELD)) {
|
||||||
this.fileSize = jsonObject.getInt(FILESIZE_FIELD);
|
this.fileSize = jsonObject.getInt(FILESIZE_FIELD);
|
||||||
}
|
}
|
||||||
|
if (jsonObject.has(EMOJI_FIELD)) {
|
||||||
|
this.emoji = jsonObject.getString(EMOJI_FIELD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileId() {
|
public String getFileId() {
|
||||||
@ -71,6 +77,10 @@ public class Sticker implements IBotApiObject {
|
|||||||
return fileSize;
|
return fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEmoji() {
|
||||||
|
return emoji;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
gen.writeStartObject();
|
gen.writeStartObject();
|
||||||
@ -83,6 +93,9 @@ public class Sticker implements IBotApiObject {
|
|||||||
if (fileSize != null) {
|
if (fileSize != null) {
|
||||||
gen.writeNumberField(FILESIZE_FIELD, fileSize);
|
gen.writeNumberField(FILESIZE_FIELD, fileSize);
|
||||||
}
|
}
|
||||||
|
if (emoji != null) {
|
||||||
|
gen.writeStringField(EMOJI_FIELD, emoji);
|
||||||
|
}
|
||||||
gen.writeEndObject();
|
gen.writeEndObject();
|
||||||
gen.flush();
|
gen.flush();
|
||||||
}
|
}
|
||||||
@ -100,6 +113,7 @@ public class Sticker implements IBotApiObject {
|
|||||||
", height=" + height +
|
", height=" + height +
|
||||||
", thumb=" + thumb +
|
", thumb=" + thumb +
|
||||||
", fileSize=" + fileSize +
|
", fileSize=" + fileSize +
|
||||||
|
", emoji=" + emoji +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user