From ee12175eeaffd919e3d240c43b7df5d767d42f04 Mon Sep 17 00:00:00 2001 From: antonu17 Date: Fri, 3 Jun 2016 23:22:02 +0600 Subject: [PATCH] Change sendNew methods signature, now accepting File --- .../api/methods/send/SendAudio.java | 21 ++++++++++--------- .../api/methods/send/SendDocument.java | 17 ++++++++------- .../api/methods/send/SendPhoto.java | 15 ++++++------- .../api/methods/send/SendSticker.java | 17 ++++++++------- .../api/methods/send/SendVideo.java | 15 ++++++------- .../api/methods/send/SendVoice.java | 16 +++++++------- 6 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java index 649906ca..6141adbd 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendAudio.java @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java index dacf2bb2..9f3ddbe7 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendDocument.java @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java index fcb59daa..18cb4802 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendPhoto.java @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java index b9c9cd9a..b67a0eaf 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendSticker.java @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java index 135ad939..25fbc004 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java index fb01b1ea..d6057548 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/send/SendVoice.java @@ -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; } }