2016-04-11 02:53:53 +02:00
|
|
|
package org.telegram.telegrambots.api.methods.send;
|
2016-01-14 01:14:53 +01:00
|
|
|
|
2016-04-11 02:53:53 +02:00
|
|
|
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
|
2016-01-14 01:14:53 +01:00
|
|
|
|
2016-06-03 19:22:02 +02:00
|
|
|
import java.io.File;
|
2016-06-04 06:15:55 +02:00
|
|
|
import java.io.InputStream;
|
2016-06-03 19:22:02 +02:00
|
|
|
|
2016-01-14 01:14:53 +01:00
|
|
|
/**
|
|
|
|
* @author Ruben Bermudez
|
|
|
|
* @version 1.0
|
2016-04-11 02:53:53 +02:00
|
|
|
* @brief Use this method to send video files, Telegram clients support mp4 videos (other formats
|
|
|
|
* may be sent as Document). On success, the sent Message is returned.
|
2016-01-14 01:14:53 +01:00
|
|
|
* @date 20 of June of 2015
|
|
|
|
*/
|
|
|
|
public class SendVideo {
|
|
|
|
public static final String PATH = "sendvideo";
|
|
|
|
|
|
|
|
public static final String CHATID_FIELD = "chat_id";
|
|
|
|
public static final String VIDEO_FIELD = "video";
|
|
|
|
public static final String DURATION_FIELD = "duration";
|
|
|
|
public static final String CAPTION_FIELD = "caption";
|
2016-02-27 03:17:06 +01:00
|
|
|
public static final String WIDTH_FIELD = "width";
|
|
|
|
public static final String HEIGHT_FIELD = "height";
|
|
|
|
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
2016-04-11 02:53:53 +02:00
|
|
|
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
|
|
|
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
|
|
|
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
|
|
|
private String video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers
|
|
|
|
private Integer duration; ///< Optional. Duration of sent video in seconds
|
|
|
|
private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
|
|
|
|
private Integer width; ///< Optional. Video width
|
|
|
|
private Integer height; ///< OptionaL. Video height
|
2016-02-27 03:17:06 +01:00
|
|
|
/**
|
2016-04-11 02:53:53 +02:00
|
|
|
* 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
|
2016-02-27 03:17:06 +01:00
|
|
|
*/
|
|
|
|
private Boolean disableNotification;
|
2016-01-14 01:14:53 +01:00
|
|
|
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 isNewVideo; ///< True to upload a new video, false to use a fileId
|
2016-06-04 06:15:55 +02:00
|
|
|
private String videoName; ///< Name of the video
|
2016-06-03 19:22:02 +02:00
|
|
|
private File newVideoFile; ///< New video file
|
2016-06-04 06:15:55 +02:00
|
|
|
private InputStream newVideoStream; ///< New video stream
|
2016-01-14 01:14:53 +01:00
|
|
|
|
|
|
|
public SendVideo() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getChatId() {
|
|
|
|
return chatId;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setChatId(String chatId) {
|
2016-01-14 01:14:53 +01:00
|
|
|
this.chatId = chatId;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getVideo() {
|
|
|
|
return video;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setVideo(String video) {
|
2016-04-11 02:53:53 +02:00
|
|
|
this.video = video;
|
|
|
|
this.isNewVideo = false;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-04-11 02:53:53 +02:00
|
|
|
}
|
|
|
|
|
2016-01-14 01:14:53 +01:00
|
|
|
public Integer getDuration() {
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setDuration(Integer duration) {
|
2016-01-14 01:14:53 +01:00
|
|
|
this.duration = duration;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getCaption() {
|
|
|
|
return caption;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setCaption(String caption) {
|
2016-01-14 01:14:53 +01:00
|
|
|
this.caption = caption;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Integer getReplayToMessageId() {
|
|
|
|
return replayToMessageId;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setReplayToMessageId(Integer replayToMessageId) {
|
2016-01-14 01:14:53 +01:00
|
|
|
this.replayToMessageId = replayToMessageId;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public ReplyKeyboard getReplayMarkup() {
|
|
|
|
return replayMarkup;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setReplayMarkup(ReplyKeyboard replayMarkup) {
|
2016-01-14 01:14:53 +01:00
|
|
|
this.replayMarkup = replayMarkup;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isNewVideo() {
|
|
|
|
return isNewVideo;
|
|
|
|
}
|
|
|
|
|
2016-06-04 06:15:55 +02:00
|
|
|
public String getVideoName() {
|
|
|
|
return videoName;
|
|
|
|
}
|
|
|
|
|
2016-06-03 19:22:02 +02:00
|
|
|
public File getNewVideoFile() {
|
|
|
|
return newVideoFile;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
|
2016-06-04 06:15:55 +02:00
|
|
|
public InputStream getNewVideoStream() {
|
|
|
|
return newVideoStream;
|
|
|
|
}
|
|
|
|
|
2016-02-27 03:17:06 +01:00
|
|
|
public Boolean getDisableNotification() {
|
|
|
|
return disableNotification;
|
|
|
|
}
|
|
|
|
|
2016-04-12 22:26:59 +02:00
|
|
|
public SendVideo enableNotification() {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.disableNotification = false;
|
2016-04-12 22:26:59 +02:00
|
|
|
return this;
|
2016-02-27 03:17:06 +01:00
|
|
|
}
|
|
|
|
|
2016-04-12 22:26:59 +02:00
|
|
|
public SendVideo disableNotification() {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.disableNotification = true;
|
2016-04-12 22:26:59 +02:00
|
|
|
return this;
|
2016-02-27 03:17:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Integer getWidth() {
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setWidth(Integer width) {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.width = width;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-02-27 03:17:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Integer getHeight() {
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:25:54 +02:00
|
|
|
public SendVideo setHeight(Integer height) {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.height = height;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-02-27 03:17:06 +01:00
|
|
|
}
|
|
|
|
|
2016-06-09 22:52:08 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-06-04 06:15:55 +02:00
|
|
|
@Deprecated
|
|
|
|
public SendVideo setNewVideo(String video, String videoName) {
|
|
|
|
this.video = video;
|
|
|
|
this.isNewVideo = true;
|
|
|
|
this.videoName = videoName;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-06-03 19:22:02 +02:00
|
|
|
public SendVideo setNewVideo(File file) {
|
|
|
|
this.video = file.getName();
|
2016-01-14 01:14:53 +01:00
|
|
|
this.isNewVideo = true;
|
2016-06-03 19:22:02 +02:00
|
|
|
this.newVideoFile = file;
|
2016-04-12 21:25:54 +02:00
|
|
|
return this;
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
2016-03-08 20:17:07 +01:00
|
|
|
|
2016-06-04 06:15:55 +02:00
|
|
|
public SendVideo setNewVideo(InputStream inputStream) {
|
|
|
|
this.isNewVideo = true;
|
|
|
|
this.newVideoStream = inputStream;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:17:07 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "SendVideo{" +
|
|
|
|
"chatId='" + chatId + '\'' +
|
|
|
|
", video='" + video + '\'' +
|
|
|
|
", duration=" + duration +
|
|
|
|
", caption='" + caption + '\'' +
|
|
|
|
", replayToMessageId=" + replayToMessageId +
|
|
|
|
", replayMarkup=" + replayMarkup +
|
|
|
|
", isNewVideo=" + isNewVideo +
|
|
|
|
'}';
|
|
|
|
}
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|