Api version 4.2

This commit is contained in:
Rubenlagus 2019-04-08 01:43:46 +01:00 committed by Ruben Bermudez
parent d78acbdda0
commit 64b0be3154
24 changed files with 507 additions and 31 deletions

View File

@ -15,10 +15,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 3.1
* Use this method to pin a message in a supergroup or channel.
* The bot must be an administrator in the chat for this to work and must have the can_pin_messages
* admin right in the supergroup or can_edit_messages admin right in the channel.
* Returns True on success.
* Use this method to pin a message in a group, a supergroup or a channel.
* The bot must be an administrator in the chat for this to work and must
* have the can_pin_messages admin right in the supergroup or can_edit_messages
* admin right in the channel. Returns True on success.
*/
public class PinChatMessage extends BotApiMethod<Boolean> {
public static final String PATH = "pinChatMessage";

View File

@ -15,9 +15,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 3.1
* Use this method to unpin a message in a supergroup or channel.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns True on success.
* Use this method to unpin a message in a group, a supergroup or a channel.
* The bot must be an administrator in the chat for this to work and must have
* the can_pin_messages admin right in the supergroup or can_edit_messages
* admin right in the channel. Returns True on success.
*/
public class UnpinChatMessage extends BotApiMethod<Boolean> {
public static final String PATH = "unpinChatMessage";

View File

@ -0,0 +1,209 @@
package org.telegram.telegrambots.meta.api.methods.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send a native poll.
* A native poll can't be sent to a private chat.
*
* On success, the sent Message is returned.
*/
public class SendPoll extends BotApiMethod<Message> {
public static final String PATH = "sendPoll";
private static final String CHATID_FIELD = "chat_id";
private static final String QUESTION_FIELD = "question";
private static final String OPTIONS_FIELD = "options";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
@JsonProperty(CHATID_FIELD)
/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
* A native poll can't be sent to a private chat.
*/
private String chatId;
@JsonProperty(QUESTION_FIELD)
private String question; ///< Poll question, 1-255 characters
@JsonProperty(OPTIONS_FIELD)
private List<String> options; ///< List of answer options, 1-10 strings 1-100 characters each
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@JsonProperty(REPLYTOMESSAGEID_FIELD)
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
@JsonProperty(REPLYMARKUP_FIELD)
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public SendPoll() {
super();
}
public SendPoll(String chatId, String question, List<String> options) {
this.chatId = checkNotNull(chatId);
this.question = checkNotNull(question);
this.options = checkNotNull(options);
}
public SendPoll(Long chatId, String question, List<String> options) {
this.chatId = checkNotNull(chatId).toString();
this.question = checkNotNull(question);
this.options = checkNotNull(options);
}
public String getChatId() {
return chatId;
}
public SendPoll setChatId(String chatId) {
this.chatId = chatId;
return this;
}
public SendPoll setChatId(Long chatId) {
Objects.requireNonNull(chatId);
this.chatId = chatId.toString();
return this;
}
public String getQuestion() {
return question;
}
public SendPoll setQuestion(String question) {
this.question = question;
return this;
}
public List<String> getOptions() {
return options;
}
public SendPoll setOptions(List<String> options) {
this.options = options;
return this;
}
public Integer getReplyToMessageId() {
return replyToMessageId;
}
public SendPoll setReplyToMessageId(Integer replyToMessageId) {
this.replyToMessageId = replyToMessageId;
return this;
}
public ReplyKeyboard getReplyMarkup() {
return replyMarkup;
}
public SendPoll setReplyMarkup(ReplyKeyboard replyMarkup) {
this.replyMarkup = replyMarkup;
return this;
}
public Boolean getDisableNotification() {
return disableNotification;
}
public SendPoll enableNotification() {
this.disableNotification = null;
return this;
}
public SendPoll disableNotification() {
this.disableNotification = true;
return this;
}
@Override
public String getMethod() {
return PATH;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error sending poll", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (question == null || question.isEmpty()) {
throw new TelegramApiValidationException("Question parameter can't be empty", this);
}
if (options == null || options.isEmpty()) {
throw new TelegramApiValidationException("Options parameter can't be empty", this);
}
if (replyMarkup != null) {
replyMarkup.validate();
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof SendPoll)) {
return false;
}
SendPoll sendMessage = (SendPoll) o;
return Objects.equals(chatId, sendMessage.chatId)
&& Objects.equals(disableNotification, sendMessage.disableNotification)
&& Objects.equals(question, sendMessage.question)
&& Objects.equals(options, sendMessage.options)
&& Objects.equals(replyMarkup, sendMessage.replyMarkup)
&& Objects.equals(replyToMessageId, sendMessage.replyToMessageId)
;
}
@Override
public int hashCode() {
return Objects.hash(
chatId,
disableNotification,
options,
replyMarkup,
replyToMessageId,
question);
}
@Override
public String toString() {
return "SendPoll{" +
"chatId='" + chatId + '\'' +
", question='" + question + '\'' +
", options=" + options +
", disableNotification=" + disableNotification +
", replyToMessageId=" + replyToMessageId +
", replyMarkup=" + replyMarkup +
'}';
}
}

