TDLightTelegramBots/src/main/java/org/telegram/telegrambots/api/methods/send/SendVideo.java

195 lines
5.6 KiB
Java
Raw Normal View History

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
import java.io.File;
import java.io.InputStream;
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
private String videoName; ///< Name of the video
private File newVideoFile; ///< New video file
private InputStream newVideoStream; ///< New video stream
2016-01-14 01:14:53 +01:00
public SendVideo() {
super();
}
public String getChatId() {
return chatId;
}
public SendVideo setChatId(String chatId) {
2016-01-14 01:14:53 +01:00
this.chatId = chatId;
return this;
2016-01-14 01:14:53 +01:00
}
public String getVideo() {
return video;
}
public SendVideo setVideo(String video) {
2016-04-11 02:53:53 +02:00
this.video = video;
this.isNewVideo = false;
return this;
2016-04-11 02:53:53 +02:00
}
2016-01-14 01:14:53 +01:00
public Integer getDuration() {
return duration;
}
public SendVideo setDuration(Integer duration) {
2016-01-14 01:14:53 +01:00
this.duration = duration;
return this;
2016-01-14 01:14:53 +01:00
}
public String getCaption() {
return caption;
}
public SendVideo setCaption(String caption) {
2016-01-14 01:14:53 +01:00
this.caption = caption;
return this;
2016-01-14 01:14:53 +01:00
}
public Integer getReplayToMessageId() {
return replayToMessageId;
}
public SendVideo setReplayToMessageId(Integer replayToMessageId) {
2016-01-14 01:14:53 +01:00
this.replayToMessageId = replayToMessageId;
return this;
2016-01-14 01:14:53 +01:00
}
public ReplyKeyboard getReplayMarkup() {
return replayMarkup;
}
public SendVideo setReplayMarkup(ReplyKeyboard replayMarkup) {
2016-01-14 01:14:53 +01:00
this.replayMarkup = replayMarkup;
return this;
2016-01-14 01:14:53 +01:00
}
public boolean isNewVideo() {
return isNewVideo;
}
public String getVideoName() {
return videoName;
}
public File getNewVideoFile() {
return newVideoFile;
2016-01-14 01:14:53 +01:00
}
public InputStream getNewVideoStream() {
return newVideoStream;
}
2016-02-27 03:17:06 +01:00
public Boolean getDisableNotification() {
return disableNotification;
}
public SendVideo enableNotification() {
2016-02-27 03:17:06 +01:00
this.disableNotification = false;
return this;
2016-02-27 03:17:06 +01:00
}
public SendVideo disableNotification() {
2016-02-27 03:17:06 +01:00
this.disableNotification = true;
return this;
2016-02-27 03:17:06 +01:00
}
public Integer getWidth() {
return width;
}
public SendVideo setWidth(Integer width) {
2016-02-27 03:17:06 +01:00
this.width = width;
return this;
2016-02-27 03:17:06 +01:00
}
public Integer getHeight() {
return height;
}
public SendVideo setHeight(Integer height) {
2016-02-27 03:17:06 +01:00
this.height = height;
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.
*/
@Deprecated
public SendVideo setNewVideo(String video, String videoName) {
this.video = video;
this.isNewVideo = true;
this.videoName = videoName;
return this;
}
public SendVideo setNewVideo(File file) {
this.video = file.getName();
2016-01-14 01:14:53 +01:00
this.isNewVideo = true;
this.newVideoFile = file;
return this;
2016-01-14 01:14:53 +01:00
}
public SendVideo setNewVideo(InputStream inputStream) {
this.isNewVideo = true;
this.newVideoStream = inputStream;
return this;
}
@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
}