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 java.io.File;
/**
* @author Ruben Bermudez
* @version 1.0
@ -36,8 +38,9 @@ public class SendAudio {
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private String performer; ///< Optional. Performer 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() {
super();
@ -80,13 +83,12 @@ public class SendAudio {
/**
* 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
* @param file New audio file
*/
public SendAudio setNewAudio(String audio, String audioName) {
this.audio = audio;
public SendAudio setNewAudio(File file) {
this.audio = file.getName();
this.isNewAudio = true;
this.audioName = audioName;
this.newAudioFile = file;
return this;
}
@ -144,8 +146,8 @@ public class SendAudio {
return isNewAudio;
}
public String getAudioName() {
return audioName;
public File getNewAudioFile() {
return newAudioFile;
}
@Override
@ -158,7 +160,6 @@ public class SendAudio {
", performer='" + performer + '\'' +
", title='" + title + '\'' +
", 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 java.io.File;
/**
* @author Ruben Bermudez
* @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 ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewDocument;
private String documentName;
private boolean isNewDocument; ///< True to upload a new document, false to use a fileId
private File newDocumentFile; ///< New document file
public SendDocument() {
super();
@ -54,10 +56,10 @@ public class SendDocument {
return this;
}
public SendDocument setNewDocument(String document, String documentName) {
this.document = document;
public SendDocument setNewDocument(File file) {
this.document = file.getName();
this.isNewDocument = true;
this.documentName = documentName;
this.newDocumentFile = file;
return this;
}
@ -65,8 +67,8 @@ public class SendDocument {
return isNewDocument;
}
public String getDocumentName() {
return documentName;
public File getNewDocumentFile() {
return newDocumentFile;
}
public Integer getReplayToMessageId() {
@ -118,7 +120,6 @@ public class SendDocument {
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
", 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 java.io.File;
/**
* @author Ruben Bermudez
* @version 1.0
@ -29,7 +31,7 @@ public class SendPhoto {
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 String photoName; ///< Name of the photo
private File newPhotoFile; // New photo file
public SendPhoto() {
@ -86,8 +88,8 @@ public class SendPhoto {
return isNewPhoto;
}
public String getPhotoName() {
return photoName;
public File getNewPhotoFile() {
return newPhotoFile;
}
public Boolean getDisableNotification() {
@ -104,10 +106,10 @@ public class SendPhoto {
return this;
}
public SendPhoto setNewPhoto(String photo, String photoName) {
this.photo = photo;
public SendPhoto setNewPhoto(File file) {
this.photo = file.getName();
this.newPhotoFile = file;
this.isNewPhoto = true;
this.photoName = photoName;
return this;
}
@ -120,7 +122,6 @@ public class SendPhoto {
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
", 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 java.io.File;
/**
* @author Ruben Bermudez
* @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 ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewSticker;
private String stickerName;
private boolean isNewSticker; ///< True to upload a new sticker, false to use a fileId
private File newStickerFile; ///< New sticker file
public SendSticker() {
super();
@ -70,10 +72,10 @@ public class SendSticker {
return this;
}
public SendSticker setSticker(String sticker, String stickerName) {
this.sticker = sticker;
public SendSticker setSticker(File file) {
this.sticker = file.getName();
this.isNewSticker = true;
this.stickerName = stickerName;
this.newStickerFile = file;
return this;
}
@ -95,8 +97,8 @@ public class SendSticker {
return isNewSticker;
}
public String getStickerName() {
return stickerName;
public File getNewStickerFile() {
return newStickerFile;
}
@Override
@ -107,7 +109,6 @@ public class SendSticker {
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
", 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 java.io.File;
/**
* @author Ruben Bermudez
* @version 1.0
@ -36,7 +38,7 @@ public class SendVideo {
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 String videoName; ///< Name of the video
private File newVideoFile; ///< New video file
public SendVideo() {
super();
@ -101,8 +103,8 @@ public class SendVideo {
return isNewVideo;
}
public String getVideoName() {
return videoName;
public File getNewVideoFile() {
return newVideoFile;
}
public Boolean getDisableNotification() {
@ -137,10 +139,10 @@ public class SendVideo {
return this;
}
public SendVideo setNewVideo(String video, String videoName) {
this.video = video;
public SendVideo setNewVideo(File file) {
this.video = file.getName();
this.isNewVideo = true;
this.videoName = videoName;
this.newVideoFile = file;
return this;
}
@ -154,7 +156,6 @@ public class SendVideo {
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
", 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 java.io.File;
/**
* @author Ruben Bermudez
* @version 1.0
@ -31,7 +33,7 @@ public class SendVoice {
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 String voiceName; ///< Name of the voice note
private File newVoiceFile; ///< New voice note file
public SendVoice() {
super();
@ -81,10 +83,10 @@ public class SendVoice {
return this;
}
public SendVoice setNewAudio(String audio, String audioName) {
this.audio = audio;
this.isNewVoice = false;
this.voiceName = audioName;
public SendVoice setNewAudio(File file) {
this.audio = file.getName();
this.isNewVoice = true;
this.newVoiceFile = file;
return this;
}
@ -119,7 +121,7 @@ public class SendVoice {
return isNewVoice;
}
public String getVoiceName() {
return voiceName;
public File getNewVoiceFile() {
return newVoiceFile;
}
}