Added undocumented field
Updated sendaudio method
This commit is contained in:
parent
49ff79f0cd
commit
f5dcee5cb1
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
|
||||||
|
|
||||||
@ -29,6 +30,9 @@ public class PhotoSize implements IBotApiObject {
|
|||||||
public static final String FILESIZE_FIELD = "file_size";
|
public static final String FILESIZE_FIELD = "file_size";
|
||||||
@JsonProperty(FILESIZE_FIELD)
|
@JsonProperty(FILESIZE_FIELD)
|
||||||
private Integer fileSize; ///< Optional. File size
|
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
|
||||||
|
|
||||||
public PhotoSize() {
|
public PhotoSize() {
|
||||||
super();
|
super();
|
||||||
@ -42,6 +46,9 @@ public class PhotoSize 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(FILEPATH_FIELD)) {
|
||||||
|
this.filePath = jsonObject.getString(FILEPATH_FIELD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileId() {
|
public String getFileId() {
|
||||||
@ -76,6 +83,14 @@ public class PhotoSize implements IBotApiObject {
|
|||||||
this.fileSize = fileSize;
|
this.fileSize = fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFilePath() {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePath(String filePath) {
|
||||||
|
this.filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
gen.writeStartObject();
|
gen.writeStartObject();
|
||||||
@ -85,6 +100,9 @@ public class PhotoSize implements IBotApiObject {
|
|||||||
if (fileSize != null) {
|
if (fileSize != null) {
|
||||||
gen.writeNumberField(FILESIZE_FIELD, fileSize);
|
gen.writeNumberField(FILESIZE_FIELD, fileSize);
|
||||||
}
|
}
|
||||||
|
if (filePath != null) {
|
||||||
|
gen.writeStringField(FILEPATH_FIELD, filePath);
|
||||||
|
}
|
||||||
gen.writeEndObject();
|
gen.writeEndObject();
|
||||||
gen.flush();
|
gen.flush();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,19 @@ import org.apache.http.util.EntityUtils;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.telegram.telegrambots.TelegramApiException;
|
import org.telegram.telegrambots.TelegramApiException;
|
||||||
import org.telegram.telegrambots.api.Constants;
|
import org.telegram.telegrambots.api.Constants;
|
||||||
import org.telegram.telegrambots.api.methods.*;
|
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.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.objects.File;
|
import org.telegram.telegrambots.api.objects.File;
|
||||||
import org.telegram.telegrambots.api.objects.Message;
|
import org.telegram.telegrambots.api.objects.Message;
|
||||||
import org.telegram.telegrambots.api.objects.User;
|
import org.telegram.telegrambots.api.objects.User;
|
||||||
@ -411,7 +423,7 @@ public abstract class AbsSender {
|
|||||||
if (sendAudio.isNewAudio()) {
|
if (sendAudio.isNewAudio()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId());
|
builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId());
|
||||||
builder.addBinaryBody(SendAudio.AUDIO_FIELD, new java.io.File(sendAudio.getAudio()), ContentType.APPLICATION_OCTET_STREAM, sendAudio.getAudioName());
|
builder.addBinaryBody(SendAudio.AUDIO_FIELD, new java.io.File(sendAudio.getAudio()), ContentType.create("audio/mpeg"), sendAudio.getAudioName());
|
||||||
if (sendAudio.getReplayMarkup() != null) {
|
if (sendAudio.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toJson().toString());
|
builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toJson().toString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user