Api version 4.3

This commit is contained in:
Rubenlagus 2019-06-01 12:50:17 +01:00 committed by Ruben Bermudez
parent 06dad7c262
commit b3914c5e76
19 changed files with 210 additions and 29 deletions

View File

@ -1846,6 +1846,19 @@
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/3.5/telegrambots-meta-3.5-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.telegram:telegrambots-meta:4.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/4.2/telegrambots-meta-4.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$PROJECT_DIR$/telegrambots-meta/telegrambots-meta-4.2-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/4.2/telegrambots-meta-4.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$PROJECT_DIR$/telegrambots-meta/telegrambots-meta-4.2-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/4.2/telegrambots-meta-4.2-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.telegram:telegrambots:3.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/3.5/telegrambots-3.5.jar!/" />
@ -1859,6 +1872,19 @@
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/3.5/telegrambots-3.5-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.telegram:telegrambots:4.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/4.2/telegrambots-4.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$PROJECT_DIR$/telegrambots/telegrambots-4.2-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/4.2/telegrambots-4.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$PROJECT_DIR$/telegrambots/telegrambots-4.2-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/4.2/telegrambots-4.2-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="masterDetails">
<states>

View File

@ -27,16 +27,16 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
```
```gradle
compile "org.telegram:telegrambots:4.2"
compile "org.telegram:telegrambots:4.3"
```
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.2)
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.2)
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.3)
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.3)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,3 +1,7 @@
### <a id="4.3"></a>4.3 ###
1. Update to Api version [4.3](https://core.telegram.org/bots/api-changelog#may-31-2019)
2. Fixed: #615, #621
### <a id="4.2"></a>4.2 ###
1. Update to Api version [4.2](https://core.telegram.org/bots/api-changelog#april-14-2019)
2. Fixed: #498, #578

View File

@ -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>4.2</version>
<version>4.3</version>
</dependency>
```
* With **Gradle**:
```groovy
compile group: 'org.telegram', name: 'telegrambots', version: '4.2'
compile group: 'org.telegram', name: 'telegrambots', version: '4.3'
```
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).

View File

@ -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>4.2</version>
<version>4.3</version>
</dependency>
```
* **Gradle**
```groovy
compile group: 'org.telegram', name: 'telegrambots-abilities', version: '4.2'
compile group: 'org.telegram', name: 'telegrambots-abilities', version: '4.3'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>4.2</version>
<version>4.3</version>
<modules>
<module>telegrambots</module>

View File

@ -18,19 +18,19 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
```
**Gradle**
```gradle
compile "org.telegram:telegrambots-abilities:4.2"
compile "org.telegram:telegrambots-abilities:4.3"
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.2)
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.3)
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.2)
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.3)
Motivation
----------

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Ability Bot</name>
@ -73,7 +73,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@ -15,7 +15,7 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
```

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Bots Chat Session Bot</name>
@ -73,7 +73,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->

View File

@ -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>4.2</version>
<version>4.3</version>
</dependency>
```
2. Using Gradle:
```gradle
compile "org.telegram:telegrambotsextensions:4.2"
compile "org.telegram:telegrambotsextensions:4.3"
```

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Bots Extensions</name>
@ -65,7 +65,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Bots Meta</name>

View File

@ -13,6 +13,6 @@ import java.io.Serializable;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="@class")
public interface InputBotApiObject extends Serializable {
}

View File

@ -0,0 +1,108 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.api.interfaces.InputBotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 4.3
*
* This object represents a parameter of the inline keyboard button used to automatically authorize a user.
* Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram.
* All the user needs to do is tap/click a button and confirm that they want to log in.
*/
@SuppressWarnings("unused")
public class LoginUrl implements InputBotApiObject, Validable {
private static final String URL_FIELD = "url";
private static final String FORWARD_TEXT_FIELD = "forward_text";
private static final String BOT_USERNAME_FIELD = "bot_username";
private static final String REQUEST_WRITE_ACCESS_FIELD = "request_write_access";
/**
* An HTTP URL to be opened with user authorization data added to the query string when the button is pressed.
* If the user refuses to provide authorization data, the original URL without information about the user will be opened.
* The data added is the same as described in Receiving authorization data.
*
* @implNote You must always check the hash of the received data to verify the authentication and the integrity
* of the data as described in Checking authorization.
*/
@JsonProperty(URL_FIELD)
private String url;
@JsonProperty(FORWARD_TEXT_FIELD)
private String forwardText; ///< Optional. New text of the button in forwarded messages.
/**
* Optional. Username of a bot, which will be used for user authorization. See Setting up a bot for more details.
* If not specified, the current bot's username will be assumed.
* The url's domain must be the same as the domain linked with the bot.
*/
@JsonProperty(BOT_USERNAME_FIELD)
private String botUsername; ///< Optional. Animation duration
@JsonProperty(REQUEST_WRITE_ACCESS_FIELD)
private Boolean requestWriteAccess; ///< Optional. Pass True to request the permission for your bot to send messages to the user.
public LoginUrl() {
super();
}
public LoginUrl(String url) {
this.url = checkNotNull(url);
}
public String getUrl() {
return url;
}
public LoginUrl setUrl(String url) {
this.url = url;
return this;
}
public String getForwardText() {
return forwardText;
}
public LoginUrl setForwardText(String forwardText) {
this.forwardText = forwardText;
return this;
}
public String getBotUsername() {
return botUsername;
}
public LoginUrl setBotUsername(String botUsername) {
this.botUsername = botUsername;
return this;
}
public Boolean getRequestWriteAccess() {
return requestWriteAccess;
}
public LoginUrl setRequestWriteAccess(Boolean requestWriteAccess) {
this.requestWriteAccess = requestWriteAccess;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (url == null || url.isEmpty()) {
throw new TelegramApiValidationException("Url parameter can't be empty", this);
}
}
@Override
public String toString() {
return "LoginUrl{" +
"url='" + url + '\'' +
", forwardText='" + forwardText + '\'' +
", botUsername='" + botUsername + '\'' +
", requestWriteAccess=" + requestWriteAccess +
'}';
}
}