View File

@ -0,0 +1,119 @@
package org.telegram.telegrambots.meta.api.methods.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to stop a poll which was sent by the bot.
*
* On success, the stopped Poll with the final results is returned.
*/
public class StopPoll extends BotApiMethod<Poll> {
public static final String PATH = "stopPoll";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGEID_FIELD = "message_id";
@JsonProperty(CHATID_FIELD)
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Identifier of the original message with the poll
public StopPoll() {
super();
}
public StopPoll(String chatId, Integer messageId) {
this.chatId = checkNotNull(chatId);
this.messageId = checkNotNull(messageId);
}
public StopPoll(Long chatId, Integer messageId) {
this.chatId = checkNotNull(chatId).toString();
this.messageId = checkNotNull(messageId);
}
public String getChatId() {
return chatId;
}
public StopPoll setChatId(String chatId) {
this.chatId = chatId;
return this;
}
public StopPoll setChatId(Long chatId) {
Objects.requireNonNull(chatId);
this.chatId = chatId.toString();
return this;
}
@Override
public String getMethod() {
return PATH;
}
@Override
public Poll deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Poll> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Poll>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error stopping poll", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (messageId == null || messageId == 0) {
throw new TelegramApiValidationException("Message Id parameter can't be empty", this);
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof StopPoll)) {
return false;
}
StopPoll sendMessage = (StopPoll) o;
return Objects.equals(chatId, sendMessage.chatId)
&& Objects.equals(messageId, sendMessage.messageId)
;
}
@Override
public int hashCode() {
return Objects.hash(
chatId,
messageId);
}
@Override
public String toString() {
return "StopPoll{" +
"chatId='" + chatId + '\'' +
", messageId=" + messageId +
'}';
}
}

View File

