Change sendNew methods signature, now accepting File

This commit is contained in:
antonu17 2016-06-03 23:22:02 +06:00
parent 56ac18e263
commit ee12175eea
6 changed files with 54 additions and 47 deletions

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -36,8 +38,9 @@ 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 String audioName; private boolean isNewAudio; ///< True to upload a new audio, false to use a fileId
private File newAudioFile; ///< New audio file
public SendAudio() { public SendAudio() {
super(); super();
@ -80,13 +83,12 @@ public class SendAudio {
/** /**
* Use this method to set the audio to a new file * Use this method to set the audio to a new file
* *
* @param audio Path to the new file in your server * @param file New audio file
* @param audioName Name of the file itself
*/ */
public SendAudio setNewAudio(String audio, String audioName) { public SendAudio setNewAudio(File file) {
this.audio = audio; this.audio = file.getName();
this.isNewAudio = true; this.isNewAudio = true;
this.audioName = audioName; this.newAudioFile = file;
return this; return this;
} }
@ -144,8 +146,8 @@ public class SendAudio {
return isNewAudio; return isNewAudio;
} }
public String getAudioName() { public File getNewAudioFile() {
return audioName; return newAudioFile;
} }
@Override @Override
@ -158,7 +160,6 @@ public class SendAudio {
", performer='" + performer + '\'' + ", performer='" + performer + '\'' +
", title='" + title + '\'' + ", title='" + title + '\'' +
", isNewAudio=" + isNewAudio + ", isNewAudio=" + isNewAudio +
", audioName='" + audioName + '\'' +
'}'; '}';
} }
} }

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -28,8 +30,8 @@ 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 File newDocumentFile; ///< New document file
public SendDocument() { public SendDocument() {
super(); super();
@ -54,10 +56,10 @@ public class SendDocument {
return this; return this;
} }
public SendDocument setNewDocument(String document, String documentName) { public SendDocument setNewDocument(File file) {
this.document = document; this.document = file.getName();
this.isNewDocument = true; this.isNewDocument = true;
this.documentName = documentName; this.newDocumentFile = file;
return this; return this;
} }
@ -65,8 +67,8 @@ public class SendDocument {
return isNewDocument; return isNewDocument;
} }
public String getDocumentName() { public File getNewDocumentFile() {
return documentName; return newDocumentFile;
} }
public Integer getReplayToMessageId() { public Integer getReplayToMessageId() {
@ -118,7 +120,6 @@ public class SendDocument {
", replayToMessageId=" + replayToMessageId + ", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup + ", replayMarkup=" + replayMarkup +
", isNewDocument=" + isNewDocument + ", isNewDocument=" + isNewDocument +
", documentName='" + documentName + '\'' +
'}'; '}';
} }
} }

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -29,7 +31,7 @@ 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
public SendPhoto() { public SendPhoto() {
@ -86,8 +88,8 @@ public class SendPhoto {
return isNewPhoto; return isNewPhoto;
} }
public String getPhotoName() { public File getNewPhotoFile() {
return photoName; return newPhotoFile;
} }
public Boolean getDisableNotification() { public Boolean getDisableNotification() {
@ -104,10 +106,10 @@ public class SendPhoto {
return this; return this;
} }
public SendPhoto setNewPhoto(String photo, String photoName) { public SendPhoto setNewPhoto(File file) {
this.photo = photo; this.photo = file.getName();
this.newPhotoFile = file;
this.isNewPhoto = true; this.isNewPhoto = true;
this.photoName = photoName;
return this; return this;
} }
@ -120,7 +122,6 @@ public class SendPhoto {
", replayToMessageId=" + replayToMessageId + ", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup + ", replayMarkup=" + replayMarkup +
", isNewPhoto=" + isNewPhoto + ", isNewPhoto=" + isNewPhoto +
", photoName='" + photoName + '\'' +
'}'; '}';
} }
} }

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -26,8 +28,8 @@ 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 File newStickerFile; ///< New sticker file
public SendSticker() { public SendSticker() {
super(); super();
@ -70,10 +72,10 @@ public class SendSticker {
return this; return this;
} }
public SendSticker setSticker(String sticker, String stickerName) { public SendSticker setSticker(File file) {
this.sticker = sticker; this.sticker = file.getName();
this.isNewSticker = true; this.isNewSticker = true;
this.stickerName = stickerName; this.newStickerFile = file;
return this; return this;
} }
@ -95,8 +97,8 @@ public class SendSticker {
return isNewSticker; return isNewSticker;
} }
public String getStickerName() { public File getNewStickerFile() {
return stickerName; return newStickerFile;
} }
@Override @Override
@ -107,7 +109,6 @@ public class SendSticker {
", replayToMessageId=" + replayToMessageId + ", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup + ", replayMarkup=" + replayMarkup +
", isNewSticker=" + isNewSticker + ", isNewSticker=" + isNewSticker +
", stickerName='" + stickerName + '\'' +
'}'; '}';
} }
} }

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -36,7 +38,7 @@ 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
public SendVideo() { public SendVideo() {
super(); super();
@ -101,8 +103,8 @@ public class SendVideo {
return isNewVideo; return isNewVideo;
} }
public String getVideoName() { public File getNewVideoFile() {
return videoName; return newVideoFile;
} }
public Boolean getDisableNotification() { public Boolean getDisableNotification() {
@ -137,10 +139,10 @@ public class SendVideo {
return this; return this;
} }
public SendVideo setNewVideo(String video, String videoName) { public SendVideo setNewVideo(File file) {
this.video = video; this.video = file.getName();
this.isNewVideo = true; this.isNewVideo = true;
this.videoName = videoName; this.newVideoFile = file;
return this; return this;
} }
@ -154,7 +156,6 @@ public class SendVideo {
", replayToMessageId=" + replayToMessageId + ", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup + ", replayMarkup=" + replayMarkup +
", isNewVideo=" + isNewVideo + ", isNewVideo=" + isNewVideo +
", videoName='" + videoName + '\'' +
'}'; '}';
} }
} }

View File

@ -2,6 +2,8 @@ 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;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
@ -31,7 +33,7 @@ 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
public SendVoice() { public SendVoice() {
super(); super();
@ -81,10 +83,10 @@ public class SendVoice {
return this; return this;
} }
public SendVoice setNewAudio(String audio, String audioName) { public SendVoice setNewAudio(File file) {
this.audio = audio; this.audio = file.getName();
this.isNewVoice = false; this.isNewVoice = true;
this.voiceName = audioName; this.newVoiceFile = file;
return this; return this;
} }
@ -119,7 +121,7 @@ public class SendVoice {
return isNewVoice; return isNewVoice;
} }
public String getVoiceName() { public File getNewVoiceFile() {
return voiceName; return newVoiceFile;
} }
} }