Merge branch 'feature/improve_send_newfile' of https://github.com/antonu17/TelegramBots into antonu17-feature/improve_send_newfile
This commit is contained in:
commit
df985fc276
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -36,8 +39,11 @@ public class SendAudio {
|
|||||||
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||||
private String performer; ///< Optional. Performer of sent audio
|
private String performer; ///< Optional. Performer of sent audio
|
||||||
private String title; ///< Optional. Title of sent audio
|
private String title; ///< Optional. Title of sent audio
|
||||||
private boolean isNewAudio;
|
|
||||||
|
private boolean isNewAudio; ///< True to upload a new audio, false to use a fileId
|
||||||
private String audioName;
|
private String audioName;
|
||||||
|
private File newAudioFile; ///< New audio file
|
||||||
|
private InputStream newAudioStream; ///< New audio stream
|
||||||
|
|
||||||
public SendAudio() {
|
public SendAudio() {
|
||||||
super();
|
super();
|
||||||
@ -83,6 +89,7 @@ public class SendAudio {
|
|||||||
* @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
|
* @param audioName Name of the file itself
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public SendAudio setNewAudio(String audio, String audioName) {
|
public SendAudio setNewAudio(String audio, String audioName) {
|
||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
this.isNewAudio = true;
|
this.isNewAudio = true;
|
||||||
@ -90,6 +97,24 @@ public class SendAudio {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to set the audio to a new file
|
||||||
|
*
|
||||||
|
* @param file New audio file
|
||||||
|
*/
|
||||||
|
public SendAudio setNewAudio(File file) {
|
||||||
|
this.audio = file.getName();
|
||||||
|
this.isNewAudio = true;
|
||||||
|
this.newAudioFile = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendAudio setNewAudio(InputStream inputStream) {
|
||||||
|
this.isNewAudio = true;
|
||||||
|
this.newAudioStream = inputStream;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getReplayToMessageId() {
|
public Integer getReplayToMessageId() {
|
||||||
return replayToMessageId;
|
return replayToMessageId;
|
||||||
}
|
}
|
||||||
@ -148,6 +173,14 @@ public class SendAudio {
|
|||||||
return audioName;
|
return audioName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewAudioFile() {
|
||||||
|
return newAudioFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewAudioStream() {
|
||||||
|
return newAudioStream;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SendAudio{" +
|
return "SendAudio{" +
|
||||||
@ -158,7 +191,6 @@ public class SendAudio {
|
|||||||
", performer='" + performer + '\'' +
|
", performer='" + performer + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", isNewAudio=" + isNewAudio +
|
", isNewAudio=" + isNewAudio +
|
||||||
", audioName='" + audioName + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -28,8 +31,10 @@ public class SendDocument {
|
|||||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
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
|
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||||
|
|
||||||
private boolean isNewDocument;
|
private boolean isNewDocument; ///< True to upload a new document, false to use a fileId
|
||||||
private String documentName;
|
private String documentName;
|
||||||
|
private File newDocumentFile; ///< New document file
|
||||||
|
private InputStream newDocumentStream; ///< New document stream
|
||||||
|
|
||||||
public SendDocument() {
|
public SendDocument() {
|
||||||
super();
|
super();
|
||||||
@ -54,6 +59,7 @@ public class SendDocument {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SendDocument setNewDocument(String document, String documentName) {
|
public SendDocument setNewDocument(String document, String documentName) {
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.isNewDocument = true;
|
this.isNewDocument = true;
|
||||||
@ -61,6 +67,19 @@ public class SendDocument {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendDocument setNewDocument(File file) {
|
||||||
|
this.document = file.getName();
|
||||||
|
this.isNewDocument = true;
|
||||||
|
this.newDocumentFile = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendDocument setNewDocument(InputStream inputStream) {
|
||||||
|
this.isNewDocument = true;
|
||||||
|
this.newDocumentStream = inputStream;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isNewDocument() {
|
public boolean isNewDocument() {
|
||||||
return isNewDocument;
|
return isNewDocument;
|
||||||
}
|
}
|
||||||
@ -69,6 +88,14 @@ public class SendDocument {
|
|||||||
return documentName;
|
return documentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewDocumentFile() {
|
||||||
|
return newDocumentFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewDocumentStream() {
|
||||||
|
return newDocumentStream;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getReplayToMessageId() {
|
public Integer getReplayToMessageId() {
|
||||||
return replayToMessageId;
|
return replayToMessageId;
|
||||||
}
|
}
|
||||||
@ -118,7 +145,6 @@ public class SendDocument {
|
|||||||
", replayToMessageId=" + replayToMessageId +
|
", replayToMessageId=" + replayToMessageId +
|
||||||
", replayMarkup=" + replayMarkup +
|
", replayMarkup=" + replayMarkup +
|
||||||
", isNewDocument=" + isNewDocument +
|
", isNewDocument=" + isNewDocument +
|
||||||
", documentName='" + documentName + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -30,7 +33,8 @@ public class SendPhoto {
|
|||||||
|
|
||||||
private boolean isNewPhoto; ///< True if the photo must be uploaded from a file, file if it is a fileId
|
private boolean isNewPhoto; ///< True if the photo must be uploaded from a file, file if it is a fileId
|
||||||
private String photoName; ///< Name of the photo
|
private String photoName; ///< Name of the photo
|
||||||
|
private File newPhotoFile; // New photo file
|
||||||
|
private InputStream newPhotoStream; // New photo stream
|
||||||
|
|
||||||
public SendPhoto() {
|
public SendPhoto() {
|
||||||
super();
|
super();
|
||||||
@ -90,6 +94,14 @@ public class SendPhoto {
|
|||||||
return photoName;
|
return photoName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewPhotoFile() {
|
||||||
|
return newPhotoFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewPhotoStream() {
|
||||||
|
return newPhotoStream;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getDisableNotification() {
|
public Boolean getDisableNotification() {
|
||||||
return disableNotification;
|
return disableNotification;
|
||||||
}
|
}
|
||||||
@ -104,6 +116,7 @@ public class SendPhoto {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SendPhoto setNewPhoto(String photo, String photoName) {
|
public SendPhoto setNewPhoto(String photo, String photoName) {
|
||||||
this.photo = photo;
|
this.photo = photo;
|
||||||
this.isNewPhoto = true;
|
this.isNewPhoto = true;
|
||||||
@ -111,6 +124,19 @@ public class SendPhoto {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendPhoto setNewPhoto(File file) {
|
||||||
|
this.photo = file.getName();
|
||||||
|
this.newPhotoFile = file;
|
||||||
|
this.isNewPhoto = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendPhoto setNewPhoto(InputStream inputStream) {
|
||||||
|
this.newPhotoStream = inputStream;
|
||||||
|
this.isNewPhoto = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SendPhoto{" +
|
return "SendPhoto{" +
|
||||||
@ -120,7 +146,6 @@ public class SendPhoto {
|
|||||||
", replayToMessageId=" + replayToMessageId +
|
", replayToMessageId=" + replayToMessageId +
|
||||||
", replayMarkup=" + replayMarkup +
|
", replayMarkup=" + replayMarkup +
|
||||||
", isNewPhoto=" + isNewPhoto +
|
", isNewPhoto=" + isNewPhoto +
|
||||||
", photoName='" + photoName + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -26,8 +29,10 @@ public class SendSticker {
|
|||||||
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
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
|
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||||
|
|
||||||
private boolean isNewSticker;
|
private boolean isNewSticker; ///< True to upload a new sticker, false to use a fileId
|
||||||
private String stickerName;
|
private String stickerName;
|
||||||
|
private File newStickerFile; ///< New sticker file
|
||||||
|
private InputStream newStickerStream; ///< New sticker stream
|
||||||
|
|
||||||
public SendSticker() {
|
public SendSticker() {
|
||||||
super();
|
super();
|
||||||
@ -70,6 +75,7 @@ public class SendSticker {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SendSticker setSticker(String sticker, String stickerName) {
|
public SendSticker setSticker(String sticker, String stickerName) {
|
||||||
this.sticker = sticker;
|
this.sticker = sticker;
|
||||||
this.isNewSticker = true;
|
this.isNewSticker = true;
|
||||||
@ -77,6 +83,19 @@ public class SendSticker {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendSticker setNewSticker(File file) {
|
||||||
|
this.sticker = file.getName();
|
||||||
|
this.isNewSticker = true;
|
||||||
|
this.newStickerFile = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendSticker setNewSticker(InputStream inputStream) {
|
||||||
|
this.isNewSticker = true;
|
||||||
|
this.newStickerStream = inputStream;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getDisableNotification() {
|
public Boolean getDisableNotification() {
|
||||||
return disableNotification;
|
return disableNotification;
|
||||||
}
|
}
|
||||||
@ -99,6 +118,14 @@ public class SendSticker {
|
|||||||
return stickerName;
|
return stickerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewStickerFile() {
|
||||||
|
return newStickerFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewStickerStream() {
|
||||||
|
return newStickerStream;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SendSticker{" +
|
return "SendSticker{" +
|
||||||
@ -107,7 +134,6 @@ public class SendSticker {
|
|||||||
", replayToMessageId=" + replayToMessageId +
|
", replayToMessageId=" + replayToMessageId +
|
||||||
", replayMarkup=" + replayMarkup +
|
", replayMarkup=" + replayMarkup +
|
||||||
", isNewSticker=" + isNewSticker +
|
", isNewSticker=" + isNewSticker +
|
||||||
", stickerName='" + stickerName + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -37,6 +40,8 @@ public class SendVideo {
|
|||||||
|
|
||||||
private boolean isNewVideo; ///< True to upload a new video, false to use a fileId
|
private boolean isNewVideo; ///< True to upload a new video, false to use a fileId
|
||||||
private String videoName; ///< Name of the video
|
private String videoName; ///< Name of the video
|
||||||
|
private File newVideoFile; ///< New video file
|
||||||
|
private InputStream newVideoStream; ///< New video stream
|
||||||
|
|
||||||
public SendVideo() {
|
public SendVideo() {
|
||||||
super();
|
super();
|
||||||
@ -105,6 +110,14 @@ public class SendVideo {
|
|||||||
return videoName;
|
return videoName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewVideoFile() {
|
||||||
|
return newVideoFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewVideoStream() {
|
||||||
|
return newVideoStream;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getDisableNotification() {
|
public Boolean getDisableNotification() {
|
||||||
return disableNotification;
|
return disableNotification;
|
||||||
}
|
}
|
||||||
@ -137,6 +150,7 @@ public class SendVideo {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SendVideo setNewVideo(String video, String videoName) {
|
public SendVideo setNewVideo(String video, String videoName) {
|
||||||
this.video = video;
|
this.video = video;
|
||||||
this.isNewVideo = true;
|
this.isNewVideo = true;
|
||||||
@ -144,6 +158,19 @@ public class SendVideo {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendVideo setNewVideo(File file) {
|
||||||
|
this.video = file.getName();
|
||||||
|
this.isNewVideo = true;
|
||||||
|
this.newVideoFile = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendVideo setNewVideo(InputStream inputStream) {
|
||||||
|
this.isNewVideo = true;
|
||||||
|
this.newVideoStream = inputStream;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SendVideo{" +
|
return "SendVideo{" +
|
||||||
@ -154,7 +181,6 @@ public class SendVideo {
|
|||||||
", replayToMessageId=" + replayToMessageId +
|
", replayToMessageId=" + replayToMessageId +
|
||||||
", replayMarkup=" + replayMarkup +
|
", replayMarkup=" + replayMarkup +
|
||||||
", isNewVideo=" + isNewVideo +
|
", isNewVideo=" + isNewVideo +
|
||||||
", videoName='" + videoName + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package org.telegram.telegrambots.api.methods.send;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -32,6 +35,8 @@ public class SendVoice {
|
|||||||
|
|
||||||
private boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
|
private boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
|
||||||
private String voiceName; ///< Name of the voice note
|
private String voiceName; ///< Name of the voice note
|
||||||
|
private File newVoiceFile; ///< New voice note file
|
||||||
|
private InputStream newVoiceStream; ///< New voice note stream
|
||||||
|
|
||||||
public SendVoice() {
|
public SendVoice() {
|
||||||
super();
|
super();
|
||||||
@ -81,6 +86,7 @@ public class SendVoice {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SendVoice setNewAudio(String audio, String audioName) {
|
public SendVoice setNewAudio(String audio, String audioName) {
|
||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
this.isNewVoice = false;
|
this.isNewVoice = false;
|
||||||
@ -88,6 +94,19 @@ public class SendVoice {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SendVoice setNewAudio(File file) {
|
||||||
|
this.audio = file.getName();
|
||||||
|
this.isNewVoice = true;
|
||||||
|
this.newVoiceFile = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendVoice setNewAudio(InputStream inputStream) {
|
||||||
|
this.isNewVoice = true;
|
||||||
|
this.newVoiceStream = inputStream;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getReplayToMessageId() {
|
public Integer getReplayToMessageId() {
|
||||||
return replayToMessageId;
|
return replayToMessageId;
|
||||||
}
|
}
|
||||||
@ -122,4 +141,12 @@ public class SendVoice {
|
|||||||
public String getVoiceName() {
|
public String getVoiceName() {
|
||||||
return voiceName;
|
return voiceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getNewVoiceFile() {
|
||||||
|
return newVoiceFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getNewVoiceStream() {
|
||||||
|
return newVoiceStream;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,13 @@ public abstract class AbsSender {
|
|||||||
if (sendDocument.isNewDocument()) {
|
if (sendDocument.isNewDocument()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId());
|
builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId());
|
||||||
|
if (sendDocument.getNewDocumentFile() != null) {
|
||||||
|
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, sendDocument.getNewDocumentFile());
|
||||||
|
} else if (sendDocument.getNewDocumentStream() != null) {
|
||||||
|
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, sendDocument.getNewDocumentStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, new java.io.File(sendDocument.getDocument()), ContentType.APPLICATION_OCTET_STREAM, sendDocument.getDocumentName());
|
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, new java.io.File(sendDocument.getDocument()), ContentType.APPLICATION_OCTET_STREAM, sendDocument.getDocumentName());
|
||||||
|
}
|
||||||
if (sendDocument.getReplayMarkup() != null) {
|
if (sendDocument.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, sendDocument.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, sendDocument.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
@ -564,7 +570,13 @@ public abstract class AbsSender {
|
|||||||
if (sendPhoto.isNewPhoto()) {
|
if (sendPhoto.isNewPhoto()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId());
|
builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId());
|
||||||
|
if (sendPhoto.getNewPhotoFile() != null) {
|
||||||
|
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, sendPhoto.getNewPhotoFile());
|
||||||
|
} else if (sendPhoto.getNewPhotoStream() != null) {
|
||||||
|
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, sendPhoto.getNewPhotoStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, new java.io.File(sendPhoto.getPhoto()), ContentType.APPLICATION_OCTET_STREAM, sendPhoto.getPhotoName());
|
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, new java.io.File(sendPhoto.getPhoto()), ContentType.APPLICATION_OCTET_STREAM, sendPhoto.getPhotoName());
|
||||||
|
}
|
||||||
if (sendPhoto.getReplayMarkup() != null) {
|
if (sendPhoto.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendPhoto.REPLYMARKUP_FIELD, sendPhoto.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendPhoto.REPLYMARKUP_FIELD, sendPhoto.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
@ -624,7 +636,13 @@ public abstract class AbsSender {
|
|||||||
if (sendVideo.isNewVideo()) {
|
if (sendVideo.isNewVideo()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId());
|
builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId());
|
||||||
|
if (sendVideo.getNewVideoFile() != null) {
|
||||||
|
builder.addBinaryBody(SendVideo.VIDEO_FIELD, sendVideo.getNewVideoFile());
|
||||||
|
} else if (sendVideo.getNewVideoStream() != null) {
|
||||||
|
builder.addBinaryBody(SendVideo.VIDEO_FIELD, sendVideo.getNewVideoStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendVideo.VIDEO_FIELD, new java.io.File(sendVideo.getVideo()), ContentType.APPLICATION_OCTET_STREAM, sendVideo.getVideoName());
|
builder.addBinaryBody(SendVideo.VIDEO_FIELD, new java.io.File(sendVideo.getVideo()), ContentType.APPLICATION_OCTET_STREAM, sendVideo.getVideoName());
|
||||||
|
}
|
||||||
if (sendVideo.getReplayMarkup() != null) {
|
if (sendVideo.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendVideo.REPLYMARKUP_FIELD, sendVideo.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendVideo.REPLYMARKUP_FIELD, sendVideo.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
@ -703,7 +721,13 @@ public abstract class AbsSender {
|
|||||||
if (sendSticker.isNewSticker()) {
|
if (sendSticker.isNewSticker()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId());
|
builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId());
|
||||||
|
if (sendSticker.getNewStickerFile() != null) {
|
||||||
|
builder.addBinaryBody(SendSticker.STICKER_FIELD, sendSticker.getNewStickerFile());
|
||||||
|
} else if (sendSticker.getNewStickerStream() != null) {
|
||||||
|
builder.addBinaryBody(SendSticker.STICKER_FIELD, sendSticker.getNewStickerStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendSticker.STICKER_FIELD, new java.io.File(sendSticker.getSticker()), ContentType.APPLICATION_OCTET_STREAM, sendSticker.getStickerName());
|
builder.addBinaryBody(SendSticker.STICKER_FIELD, new java.io.File(sendSticker.getSticker()), ContentType.APPLICATION_OCTET_STREAM, sendSticker.getStickerName());
|
||||||
|
}
|
||||||
if (sendSticker.getReplayMarkup() != null) {
|
if (sendSticker.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendSticker.REPLYMARKUP_FIELD, sendSticker.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendSticker.REPLYMARKUP_FIELD, sendSticker.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
@ -765,7 +789,13 @@ 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());
|
||||||
|
if (sendAudio.getNewAudioFile() != null) {
|
||||||
|
builder.addBinaryBody(SendAudio.AUDIO_FIELD, sendAudio.getNewAudioFile());
|
||||||
|
} else if (sendAudio.getNewAudioStream() != null) {
|
||||||
|
builder.addBinaryBody(SendAudio.AUDIO_FIELD, sendAudio.getNewAudioStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendAudio.AUDIO_FIELD, new java.io.File(sendAudio.getAudio()), ContentType.create("audio/mpeg"), 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(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
@ -833,6 +863,7 @@ public abstract class AbsSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice)
|
* Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice)
|
||||||
|
* For this to work, your audio must be in an .ogg file encoded with OPUS
|
||||||
* @param sendVoice Information to send
|
* @param sendVoice Information to send
|
||||||
* @return If success, the sent Message is returned
|
* @return If success, the sent Message is returned
|
||||||
* @throws TelegramApiException If there is any error sending the audio
|
* @throws TelegramApiException If there is any error sending the audio
|
||||||
@ -847,7 +878,13 @@ public abstract class AbsSender {
|
|||||||
if (sendVoice.isNewVoice()) {
|
if (sendVoice.isNewVoice()) {
|
||||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId());
|
builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId());
|
||||||
|
if (sendVoice.getNewVoiceFile() != null) {
|
||||||
|
builder.addBinaryBody(SendVoice.AUDIO_FIELD, sendVoice.getNewVoiceFile());
|
||||||
|
} else if (sendVoice.getNewVoiceStream() != null) {
|
||||||
|
builder.addBinaryBody(SendVoice.AUDIO_FIELD, sendVoice.getNewVoiceStream());
|
||||||
|
} else {
|
||||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, new java.io.File(sendVoice.getAudio()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
builder.addBinaryBody(SendVoice.AUDIO_FIELD, new java.io.File(sendVoice.getAudio()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
||||||
|
}
|
||||||
if (sendVoice.getReplayMarkup() != null) {
|
if (sendVoice.getReplayMarkup() != null) {
|
||||||
builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user