View File

@ -8,6 +8,7 @@ import org.telegram.telegrambots.meta.api.objects.passport.PassportData;
import org.telegram.telegrambots.meta.api.objects.payments.Invoice;
import org.telegram.telegrambots.meta.api.objects.payments.SuccessfulPayment;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.api.objects.stickers.Sticker;
import java.util.ArrayList;
@ -65,6 +66,7 @@ public class Message implements BotApiObject {
private static final String PASSPORTDATA_FIELD = "passport_data";
private static final String FORWARDSENDERNAME_FIELD = "forward_sender_name";
private static final String POLL_FIELD = "poll";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@ -198,6 +200,13 @@ public class Message implements BotApiObject {
private String forwardSenderName; ///< Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
@JsonProperty(POLL_FIELD)
private Poll poll; ///< Optional. Message is a native poll, information about the poll
/**
* Inline keyboard attached to the message.
*
* @apiNote login_url buttons are represented as ordinary url buttons.
*/
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup;
public Message() {
super();
@ -501,6 +510,14 @@ public class Message implements BotApiObject {
return poll;
}
public boolean hasReplyMarkup() {
return replyMarkup != null;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
@Override
public String toString() {
return "Message{" +
@ -522,6 +539,7 @@ public class Message implements BotApiObject {
", contact=" + contact +
", location=" + location +
", venue=" + venue +
", animation=" + animation +
", pinnedMessage=" + pinnedMessage +
", newChatMembers=" + newChatMembers +
", leftChatMember=" + leftChatMember +
@ -547,7 +565,9 @@ public class Message implements BotApiObject {
", mediaGroupId='" + mediaGroupId + '\'' +
", connectedWebsite='" + connectedWebsite + '\'' +
", passportData=" + passportData +
", forwardSenderName='" + forwardSenderName + '\'' +
", poll=" + poll +
", replyMarkup=" + replyMarkup +
'}';
}
}

View File

@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.meta.api.interfaces.InputBotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.api.objects.LoginUrl;
import org.telegram.telegrambots.meta.api.objects.games.CallbackGame;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -27,6 +28,7 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
private static final String SWITCH_INLINE_QUERY_FIELD = "switch_inline_query";
private static final String SWITCH_INLINE_QUERY_CURRENT_CHAT_FIELD = "switch_inline_query_current_chat";
private static final String PAY_FIELD = "pay";
private static final String LOGIN_URL_FIELD = "login_url";
@JsonProperty(TEXT_FIELD)
private String text; ///< Label text on the button
@ -69,6 +71,12 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
*/
@JsonProperty(PAY_FIELD)
private Boolean pay;
/**
* Optional. An HTTP URL used to automatically authorize the user.
* Can be used as a replacement for the Telegram Login Widget.
*/
@JsonProperty(LOGIN_URL_FIELD)
private LoginUrl loginUrl;
public InlineKeyboardButton() {
super();
@ -141,11 +149,23 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
return this;
}
public LoginUrl getLoginUrl() {
return loginUrl;
}
public InlineKeyboardButton setLoginUrl(LoginUrl loginUrl) {
this.loginUrl = loginUrl;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (text == null || text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
if (loginUrl != null) {
loginUrl.validate();
}
}
@Override
@ -162,6 +182,7 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
&& Objects.equals(switchInlineQueryCurrentChat, inlineKeyboardButton.switchInlineQueryCurrentChat)
&& Objects.equals(text, inlineKeyboardButton.text)
&& Objects.equals(url, inlineKeyboardButton.url)
&& Objects.equals(loginUrl, inlineKeyboardButton.loginUrl)
;
}
@ -174,7 +195,8 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
switchInlineQuery,
switchInlineQueryCurrentChat,
text,
url);
url,
loginUrl);
}
@Override
@ -187,6 +209,7 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
", switchInlineQuery='" + switchInlineQuery + '\'' +
", switchInlineQueryCurrentChat='" + switchInlineQueryCurrentChat + '\'' +
", pay=" + pay +
", loginUrl=" + loginUrl +
'}';
}
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-spring-boot-starter</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Bots Spring Boot Starter</name>
@ -67,7 +67,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>4.2</version>
<version>4.3</version>
<packaging>jar</packaging>
<name>Telegram Bots</name>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>4.2</version>
<version>4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>