commit
45671f1bab
10
README.md
10
README.md
@ -1,7 +1,7 @@
|
||||
# Telegram Bot Java Library
|
||||
[![Telegram](/TelegramBots.svg)](https://telegram.me/JavaBotsApi)
|
||||
|
||||
|
||||
[![Build Status](https://telegrambots.teamcity.com/app/rest/builds/buildType:(id:TelegramBots_TelegramBotsBuild)/statusIcon.svg)](https://telegrambots.teamcity.com/viewType.html?buildTypeId=TelegramBots_TelegramBotsBuild)
|
||||
[![Build Status](https://travis-ci.org/rubenlagus/TelegramBots.svg?branch=master)](https://travis-ci.org/rubenlagus/TelegramBots)
|
||||
[![Jitpack](https://jitpack.io/v/rubenlagus/TelegramBots.svg)](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.telegram/telegrambots/badge.svg)](http://mvnrepository.com/artifact/org.telegram/telegrambots)
|
||||
@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
2. Using Gradle:
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots:5.1.1'
|
||||
implementation 'org.telegram:telegrambots:5.2.0'
|
||||
```
|
||||
|
||||
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.1.1)
|
||||
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.1.1)
|
||||
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.2.0)
|
||||
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.2.0)
|
||||
|
||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
### <a id="5.2.0"></a>5.2.0 ###
|
||||
1. Update Api version [5.2](https://core.telegram.org/bots/api#april-26-2021)
|
||||
2. Allow custom BackOff implementations
|
||||
3. Spring version 2.4.5 in spring module
|
||||
4. Bug fixing: #869, #888 and #892
|
||||
|
||||
### <a id="5.1.1"></a>5.1.1 ###
|
||||
1. Bug fixing: #874
|
||||
|
||||
|
@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
* With **Gradle**:
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots:5.1.1'
|
||||
implementation 'org.telegram:telegrambots:5.2.0'
|
||||
```
|
||||
|
||||
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
||||
|
@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
* **Gradle**
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots-abilities:5.1.1'
|
||||
implementation 'org.telegram:telegrambots-abilities:5.2.0'
|
||||
```
|
||||
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
|
||||
<modules>
|
||||
<module>telegrambots</module>
|
||||
|
@ -18,14 +18,14 @@ Usage
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
**Gradle**
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots-abilities:5.1.1'
|
||||
implementation 'org.telegram:telegrambots-abilities:5.2.0'
|
||||
```
|
||||
|
||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -15,14 +15,14 @@ Usage
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
**Gradle**
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots-chat-session-bot:5.1.1'
|
||||
implementation 'org.telegram:telegrambots-chat-session-bot:5.2.0'
|
||||
```
|
||||
|
||||
Motivation
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||
@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
||||
|
@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambotsextensions</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
2. Using Gradle:
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambotsextensions:5.1.1'
|
||||
implementation 'org.telegram:telegrambotsextensions:5.2.0'
|
||||
```
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambotsextensions</artifactId>
|
||||
@ -75,7 +75,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-meta</artifactId>
|
||||
|
@ -3,22 +3,31 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @brief Types of actions for SendChatAction method.
|
||||
* @date 20 of June of 2016
|
||||
* Types of actions for SendChatAction method.
|
||||
*/
|
||||
public enum ActionType {
|
||||
TYPING("typing"),
|
||||
RECORDVIDEO("record_video"),
|
||||
RECORDVIDEONOTE("record_video_note"),
|
||||
/**
|
||||
* @deprecated Use {@link #RECORDVOICE} instead
|
||||
*/
|
||||
@Deprecated
|
||||
RECORDAUDIO("record_audio"),
|
||||
RECORDVOICE("record_voice"),
|
||||
UPLOADPHOTO("upload_photo"),
|
||||
UPLOADVIDEO("upload_video"),
|
||||
UPLOADVIDEONOTE("upload_video_note"),
|
||||
/**
|
||||
* @deprecated Use {@link #UPLOADVOICE} instead
|
||||
*/
|
||||
@Deprecated
|
||||
UPLOADAUDIO("upload_audio"),
|
||||
UPLOADVOICE("upload_voice"),
|
||||
UPLOADDOCUMENT("upload_document"),
|
||||
FINDLOCATION("find_location");
|
||||
|
||||
private String text;
|
||||
private final String text;
|
||||
|
||||
ActionType(String text) {
|
||||
this.text = text;
|
||||
@ -41,7 +50,8 @@ public enum ActionType {
|
||||
case "record_video_note":
|
||||
return RECORDVIDEONOTE;
|
||||
case "record_audio":
|
||||
return RECORDAUDIO;
|
||||
case "record_voice":
|
||||
return RECORDVOICE;
|
||||
case "upload_photo":
|
||||
return UPLOADPHOTO;
|
||||
case "upload_video":
|
||||
@ -49,7 +59,8 @@ public enum ActionType {
|
||||
case "upload_video_note":
|
||||
return UPLOADVIDEONOTE;
|
||||
case "upload_audio":
|
||||
return UPLOADAUDIO;
|
||||
case "upload_voice":
|
||||
return UPLOADVOICE;
|
||||
case "upload_document":
|
||||
return UPLOADDOCUMENT;
|
||||
case "find_location":
|
||||
|
@ -25,8 +25,10 @@ import java.util.List;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to copy messages of any kind. The method is analogous to the method forwardMessages,
|
||||
* but the copied message doesn't have a link to the original message.
|
||||
* Use this method to copy messages of any kind.
|
||||
* Service messages and invoice messages can't be copied.
|
||||
*
|
||||
* The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message.
|
||||
* Returns the MessageId of the sent message on success.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@ -138,7 +140,7 @@ public class CopyMessage extends BotApiMethod<MessageId> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (fromChatId == null) {
|
||||
|
@ -21,7 +21,10 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Use this method to send text messages. On success, the sent Message is returned.
|
||||
* Use this method to forward messages of any kind.
|
||||
* Service messages can't be forwarded.
|
||||
*
|
||||
* On success, the sent Message is returned.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
|
@ -93,7 +93,7 @@ public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -102,7 +102,7 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
|
||||
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
|
||||
}
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -124,7 +124,7 @@ public class SetGameScore extends BotApiMethod<Serializable> {
|
||||
throw new TelegramApiValidationException("Score parameter can't be empty", this);
|
||||
}
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -64,7 +64,7 @@ public class DeleteChatPhoto extends BotApiMethod<Boolean> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId can't be null", this);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class SendPoll extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (question == null || question.isEmpty()) {
|
||||
|
@ -67,7 +67,7 @@ public class StopPoll extends BotApiMethod<Poll> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (messageId == null || messageId == 0) {
|
||||
|
@ -111,7 +111,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class SendChatAction extends BotApiMethod<Boolean> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (action == null) {
|
||||
|
@ -99,7 +99,7 @@ public class SendContact extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (phoneNumber == null) {
|
||||
|
@ -103,7 +103,7 @@ public class SendDice extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (emoji != null && !VALIDEMOJIS.contains(emoji)) {
|
||||
|
@ -99,7 +99,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class SendGame extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (gameShortName == null || gameShortName.isEmpty()) {
|
||||
|
@ -2,6 +2,7 @@ package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.common.base.Strings;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -10,6 +11,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
@ -62,10 +64,12 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||
private static final String PROVIDER_DATA_FIELD = "provider_data";
|
||||
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
||||
private static final String MAXTIPAMOUNT_FIELD = "max_tip_amount";
|
||||
private static final String SUGGESTEDTIPAMOUNTS_FIELD = "suggested_tip_amounts";
|
||||
|
||||
@JsonProperty(CHATID_FIELD)
|
||||
@NonNull
|
||||
private Integer chatId; ///< Unique identifier for the target private chat
|
||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
@NonNull
|
||||
private String title; ///< Product name
|
||||
@ -78,14 +82,22 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
@JsonProperty(PROVIDER_TOKEN_FIELD)
|
||||
@NonNull
|
||||
private String providerToken; ///< Payments provider token, obtained via Botfather
|
||||
/**
|
||||
* Optional
|
||||
* Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button,
|
||||
* allowing multiple users to pay directly from the forwarded message, using the same invoice.
|
||||
* If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button),
|
||||
* with the value used as the start parameter
|
||||
*/
|
||||
@JsonProperty(START_PARAMETER_FIELD)
|
||||
@NonNull
|
||||
private String startParameter; ///< Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.
|
||||
private String startParameter;
|
||||
@JsonProperty(CURRENCY_FIELD)
|
||||
@NonNull
|
||||
private String currency; ///< 3-letter ISO 4217 currency code
|
||||
@JsonProperty(PRICES_FIELD)
|
||||
@NonNull
|
||||
@Singular
|
||||
private List<LabeledPrice> prices; ///< Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
||||
/**
|
||||
* Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
|
||||
@ -134,6 +146,21 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
private String providerData;
|
||||
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
|
||||
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
||||
/**
|
||||
* The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double).
|
||||
* For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145.
|
||||
* Defaults to 0
|
||||
*/
|
||||
@JsonProperty(MAXTIPAMOUNT_FIELD)
|
||||
private Integer maxTipAmount;
|
||||
/**
|
||||
* A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double).
|
||||
* At most 4 suggested tip amounts can be specified.
|
||||
* The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
||||
*/
|
||||
@JsonProperty(SUGGESTEDTIPAMOUNTS_FIELD)
|
||||
@Singular
|
||||
private List<Integer> suggestedTipAmounts;
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
@ -157,25 +184,25 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (Strings.isNullOrEmpty(chatId)) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (title == null || title.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(title)) {
|
||||
throw new TelegramApiValidationException("Title parameter can't be empty", this);
|
||||
}
|
||||
if (description == null || description.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(description)) {
|
||||
throw new TelegramApiValidationException("Description parameter can't be empty", this);
|
||||
}
|
||||
if (payload == null || payload.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(payload)) {
|
||||
throw new TelegramApiValidationException("Payload parameter can't be empty", this);
|
||||
}
|
||||
if (providerToken == null || providerToken.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(providerToken)) {
|
||||
throw new TelegramApiValidationException("ProviderToken parameter can't be empty", this);
|
||||
}
|
||||
if (startParameter == null || startParameter.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(startParameter)) {
|
||||
throw new TelegramApiValidationException("StartParameter parameter can't be empty", this);
|
||||
}
|
||||
if (currency == null || currency.isEmpty()) {
|
||||
if (Strings.isNullOrEmpty(currency)) {
|
||||
throw new TelegramApiValidationException("Currency parameter can't be empty", this);
|
||||
}
|
||||
if (prices == null || prices.isEmpty()) {
|
||||
@ -185,6 +212,9 @@ public class SendInvoice extends BotApiMethod<Message> {
|
||||
price.validate();
|
||||
}
|
||||
}
|
||||
if (suggestedTipAmounts != null && !suggestedTipAmounts.isEmpty() && suggestedTipAmounts.size() > 4) {
|
||||
throw new TelegramApiValidationException("No more that 4 suggested tips allowed", this);
|
||||
}
|
||||
if (replyMarkup != null) {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class SendLocation extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (latitude == null) {
|
||||
|
@ -90,7 +90,7 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class SendMessage extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (text == null || text.isEmpty()) {
|
||||
|
@ -93,7 +93,7 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class SendSticker extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class SendVenue extends BotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (longitude == null) {
|
||||
|
@ -106,7 +106,7 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class DeleteMessage extends BotApiMethod<Boolean> {
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -106,7 +106,7 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -127,7 +127,7 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -104,7 +104,7 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -94,7 +94,7 @@ public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -144,7 +144,7 @@ public class EditMessageText extends BotApiMethod<Serializable> {
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (inlineMessageId == null) {
|
||||
if (chatId == null) {
|
||||
if (chatId == null || chatId.isEmpty()) {
|
||||
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
|
||||
}
|
||||
if (messageId == null) {
|
||||
|
@ -19,6 +19,7 @@ import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMa
|
||||
import org.telegram.telegrambots.meta.api.objects.stickers.Sticker;
|
||||
import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatEnded;
|
||||
import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatParticipantsInvited;
|
||||
import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatScheduled;
|
||||
import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatStarted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -91,6 +92,7 @@ public class Message implements BotApiObject {
|
||||
private static final String VOICECHATSTARTED_FIELD = "voice_chat_started";
|
||||
private static final String VOICECHATENDED_FIELD = "voice_chat_ended";
|
||||
private static final String VOICECHATPARTICIPANTSINVITED_FIELD = "voice_chat_participants_invited";
|
||||
private static final String VOICECHATSCHEDULED_FIELD = "voice_chat_scheduled";
|
||||
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
private Integer messageId; ///< Integer Unique message identifier
|
||||
@ -266,7 +268,8 @@ public class Message implements BotApiObject {
|
||||
private VoiceChatEnded voiceChatEnded; ///< Optional. Service message: voice chat ended
|
||||
@JsonProperty(VOICECHATPARTICIPANTSINVITED_FIELD)
|
||||
private VoiceChatParticipantsInvited voiceChatParticipantsInvited; ///< Optional. Service message: new members invited to a voice chat
|
||||
|
||||
@JsonProperty(VOICECHATSCHEDULED_FIELD)
|
||||
private VoiceChatScheduled voiceChatScheduled; ///< Optional. Service message: voice chat scheduled
|
||||
|
||||
public List<MessageEntity> getEntities() {
|
||||
if (entities != null) {
|
||||
@ -445,6 +448,11 @@ public class Message implements BotApiObject {
|
||||
return voiceChatEnded != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private boolean hasVoiceChatScheduled() {
|
||||
return voiceChatScheduled != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private boolean hasVoiceChatParticipantsInvited() {
|
||||
return voiceChatParticipantsInvited != null;
|
||||
|
@ -34,6 +34,7 @@ public class InlineQuery implements BotApiObject {
|
||||
private static final String LOCATION_FIELD = "location";
|
||||
private static final String QUERY_FIELD = "query";
|
||||
private static final String OFFSET_FIELD = "offset";
|
||||
private static final String CHATTYPE_FIELD = "chat_type";
|
||||
|
||||
@JsonProperty(ID_FIELD)
|
||||
@NonNull
|
||||
@ -49,5 +50,13 @@ public class InlineQuery implements BotApiObject {
|
||||
@JsonProperty(OFFSET_FIELD)
|
||||
@NonNull
|
||||
private String offset; ///< Offset of the results to be returned, can be controlled by the bot
|
||||
/**
|
||||
* Optional. Type of the chat, from which the inline query was sent.
|
||||
* Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”.
|
||||
* The chat type should be always known for requests sent from official clients and most third-party clients,
|
||||
* unless the request was sent from a secret chat
|
||||
*/
|
||||
@JsonProperty(CHATTYPE_FIELD)
|
||||
private String chatType;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,165 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.google.common.base.Strings;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.Singular;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* Represents the content of a text message to be sent as the result of an inline query.
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class InputInvoiceMessageContent implements InputMessageContent {
|
||||
|
||||
private static final String TITLE_FIELD = "title";
|
||||
private static final String DESCRIPTION_FIELD = "description";
|
||||
private static final String PAYLOAD_FIELD = "payload";
|
||||
private static final String PROVIDERTOKEN_FIELD = "provider_token";
|
||||
private static final String CURRENCY_FIELD = "currency";
|
||||
private static final String PRICES_FIELD = "prices";
|
||||
private static final String MAXTIPAMOUNT_FIELD = "max_tip_amount";
|
||||
private static final String SUGGESTEDTIPAMOUNTS_FIELD = "suggested_tip_amounts";
|
||||
private static final String PROVIDERDATA_FIELD = "provider_data";
|
||||
private static final String PHOTOURL_FIELD = "photo_url";
|
||||
private static final String PHOTOSIZE_FIELD = "photo_size";
|
||||
private static final String PHOTOWIDTH_FIELD = "photo_width";
|
||||
private static final String PHOTOHEIGHT_FIELD = "photo_height";
|
||||
private static final String NEEDNAME_FIELD = "need_name";
|
||||
private static final String NEEDPHONENUMBER_FIELD = "need_phone_number";
|
||||
private static final String NEEDEMAIL_FIELD = "need_email";
|
||||
private static final String NEEDSHIPPINGADDRESS_FIELD = "need_shipping_address";
|
||||
private static final String SENDPHONENUMBERTOPROVIDER_FIELD = "send_phone_number_to_provider";
|
||||
private static final String SENDEMAILTOPROVIDER_FIELD = "send_email_to_provider";
|
||||
private static final String ISFLEXIBLE_FIELD = "is_flexible";
|
||||
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
@NonNull
|
||||
private String title; ///< Product name, 1-32 characters
|
||||
@JsonProperty(DESCRIPTION_FIELD)
|
||||
@NonNull
|
||||
private String description; ///< Product description, 1-255 characters
|
||||
/**
|
||||
* Bot-defined invoice payload, 1-128 bytes.
|
||||
* This will not be displayed to the user, use for your internal processes.
|
||||
*/
|
||||
@JsonProperty(PAYLOAD_FIELD)
|
||||
@NonNull
|
||||
private String payload;
|
||||
@JsonProperty(PROVIDERTOKEN_FIELD)
|
||||
@NonNull
|
||||
private String providerToken; ///< Payment provider token, obtained via Botfather
|
||||
@JsonProperty(CURRENCY_FIELD)
|
||||
@NonNull
|
||||
private String currency; ///< Three-letter ISO 4217 currency code, see more on currencies
|
||||
/**
|
||||
* Price breakdown, a JSON-serialized list of components
|
||||
* (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
||||
*/
|
||||
@JsonProperty(PRICES_FIELD)
|
||||
@NonNull
|
||||
@Singular
|
||||
private List<LabeledPrice> prices;
|
||||
/**
|
||||
* Optional.
|
||||
* The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double).
|
||||
* For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145.
|
||||
* Defaults to 0
|
||||
*/
|
||||
@JsonProperty(MAXTIPAMOUNT_FIELD)
|
||||
private Integer maxTipAmount;
|
||||
/**
|
||||
* Optional.
|
||||
* A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double).
|
||||
* At most 4 suggested tip amounts can be specified.
|
||||
* The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
||||
*/
|
||||
@JsonProperty(SUGGESTEDTIPAMOUNTS_FIELD)
|
||||
@Singular
|
||||
private List<Integer> suggestedTipAmounts;
|
||||
/**
|
||||
* Optional.
|
||||
* A JSON-serialized object for data about the invoice, which will be shared with the payment provider.
|
||||
* A detailed description of the required fields should be provided by the payment provider.
|
||||
*/
|
||||
@JsonProperty(PROVIDERDATA_FIELD)
|
||||
private String providerData;
|
||||
/**
|
||||
* Optional.
|
||||
* URL of the product photo for the invoice.
|
||||
* Can be a photo of the goods or a marketing image for a service.
|
||||
* People like it better when they see what they are paying for.
|
||||
*/
|
||||
@JsonProperty(PHOTOURL_FIELD)
|
||||
private String photoUrl;
|
||||
@JsonProperty(PHOTOSIZE_FIELD)
|
||||
private Integer photoSize; ///< Optional. Photo size
|
||||
@JsonProperty(PHOTOWIDTH_FIELD)
|
||||
private Integer photoWidth; ///< Optional. Photo width
|
||||
@JsonProperty(PHOTOHEIGHT_FIELD)
|
||||
private Integer photoHeight; ///< Optional. Photo height
|
||||
@JsonProperty(NEEDNAME_FIELD)
|
||||
private Boolean needName; ///< Optional. Pass True, if you require the user's full name to complete the order
|
||||
@JsonProperty(NEEDPHONENUMBER_FIELD)
|
||||
private Boolean needPhoneNumber; ///< Optional. Pass True, if you require the user's phone number to complete the order
|
||||
@JsonProperty(NEEDEMAIL_FIELD)
|
||||
private Boolean needEmail; ///< Optional. Pass True, if you require the user's email address to complete the order
|
||||
@JsonProperty(NEEDSHIPPINGADDRESS_FIELD)
|
||||
private Boolean needShippingAddress; ///< Optional. Pass True, if you require the user's shipping address to complete the order
|
||||
@JsonProperty(SENDPHONENUMBERTOPROVIDER_FIELD)
|
||||
private Boolean sendPhoneNumberToProvider; ///< Optional. Pass True, if user's phone number should be sent to provider
|
||||
@JsonProperty(SENDEMAILTOPROVIDER_FIELD)
|
||||
private Boolean sendEmailToProvider; ///< Optional. Pass True, if user's email address should be sent to provider
|
||||
@JsonProperty(ISFLEXIBLE_FIELD)
|
||||
private Boolean isFlexible; ///< Optional. Pass True, if the final price depends on the shipping method
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (Strings.isNullOrEmpty(title) || title.length() > 32) {
|
||||
throw new TelegramApiValidationException("Title parameter must be between 1 and 32 characters", this);
|
||||
}
|
||||
if (Strings.isNullOrEmpty(description) || description.length() > 32) {
|
||||
throw new TelegramApiValidationException("Description parameter must be between 1 and 255 characters", this);
|
||||
}
|
||||
if (Strings.isNullOrEmpty(payload) || payload.length() > 32) {
|
||||
throw new TelegramApiValidationException("Payload parameter must be between 1 and 128 characters", this);
|
||||
}
|
||||
if (Strings.isNullOrEmpty(providerToken)) {
|
||||
throw new TelegramApiValidationException("ProviderToken parameter must not be empty", this);
|
||||
}
|
||||
if (Strings.isNullOrEmpty(currency)) {
|
||||
throw new TelegramApiValidationException("Currency parameter must not be empty", this);
|
||||
}
|
||||
if (prices == null || prices.isEmpty()) {
|
||||
throw new TelegramApiValidationException("Prices parameter must not be empty", this);
|
||||
}
|
||||
for (LabeledPrice price : prices) {
|
||||
price.validate();
|
||||
}
|
||||
if (suggestedTipAmounts != null && !suggestedTipAmounts.isEmpty() && suggestedTipAmounts.size() > 4) {
|
||||
throw new TelegramApiValidationException("Only up to 4 suggested tip amounts are allowed", this);
|
||||
}
|
||||
}
|
||||
}
|
@ -52,6 +52,11 @@ public class InputMessageContentDeserializer extends StdDeserializer<InputMessag
|
||||
new com.fasterxml.jackson.core.type.TypeReference<InputContactMessageContent>(){});
|
||||
}
|
||||
|
||||
if (node.has("provider_token")) {
|
||||
return objectMapper.readValue(node.toString(),
|
||||
new com.fasterxml.jackson.core.type.TypeReference<InputInvoiceMessageContent>(){});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,11 @@ public class Invoice implements BotApiObject {
|
||||
private String title; ///< Product name
|
||||
@JsonProperty(DESCRIPTION_FIELD)
|
||||
private String description; ///< Product description
|
||||
/**
|
||||
* Unique bot deep-linking parameter that can be used to generate this invoice; may be empty
|
||||
*/
|
||||
@JsonProperty(START_PARAMETER_FIELD)
|
||||
private String startParameter; ///< Unique bot deep-linking parameter for generation of this invoice
|
||||
private String startParameter;
|
||||
@JsonProperty(CURRENCY_FIELD)
|
||||
private String currency; ///< Three-letter ISO 4217 currency code
|
||||
/**
|
||||
|
@ -2,9 +2,11 @@ package org.telegram.telegrambots.meta.api.objects.payments;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
@ -22,17 +24,20 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LabeledPrice implements Validable, BotApiObject {
|
||||
private static final String LABEL_FIELD = "label";
|
||||
private static final String AMOUNT_FIELD = "amount";
|
||||
|
||||
@JsonProperty(LABEL_FIELD)
|
||||
@NonNull
|
||||
private String label; ///< Portion label
|
||||
/**
|
||||
* Price of the product in the smallest units of the currency (integer, not float/double).
|
||||
* For example, for a price of US$ 1.45 pass amount = 145.
|
||||
*/
|
||||
@JsonProperty(AMOUNT_FIELD)
|
||||
@NonNull
|
||||
private Integer amount;
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,31 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.voicechat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 5.2
|
||||
*
|
||||
* This object represents a service message about a voice chat scheduled in the chat.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VoiceChatScheduled implements BotApiObject {
|
||||
private static final String STARTDATE_FIELD = "start_date";
|
||||
|
||||
@JsonProperty(STARTDATE_FIELD)
|
||||
@NonNull
|
||||
private Integer startDate; ///< Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator
|
||||
}
|
@ -92,16 +92,16 @@ public class TelegramApiRequestException extends TelegramApiException {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (apiResponse == null) {
|
||||
return super.toString();
|
||||
return super.getMessage();
|
||||
} else if (errorCode == null) {
|
||||
return super.toString() + ": " + apiResponse;
|
||||
return super.getMessage() + ": " + apiResponse;
|
||||
} else {
|
||||
return super.toString() + ": [" + errorCode + "] " + apiResponse;
|
||||
return super.getMessage() + ": [" + errorCode + "] " + apiResponse;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Just left as backward compatibility if anybody used this in version 5.1.1 or older.
|
||||
* Just left as backward compatibility if anybody used this in version 5.2.0 or older.
|
||||
*
|
||||
* @return the getMessage string
|
||||
*/
|
||||
|
@ -0,0 +1,19 @@
|
||||
package org.telegram.telegrambots.meta;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TestUtils {
|
||||
public static String getTextOfSize(int n) {
|
||||
char[] text = new char[33];
|
||||
Arrays.fill(text, 'A');
|
||||
return new String(text);
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
package org.telegram.telegrambots.meta.api.methods.send;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 5.2
|
||||
*/
|
||||
public class SendInvoiceTest {
|
||||
@Test
|
||||
public void validObjectMustNotThrow() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
assertDoesNotThrow(sendInvoice::validate);
|
||||
sendInvoice.setSuggestedTipAmounts(new ArrayList<>());
|
||||
assertDoesNotThrow(sendInvoice::validate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chatIdCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setChatId("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("ChatId parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titleCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setTitle("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Title parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptionCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setDescription("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Description parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void payloadCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPayload("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Payload parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providerTokenCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setProviderToken("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("ProviderToken parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startParameterCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setStartParameter("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("StartParameter parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void currencyCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setCurrency("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Currency parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pricesMustBeValidated() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPrices(Collections.singletonList(LabeledPrice.builder().label("").amount(1).build()));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Label parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pricesCantBeEmpty() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPrices(new ArrayList<>());
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Prices parameter can't be empty", thrown.getMessage());
|
||||
sendInvoice.setPrices(Collections.singletonList(LabeledPrice.builder().label("").amount(1).build()));
|
||||
thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Label parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestedTipAmountsMustNotHaveMoreThan4Elements() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setSuggestedTipAmounts(Arrays.asList(1,2,3,4,5));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("No more that 4 suggested tips allowed", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replyMarkupMustBeValidated() {
|
||||
SendInvoice sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setReplyMarkup(InlineKeyboardMarkup.builder().keyboardRow(Collections.singletonList(InlineKeyboardButton.builder().text("").build())).build());
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Text parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
private SendInvoice createSendInvoiceObject() {
|
||||
return SendInvoice.builder()
|
||||
.chatId("123456")
|
||||
.title("Title")
|
||||
.description("Description")
|
||||
.payload("Payload")
|
||||
.providerToken("ProviderToken")
|
||||
.startParameter("StartParameter")
|
||||
.currency("Currency")
|
||||
.price(LabeledPrice.builder().label("Label").amount(1).build())
|
||||
.suggestedTipAmount(1)
|
||||
.suggestedTipAmount(2)
|
||||
.suggestedTipAmount(3)
|
||||
.suggestedTipAmount(4)
|
||||
.replyMarkup(InlineKeyboardMarkup.builder().keyboardRow(Collections.singletonList(InlineKeyboardButton.builder().text("Hello").build())).build())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.telegram.telegrambots.meta.TestUtils;
|
||||
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
*/
|
||||
public class InputInvoiceMessageContentTest {
|
||||
|
||||
@Test
|
||||
public void validObjectMustNotThrow() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
assertDoesNotThrow(sendInvoice::validate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titleCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setTitle("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Title parameter must be between 1 and 32 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titleCantBeLongerThan32() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setTitle(TestUtils.getTextOfSize(33));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Title parameter must be between 1 and 32 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptionCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setDescription("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Description parameter must be between 1 and 255 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptionCantBeLongerThan255() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setDescription(TestUtils.getTextOfSize(256));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Description parameter must be between 1 and 255 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void payloadCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPayload("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Payload parameter must be between 1 and 128 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void payloadCantBeLongerThan128() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPayload(TestUtils.getTextOfSize(129));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Payload parameter must be between 1 and 128 characters", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providerTokenCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setProviderToken("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("ProviderToken parameter must not be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void currencyCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setCurrency("");
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Currency parameter must not be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pricesMustBeValidated() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPrices(Collections.singletonList(LabeledPrice.builder().label("").amount(1).build()));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Label parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pricesCantBeEmpty() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setPrices(new ArrayList<>());
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Prices parameter must not be empty", thrown.getMessage());
|
||||
sendInvoice.setPrices(Collections.singletonList(LabeledPrice.builder().label("").amount(1).build()));
|
||||
thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Label parameter can't be empty", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestedTipAmountsMustNotHaveMoreThan4Elements() {
|
||||
InputInvoiceMessageContent sendInvoice = createSendInvoiceObject();
|
||||
sendInvoice.setSuggestedTipAmounts(Arrays.asList(1,2,3,4,5));
|
||||
Throwable thrown = assertThrows(TelegramApiValidationException.class, sendInvoice::validate);
|
||||
assertEquals("Only up to 4 suggested tip amounts are allowed", thrown.getMessage());
|
||||
}
|
||||
|
||||
private InputInvoiceMessageContent createSendInvoiceObject() {
|
||||
return InputInvoiceMessageContent.builder()
|
||||
.title("Title")
|
||||
.description("Description")
|
||||
.payload("Payload")
|
||||
.providerToken("ProviderToken")
|
||||
.currency("Currency")
|
||||
.price(LabeledPrice.builder().label("Label").amount(1).build())
|
||||
.suggestedTipAmount(1)
|
||||
.suggestedTipAmount(2)
|
||||
.suggestedTipAmount(3)
|
||||
.suggestedTipAmount(4)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -18,14 +18,14 @@ Usage
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
**Gradle**
|
||||
|
||||
```gradle
|
||||
implementation 'org.telegram:telegrambots-spring-boot-starter:5.1.1'
|
||||
implementation 'org.telegram:telegrambots-spring-boot-starter:5.2.0'
|
||||
```
|
||||
|
||||
Motivation
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||
@ -70,7 +70,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<telegrambots.version>5.1.1</telegrambots.version>
|
||||
<telegrambots.version>5.2.0</telegrambots.version>
|
||||
<spring-boot.version>2.4.5</spring-boot.version>
|
||||
|
||||
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>Bots</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegrambots</artifactId>
|
||||
@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-meta</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.telegram.telegrambots.updatesreceivers;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.telegram.telegrambots.Constants;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
@ -24,9 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* Rest api to for webhook callback function
|
||||
*/
|
||||
@Path(Constants.WEBHOOK_URL_PATH)
|
||||
@Slf4j
|
||||
public class RestApi {
|
||||
private static final Logger log = LoggerFactory.getLogger(RestApi.class);
|
||||
|
||||
private final ConcurrentHashMap<String, WebhookBot> callbacks = new ConcurrentHashMap<>();
|
||||
|
||||
public RestApi() {
|
||||
|
@ -71,7 +71,7 @@ public final class BotApiMethodHelperFactory {
|
||||
.text("Hithere")
|
||||
.replyToMessageId(12)
|
||||
.parseMode(ParseMode.HTML)
|
||||
.replyMarkup(new ForceReplyKeyboard())
|
||||
.replyMarkup(ForceReplyKeyboard.builder().forceReply(true).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -362,12 +362,16 @@ public final class BotApiMethodHelperFactory {
|
||||
|
||||
return SendInvoice
|
||||
.builder()
|
||||
.chatId(12345)
|
||||
.chatId("12345")
|
||||
.title("Random title")
|
||||
.description("Random description")
|
||||
.payload("Random Payload")
|
||||
.providerToken("Random provider token")
|
||||
.startParameter("STARTPARAM")
|
||||
.maxTipAmount(100)
|
||||
.suggestedTipAmount(10)
|
||||
.suggestedTipAmount(50)
|
||||
.suggestedTipAmount(75)
|
||||
.currency("EUR")
|
||||
.prices(prices)
|
||||
.build();
|
||||
|
@ -22,7 +22,9 @@ public class TelegramLongPollingBotTest {
|
||||
TelegramLongPollingBot bot = Mockito.mock(TelegramLongPollingBot.class);
|
||||
Mockito.doCallRealMethod().when(bot).onUpdatesReceived(any());
|
||||
Update update1 = new Update();
|
||||
update1.setUpdateId(1);
|
||||
Update update2 = new Update();
|
||||
update2.setUpdateId(2);
|
||||
bot.onUpdatesReceived(asList(update1, update2));
|
||||
Mockito.verify(bot).onUpdateReceived(update1);
|
||||
Mockito.verify(bot).onUpdateReceived(update2);
|
||||
|
@ -113,7 +113,8 @@ public class TestRestApi extends JerseyTest {
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, AnswerInlineQuery.class);
|
||||
|
||||
assertEquals("{\"personal\":true,\"inline_query_id\":\"id\",\"results\":[{\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10,\"thumb_height\":20},{\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]}}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}", map(result));
|
||||
assertEquals("{\"inline_query_id\":\"id\",\"results\":[{\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10,\"thumb_height\":20},{\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"caption_entities\":[]}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}",
|
||||
map(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -127,9 +128,8 @@ public class TestRestApi extends JerseyTest {
|
||||
.post(entity, EditMessageCaption.class);
|
||||
|
||||
assertEquals("{\"chat_id\":\"ChatId\",\"message_id\":1,\"caption\":\"Caption\"," +
|
||||
"\"reply_markup\":{\"inline_keyboard\":[[{" +
|
||||
"\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"method\":" +
|
||||
"\"editmessagecaption\"}", map(result));
|
||||
"\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]}," +
|
||||
"\"caption_entities\":[],\"method\":\"editmessagecaption\"}", map(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -422,10 +422,10 @@ public class TestRestApi extends JerseyTest {
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendInvoice.class);
|
||||
|
||||
assertEquals("{\"chat_id\":12345,\"title\":\"Random title\",\"description\":\"Random description\"" +
|
||||
",\"payload\":\"Random Payload\",\"provider_token\":\"Random provider token\",\"start_parameter\":" +
|
||||
"\"STARTPARAM\",\"currency\":\"EUR\",\"prices\":[{\"label\":\"LABEL\"," +
|
||||
"\"amount\":1000}],\"method\":\"sendinvoice\"}", map(result));
|
||||
assertEquals("{\"chat_id\":\"12345\",\"title\":\"Random title\",\"description\":\"Random description\"," +
|
||||
"\"payload\":\"Random Payload\",\"provider_token\":\"Random provider token\",\"start_parameter\":\"STARTPARAM\"," +
|
||||
"\"currency\":\"EUR\",\"prices\":[{\"label\":\"LABEL\",\"amount\":1000}],\"max_tip_amount\":100," +
|
||||
"\"suggested_tip_amounts\":[10,50,75],\"method\":\"sendinvoice\"}", map(result));
|
||||
}
|
||||
|
||||
private Update getUpdate() {
|
||||
|
Loading…
Reference in New Issue
Block a user