Deprecate old methods, overload setNew... methods with InputStream arguments

This commit is contained in:
antonu17 2016-06-04 10:15:55 +06:00
parent 7b6a376976
commit 65d82076c2
6 changed files with 157 additions and 2 deletions

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -40,7 +41,9 @@ public class SendAudio {
private String title; ///< Optional. Title of sent audio private String title; ///< Optional. Title of sent audio
private boolean isNewAudio; ///< True to upload a new audio, false to use a fileId private boolean isNewAudio; ///< True to upload a new audio, false to use a fileId
private String audioName;
private File newAudioFile; ///< New audio file private File newAudioFile; ///< New audio file
private InputStream newAudioStream; ///< New audio stream
public SendAudio() { public SendAudio() {
super(); super();
@ -80,6 +83,20 @@ public class SendAudio {
return this; return this;
} }
/**
* Use this method to set the audio to a new file
*
* @param audio Path to the new file in your server
* @param audioName Name of the file itself
*/
@Deprecated
public SendAudio setNewAudio(String audio, String audioName) {
this.audio = audio;
this.isNewAudio = true;
this.audioName = audioName;
return this;
}
/** /**
* Use this method to set the audio to a new file * Use this method to set the audio to a new file
* *
@ -92,6 +109,12 @@ public class SendAudio {
return this; 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;
} }
@ -146,10 +169,18 @@ public class SendAudio {
return isNewAudio; return isNewAudio;
} }
public String getAudioName() {
return audioName;
}
public File getNewAudioFile() { public File getNewAudioFile() {
return newAudioFile; return newAudioFile;
} }
public InputStream getNewAudioStream() {
return newAudioStream;
}
@Override @Override
public String toString() { public String toString() {
return "SendAudio{" + return "SendAudio{" +

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -31,7 +32,9 @@ public class SendDocument {
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; ///< True to upload a new document, false to use a fileId private boolean isNewDocument; ///< True to upload a new document, false to use a fileId
private String documentName;
private File newDocumentFile; ///< New document file private File newDocumentFile; ///< New document file
private InputStream newDocumentStream; ///< New document stream
public SendDocument() { public SendDocument() {
super(); super();
@ -56,6 +59,14 @@ public class SendDocument {
return this; return this;
} }
@Deprecated
public SendDocument setNewDocument(String document, String documentName) {
this.document = document;
this.isNewDocument = true;
this.documentName = documentName;
return this;
}
public SendDocument setNewDocument(File file) { public SendDocument setNewDocument(File file) {
this.document = file.getName(); this.document = file.getName();
this.isNewDocument = true; this.isNewDocument = true;
@ -63,14 +74,28 @@ public class SendDocument {
return this; 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;
} }
public String getDocumentName() {
return documentName;
}
public File getNewDocumentFile() { public File getNewDocumentFile() {
return newDocumentFile; return newDocumentFile;
} }
public InputStream getNewDocumentStream() {
return newDocumentStream;
}
public Integer getReplayToMessageId() { public Integer getReplayToMessageId() {
return replayToMessageId; return replayToMessageId;
} }

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -31,8 +32,9 @@ public class SendPhoto {
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 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 File newPhotoFile; // New photo file private File newPhotoFile; // New photo file
private InputStream newPhotoStream; // New photo stream
public SendPhoto() { public SendPhoto() {
super(); super();
@ -88,10 +90,18 @@ public class SendPhoto {
return isNewPhoto; return isNewPhoto;
} }
public String getPhotoName() {
return photoName;
}
public File getNewPhotoFile() { public File getNewPhotoFile() {
return newPhotoFile; return newPhotoFile;
} }
public InputStream getNewPhotoStream() {
return newPhotoStream;
}
public Boolean getDisableNotification() { public Boolean getDisableNotification() {
return disableNotification; return disableNotification;
} }
@ -106,6 +116,14 @@ public class SendPhoto {
return this; return this;
} }
@Deprecated
public SendPhoto setNewPhoto(String photo, String photoName) {
this.photo = photo;
this.isNewPhoto = true;
this.photoName = photoName;
return this;
}
public SendPhoto setNewPhoto(File file) { public SendPhoto setNewPhoto(File file) {
this.photo = file.getName(); this.photo = file.getName();
this.newPhotoFile = file; this.newPhotoFile = file;
@ -113,6 +131,12 @@ public class SendPhoto {
return this; 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{" +

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -29,7 +30,9 @@ public class SendSticker {
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; ///< True to upload a new sticker, false to use a fileId private boolean isNewSticker; ///< True to upload a new sticker, false to use a fileId
private String stickerName;
private File newStickerFile; ///< New sticker file private File newStickerFile; ///< New sticker file
private InputStream newStickerStream; ///< New sticker stream
public SendSticker() { public SendSticker() {
super(); super();
@ -72,13 +75,27 @@ public class SendSticker {
return this; return this;
} }
public SendSticker setSticker(File file) { @Deprecated
public SendSticker setSticker(String sticker, String stickerName) {
this.sticker = sticker;
this.isNewSticker = true;
this.stickerName = stickerName;
return this;
}
public SendSticker setNewSticker(File file) {
this.sticker = file.getName(); this.sticker = file.getName();
this.isNewSticker = true; this.isNewSticker = true;
this.newStickerFile = file; this.newStickerFile = file;
return this; 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;
} }
@ -97,10 +114,18 @@ public class SendSticker {
return isNewSticker; return isNewSticker;
} }
public String getStickerName() {
return stickerName;
}
public File getNewStickerFile() { public File getNewStickerFile() {
return newStickerFile; return newStickerFile;
} }
public InputStream getNewStickerStream() {
return newStickerStream;
}
@Override @Override
public String toString() { public String toString() {
return "SendSticker{" + return "SendSticker{" +

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -38,7 +39,9 @@ public class SendVideo {
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 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 File newVideoFile; ///< New video file private File newVideoFile; ///< New video file
private InputStream newVideoStream; ///< New video stream
public SendVideo() { public SendVideo() {
super(); super();
@ -103,10 +106,18 @@ public class SendVideo {
return isNewVideo; return isNewVideo;
} }
public String getVideoName() {
return videoName;
}
public File getNewVideoFile() { public File getNewVideoFile() {
return newVideoFile; return newVideoFile;
} }
public InputStream getNewVideoStream() {
return newVideoStream;
}
public Boolean getDisableNotification() { public Boolean getDisableNotification() {
return disableNotification; return disableNotification;
} }
@ -139,6 +150,14 @@ public class SendVideo {
return this; return this;
} }
@Deprecated
public SendVideo setNewVideo(String video, String videoName) {
this.video = video;
this.isNewVideo = true;
this.videoName = videoName;
return this;
}
public SendVideo setNewVideo(File file) { public SendVideo setNewVideo(File file) {
this.video = file.getName(); this.video = file.getName();
this.isNewVideo = true; this.isNewVideo = true;
@ -146,6 +165,12 @@ public class SendVideo {
return this; 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{" +

View File

@ -3,6 +3,7 @@ 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.File;
import java.io.InputStream;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -33,7 +34,9 @@ public class SendVoice {
private Integer duration; ///< Optional. Duration of sent audio in seconds private Integer duration; ///< Optional. Duration of sent audio in seconds
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 File newVoiceFile; ///< New voice note file private File newVoiceFile; ///< New voice note file
private InputStream newVoiceStream; ///< New voice note stream
public SendVoice() { public SendVoice() {
super(); super();
@ -83,6 +86,14 @@ public class SendVoice {
return this; return this;
} }
@Deprecated
public SendVoice setNewAudio(String audio, String audioName) {
this.audio = audio;
this.isNewVoice = false;
this.voiceName = audioName;
return this;
}
public SendVoice setNewAudio(File file) { public SendVoice setNewAudio(File file) {
this.audio = file.getName(); this.audio = file.getName();
this.isNewVoice = true; this.isNewVoice = true;
@ -90,6 +101,12 @@ public class SendVoice {
return this; 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;
} }
@ -121,7 +138,15 @@ public class SendVoice {
return isNewVoice; return isNewVoice;
} }
public String getVoiceName() {
return voiceName;
}
public File getNewVoiceFile() { public File getNewVoiceFile() {
return newVoiceFile; return newVoiceFile;
} }
public InputStream getNewVoiceStream() {
return newVoiceStream;
}
} }