@ -55,7 +55,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -50,7 +50,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass
* attach://<file_attach_name> if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -40,7 +40,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -49,7 +49,7 @@ public class SendVideo extends PartialBotApiMethod<Message> {
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -44,7 +44,7 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -16,12 +16,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author Ruben Bermudez
* @version 1.0
*
* Use this method to delete a message. A message can only be deleted if it was sent less than
* 48 hours ago. Any sent outgoing message may be deleted.
* Additionally, if the bot is an administrator in a group chat, it can delete any message.
* If the bot is an administrator of a supergroup or channel,
* it can delete ordinary messages from any other user,
* including service messages about people added or removed from the chat.
* Use this method to delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - Bots can delete outgoing messages in private chats, groups, and supergroups.
* - Bots can delete incoming messages in private chats.
* - Bots granted can_post_messages permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
* Returns True on success.
*/
public class DeleteMessage extends BotApiMethod<Boolean> {
public static final String PATH = "deleteMessage";

View File

@ -16,8 +16,8 @@ import java.io.Serializable;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to edit captions of messages sent by the bot or via the bot (for inline
* bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* Use this method to edit captions of messages.
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
*/
public class EditMessageCaption extends BotApiMethod<Serializable> {
public static final String PATH = "editmessagecaption";

View File

@ -17,7 +17,7 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
* Use this method to edit live location.
* A location can be edited until its live_period expires or editing is explicitly disabled by a call to
* stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned,
* otherwise True is returned.

View File

@ -16,8 +16,8 @@ import java.io.Serializable;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot
* (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned,
* @brief Use this method to edit only the reply markup of messages.
* On success, if edited message is sent by the bot, the edited Message is returned,
* therwise True is returned.
* @date 10 of April of 2016
*/

View File

@ -17,7 +17,7 @@ import java.io.Serializable;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit text messages sent by the bot or via the bot (for inline bots). On
* @brief Use this method to edit text messages. On
* success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @date 10 of April of 2016
*/

View File

@ -61,7 +61,7 @@ public class Chat implements BotApiObject {
@JsonProperty(INVITELINK_FIELD)
private String inviteLink; ///< Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
@JsonProperty(PINNEDMESSAGE_FIELD)
private Message pinnedMessage; ///< Optional. Pinned message, for supergroups. Returned only in getChat.
private Message pinnedMessage; ///< Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat.
@JsonProperty(STICKERSETNAME_FIELD)
private String stickerSetName; ///< Optional. For supergroups, name of Group sticker set. Returned only in getChat.
@JsonProperty(CANSETSTICKERSET_FIELD)

View File

@ -29,6 +29,7 @@ public class ChatMember implements BotApiObject {
private static final String CANSENDMEDIAMESSAGES_FIELD = "can_send_media_messages";
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews";
private static final String ISMEMBER_FIELD = "is_member";
@JsonProperty(USER_FIELD)
private User user; ///< Information about the user
@ -51,7 +52,7 @@ public class ChatMember implements BotApiObject {
@JsonProperty(CANRESTRICTUSERS_FIELD)
private Boolean canRestrictUsers; ///< Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
@JsonProperty(CANPINMESSAGES_FIELD)
private Boolean canPinMessages; ///< Optional. Administrators only. True, if the administrator can pin messages
private Boolean canPinMessages; ///< Optional. Administrators only. True, if the administrator can pin messages, groups and supergroups only
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
private Boolean canPromoteMembers; ///< Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that it has promoted, directly or indirectly (promoted by administrators that were appointed by the bot)
@JsonProperty(CANSENDMESSAGES_FIELD)
@ -62,6 +63,8 @@ public class ChatMember implements BotApiObject {
private Boolean canSendOtherMessages; ///< Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
@JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
private Boolean canAddWebPagePreviews; ///< Optional. Restricted only. True, if user may add web page previews Э to his messages, implies can_send_messages
@JsonProperty(ISMEMBER_FIELD)
private Boolean isMemberField; ///< True, if the user is a member of the chat at the moment of the request. For example, it can be false for the chat creator or for a restricted user.
public ChatMember() {
super();

View File

@ -62,6 +62,7 @@ public class Message implements BotApiObject {
private static final String MEDIAGROUPID_FIELD = "media_group_id";
private static final String CONNECTEDWEBSITE_FIELD = "connected_website";
private static final String PASSPORTDATA_FIELD = "passport_data";
private static final String FORWARDSENDERNAME_FIELD = "forward_sender_name";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@ -191,6 +192,8 @@ public class Message implements BotApiObject {
private String connectedWebsite; ///< Optional. The domain name of the website on which the user has logged in
@JsonProperty(PASSPORTDATA_FIELD)
private PassportData passportData; ///< Optional. Telegram Passport data
@JsonProperty(FORWARDSENDERNAME_FIELD)
private String forwardSenderName; ///< Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
public Message() {
super();
@ -478,6 +481,14 @@ public class Message implements BotApiObject {
return animation != null;
}
public String getForwardSenderName() {
return forwardSenderName;
}
public void setForwardSenderName(String forwardSenderName) {
this.forwardSenderName = forwardSenderName;
}
@Override
public String toString() {
return "Message{" +

View File

@ -1,12 +1,12 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.inlinequery.ChosenInlineQuery;
import org.telegram.telegrambots.meta.api.objects.inlinequery.InlineQuery;
import org.telegram.telegrambots.meta.api.objects.payments.PreCheckoutQuery;
import org.telegram.telegrambots.meta.api.objects.payments.ShippingQuery;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
/**
* @author Ruben Bermudez
@ -27,6 +27,7 @@ public class Update implements BotApiObject {
private static final String EDITEDCHANNELPOST_FIELD = "edited_channel_post";
private static final String SHIPPING_QUERY_FIELD = "shipping_query";
private static final String PRE_CHECKOUT_QUERY_FIELD = "pre_checkout_query";
private static final String POLL_FIELD = "poll";
@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
@ -48,6 +49,8 @@ public class Update implements BotApiObject {
private ShippingQuery shippingQuery; ///< Optional. New incoming shipping query. Only for invoices with flexible price
@JsonProperty(PRE_CHECKOUT_QUERY_FIELD)
private PreCheckoutQuery preCheckoutQuery; ///< Optional. New incoming pre-checkout query. Contains full information about checkout
@JsonProperty(POLL_FIELD)
private Poll poll; ///< Optional. New poll state. Bots receive only updates about polls, which are sent by the bot.
public Update() {
super();
@ -93,6 +96,10 @@ public class Update implements BotApiObject {
return preCheckoutQuery;
}
public Poll getPoll() {
return poll;
}
public boolean hasMessage() {
return message != null;
}
@ -129,6 +136,10 @@ public class Update implements BotApiObject {
return preCheckoutQuery != null;
}
public boolean hasPoll() {
return poll != null;
}
@Override
public String toString() {
return "Update{" +

View File

@ -27,7 +27,7 @@ public class InputMediaAnimation extends InputMedia<InputMediaAnimation> {
private Integer duration; ///< Optional. Animation duration
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -27,7 +27,7 @@ public class InputMediaAudio extends InputMedia<InputMediaAudio> {
private String title; ///< Optional. Title of the audio
/**
* Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -16,7 +16,7 @@ public class InputMediaDocument extends InputMedia<InputMediaDocument> {
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -30,7 +30,7 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> {
private Boolean supportsStreaming; ///< Optional. Pass True, if the uploaded video is suitable for streaming
/**
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnails width and height should not exceed 90.
* A thumbnails width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

View File

@ -0,0 +1,73 @@
package org.telegram.telegrambots.meta.api.objects.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 4.2
*
* This object contains information about a poll.
*/
public class Poll implements BotApiObject {
private static final String ID_FIELD = "id";
private static final String QUESTION_FIELD = "question";
private static final String OPTIONS_FIELD = "options";
private static final String ISCLOSED_FIELD = "is_closed";
@JsonProperty(ID_FIELD)
private String id; ///< Unique poll identifier
@JsonProperty(QUESTION_FIELD)
private String question; ///< Poll question, 1-255 characters
@JsonProperty(OPTIONS_FIELD)
private List<PollOption> options; ///< List of poll options
@JsonProperty(ISCLOSED_FIELD)
private Boolean isClosed; ///< True, if the poll is closed
public Poll() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public List<PollOption> getOptions() {
return options;
}
public void setOptions(List<PollOption> options) {
this.options = options;
}
public Boolean getClosed() {
return isClosed;
}
public void setClosed(Boolean closed) {
isClosed = closed;
}
@Override
public String toString() {
return "Poll{" +
"id='" + id + '\'' +
", question='" + question + '\'' +
", options=" + options +
", isClosed=" + isClosed +
'}';
}
}

View File

@ -0,0 +1,47 @@
package org.telegram.telegrambots.meta.api.objects.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 4.2
*
* This object contains information about one answer option in a poll.
*/
public class PollOption implements BotApiObject {
private static final String TEXT_FIELD = "text";
private static final String VOTERCOUNT_FIELD = "voter_count";
@JsonProperty(TEXT_FIELD)
private String text; ///< Option text, 1-100 characters
@JsonProperty(VOTERCOUNT_FIELD)
private Integer voterCount; ///< Number of users that voted for this option
public PollOption() {
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getVoterCount() {
return voterCount;
}
public void setVoterCount(Integer voterCount) {
this.voterCount = voterCount;
}
@Override
public String toString() {
return "PollOption{" +
"text='" + text + '\'' +
", voterCount=" + voterCount +
'}';
}
}