Document deprecated methods
This commit is contained in:
parent
d8c2a1a22a
commit
ef66e35827
@ -88,6 +88,8 @@ public class SendAudio {
|
||||
*
|
||||
* @param audio Path to the new file in your server
|
||||
* @param audioName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewAudio(File)} or {@link #setNewAudio(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendAudio setNewAudio(String audio, String audioName) {
|
||||
|
@ -53,12 +53,26 @@ public class SendDocument {
|
||||
return document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to an document existing in Telegram system
|
||||
*
|
||||
* @param document File_id of the document to send
|
||||
* @note The file_id must have already been received or sent by your bot
|
||||
*/
|
||||
public SendDocument setDocument(String document) {
|
||||
this.document = document;
|
||||
this.isNewDocument = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to a new file
|
||||
*
|
||||
* @param document Path to the new file in your server
|
||||
* @param documentName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewDocument(File)} or {@link #setNewDocument(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendDocument setNewDocument(String document, String documentName) {
|
||||
this.document = document;
|
||||
@ -67,6 +81,11 @@ public class SendDocument {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to a new file
|
||||
*
|
||||
* @param file New document file
|
||||
*/
|
||||
public SendDocument setNewDocument(File file) {
|
||||
this.document = file.getName();
|
||||
this.isNewDocument = true;
|
||||
@ -74,6 +93,11 @@ public class SendDocument {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the document to a new file
|
||||
*
|
||||
* @param inputStream New document file
|
||||
*/
|
||||
public SendDocument setNewDocument(InputStream inputStream) {
|
||||
this.isNewDocument = true;
|
||||
this.newDocumentStream = inputStream;
|
||||
|
@ -116,6 +116,14 @@ public class SendPhoto {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the photo to a new file
|
||||
*
|
||||
* @param photo Path to the new file in your server
|
||||
* @param photoName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewPhoto(File)} or {@link #setNewPhoto(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendPhoto setNewPhoto(String photo, String photoName) {
|
||||
this.photo = photo;
|
||||
|
@ -75,6 +75,14 @@ public class SendSticker {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the sticker to a new file
|
||||
*
|
||||
* @param sticker Path to the new file in your server
|
||||
* @param stickerName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewSticker(File)} or {@link #setNewSticker(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendSticker setSticker(String sticker, String stickerName) {
|
||||
this.sticker = sticker;
|
||||
|
@ -150,6 +150,14 @@ public class SendVideo {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the video to a new file
|
||||
*
|
||||
* @param video Path to the new file in your server
|
||||
* @param videoName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewVideo(File)} or {@link #setNewVideo(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendVideo setNewVideo(String video, String videoName) {
|
||||
this.video = video;
|
||||
|
@ -17,13 +17,14 @@ public class SendVoice {
|
||||
public static final String PATH = "sendvoice";
|
||||
|
||||
public static final String CHATID_FIELD = "chat_id";
|
||||
public static final String AUDIO_FIELD = "audio";
|
||||
public static final String VOICE_FIELD = "voice";
|
||||
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.
|
||||
private String voice; ///< 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
|
||||
@ -46,7 +47,7 @@ public class SendVoice {
|
||||
public String toString() {
|
||||
return "SendVoice{" +
|
||||
"chatId='" + chatId + '\'' +
|
||||
", audio='" + audio + '\'' +
|
||||
", voice='" + voice + '\'' +
|
||||
", replayToMessageId=" + replayToMessageId +
|
||||
", replayMarkup=" + replayMarkup +
|
||||
", duration=" + duration +
|
||||
@ -76,32 +77,74 @@ public class SendVoice {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAudio() {
|
||||
return audio;
|
||||
}
|
||||
|
||||
public SendVoice setAudio(String audio) {
|
||||
this.audio = audio;
|
||||
this.isNewVoice = false;
|
||||
return this;
|
||||
public String getVoice() {
|
||||
return voice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getVoice()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public SendVoice setNewAudio(String audio, String audioName) {
|
||||
this.audio = audio;
|
||||
public String getAudio() {
|
||||
return voice;
|
||||
}
|
||||
|
||||
public SendVoice setVoice(String voice) {
|
||||
this.voice = voice;
|
||||
this.isNewVoice = false;
|
||||
this.voiceName = audioName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setNewAudio(File file) {
|
||||
this.audio = file.getName();
|
||||
/**
|
||||
* @deprecated Use {@link #setVoice(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public SendVoice setAudio(String voice) {
|
||||
this.voice = voice;
|
||||
this.isNewVoice = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the voice to a new file
|
||||
*
|
||||
* @param voice Path to the new file in your server
|
||||
* @param voiceName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewVoice(File)} or {@link #setNewVoice(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendVoice setNewVoice(String voice, String voiceName) {
|
||||
this.voice = voice;
|
||||
this.isNewVoice = false;
|
||||
this.voiceName = voiceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to set the voice to a new file
|
||||
*
|
||||
* @param voice Path to the new file in your server
|
||||
* @param voiceName Name of the file itself
|
||||
*
|
||||
* @deprecated use {@link #setNewVoice(File)} or {@link #setNewVoice(InputStream)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SendVoice setNewAudio(String voice, String voiceName) {
|
||||
this.voice = voice;
|
||||
this.isNewVoice = false;
|
||||
this.voiceName = voiceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setNewVoice(File file) {
|
||||
this.voice = file.getName();
|
||||
this.isNewVoice = true;
|
||||
this.newVoiceFile = file;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendVoice setNewAudio(InputStream inputStream) {
|
||||
public SendVoice setNewVoice(InputStream inputStream) {
|
||||
this.isNewVoice = true;
|
||||
this.newVoiceStream = inputStream;
|
||||
return this;
|
||||
|
@ -81,7 +81,7 @@ public abstract class AbsSender {
|
||||
private volatile RequestConfig requestConfig;
|
||||
private static final int SOCKET_TIMEOUT = 75 * 1000;
|
||||
|
||||
public AbsSender() {
|
||||
AbsSender() {
|
||||
httpclient = HttpClientBuilder.create()
|
||||
.setSSLHostnameVerifier(new NoopHostnameVerifier())
|
||||
.setConnectionTimeToLive(70, TimeUnit.SECONDS)
|
||||
@ -879,11 +879,11 @@ public abstract class AbsSender {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId());
|
||||
if (sendVoice.getNewVoiceFile() != null) {
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, sendVoice.getNewVoiceFile());
|
||||
builder.addBinaryBody(SendVoice.VOICE_FIELD, sendVoice.getNewVoiceFile());
|
||||
} else if (sendVoice.getNewVoiceStream() != null) {
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, sendVoice.getNewVoiceStream());
|
||||
builder.addBinaryBody(SendVoice.VOICE_FIELD, sendVoice.getNewVoiceStream());
|
||||
} else {
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, new java.io.File(sendVoice.getAudio()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
||||
builder.addBinaryBody(SendVoice.VOICE_FIELD, new java.io.File(sendVoice.getVoice()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
||||
}
|
||||
if (sendVoice.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||
@ -902,7 +902,7 @@ public abstract class AbsSender {
|
||||
} else {
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<>();
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.CHATID_FIELD, sendVoice.getChatId()));
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.AUDIO_FIELD, sendVoice.getAudio()));
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.VOICE_FIELD, sendVoice.getVoice()));
|
||||
if (sendVoice.getReplayMarkup() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user