Merge pull request #188 from rubenlagus/dev

Update 2.4.4.4
This commit is contained in:
Ruben Bermudez 2017-01-15 03:26:53 +01:00 committed by GitHub
commit b3828accbe
11 changed files with 75 additions and 29 deletions

View File

@ -31,8 +31,8 @@ Just import add the library to your project with one of these options:
</dependency>
```
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/2.4.4.3)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/2.4.4.3)
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/2.4.4.4)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/2.4.4.4)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -29,4 +29,9 @@
1. In `BotSession`, renamed `close` to `stop`. `Close` method is maintained for backward compatibility.
2. Support crating webhook with HTTP servers (HTTPS must be managed via external tools)
**[[How to update to version 2.4.4.3|How-To-Update#2.4.4.3]]**
**[[How to update to version 2.4.4.3|How-To-Update#2.4.4.3]]**
### <a id="2.4.4.4"></a>2.4.4.4 ###
1. EditMessageText, EditMessageCaption and EditMessageReplyMarkup now return a `Serializable` object that can be `Boolean` or `Message`
**[[How to update to version 2.4.4.4|How-To-Update#2.4.4.4]]**

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

View File

@ -16,4 +16,8 @@
3. Removed deprecated stuff from version 2.4.3
### <a id="2.4.4.3"></a>To version 2.4.4.3 ###
1. Replace `BotSession.close()` by `BotSession.stop()`.
1. Replace `BotSession.close()` by `BotSession.stop()`.
### <a id="2.4.4.4"></a>To version 2.4.4.4 ###
1. All calls to `editMessageText`, `editMessageCaption` or `editMessageReplyMarkup` in `AbsSender` return value is changed to `Serializable`
2. In `editMessageTextAsync`, `editMessageCaptionAsync` or `editMessageReplyMarkupAsync` in `AbsSender`, second parameter should become `SentCallback<Serializable>` due to new return type.

View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>2.4.4.3</version>
<version>2.4.4.4</version>
<modules>
<module>telegrambots</module>
@ -24,6 +24,6 @@
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<bots.version>2.4.4.3</bots.version>
<bots.version>2.4.4.4</bots.version>
</properties>
</project>

View File

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

View File

@ -11,15 +11,16 @@ import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.io.Serializable;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline
* bots). On success, the edited Message is returned
* bots). 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
*/
public class EditMessageCaption extends BotApiMethod<Message> {
public class EditMessageCaption extends BotApiMethod<Serializable> {
public static final String PATH = "editmessagecaption";
private static final String CHATID_FIELD = "chat_id";
@ -104,7 +105,7 @@ public class EditMessageCaption extends BotApiMethod<Message> {
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
public Serializable deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
@ -114,7 +115,18 @@ public class EditMessageCaption extends BotApiMethod<Message> {
throw new TelegramApiRequestException("Error editing message caption", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
try {
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Boolean>>() {
});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error editing message caption", result);
}
} catch (IOException e2) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
}

View File

@ -11,16 +11,18 @@ import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;
/**
* @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, the edited Message is returned.
* (for inline bots). 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
*/
public class EditMessageReplyMarkup extends BotApiMethod<Message> {
public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
public static final String PATH = "editmessagereplymarkup";
private static final String CHATID_FIELD = "chat_id";
@ -99,7 +101,7 @@ public class EditMessageReplyMarkup extends BotApiMethod<Message> {
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
public Serializable deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
@ -109,7 +111,18 @@ public class EditMessageReplyMarkup extends BotApiMethod<Message> {
throw new TelegramApiRequestException("Error editing message reply markup", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
try {
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Boolean>>() {
});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error editing message reply markup", result);
}
} catch (IOException e2) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
}

View File

@ -12,16 +12,17 @@ import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;
/**
* @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
* success, the edited Message is returned.
* success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @date 10 of April of 2016
*/
public class EditMessageText extends BotApiMethod<Message> {
public class EditMessageText extends BotApiMethod<Serializable> {
public static final String PATH = "editmessagetext";
private static final String CHATID_FIELD = "chat_id";
@ -159,7 +160,7 @@ public class EditMessageText extends BotApiMethod<Message> {
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
public Serializable deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Message>>(){});
@ -169,7 +170,18 @@ public class EditMessageText extends BotApiMethod<Message> {
throw new TelegramApiRequestException("Error editing message text", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
try {
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Boolean>>() {
});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error editing message text", result);
}
} catch (IOException e2) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
}

View File

@ -164,21 +164,21 @@ public abstract class AbsSender {
return sendApiMethod(getChatMemberCount);
}
public final Message editMessageText(EditMessageText editMessageText) throws TelegramApiException {
public final Serializable editMessageText(EditMessageText editMessageText) throws TelegramApiException {
if (editMessageText == null) {
throw new TelegramApiException("Parameter editMessageText can not be null");
}
return sendApiMethod(editMessageText);
}
public final Message editMessageCaption(EditMessageCaption editMessageCaption) throws TelegramApiException {
public final Serializable editMessageCaption(EditMessageCaption editMessageCaption) throws TelegramApiException {
if (editMessageCaption == null) {
throw new TelegramApiException("Parameter editMessageCaption can not be null");
}
return sendApiMethod(editMessageCaption);
}
public final Message editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup) throws TelegramApiException {
public final Serializable editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup) throws TelegramApiException {
if (editMessageReplyMarkup == null) {
throw new TelegramApiException("Parameter editMessageReplyMarkup can not be null");
}
@ -407,7 +407,7 @@ public abstract class AbsSender {
sendApiMethodAsync(getChatMemberCount, sentCallback);
}
public final void editMessageTextAsync(EditMessageText editMessageText, SentCallback<Message> sentCallback) throws TelegramApiException {
public final void editMessageTextAsync(EditMessageText editMessageText, SentCallback<Serializable> sentCallback) throws TelegramApiException {
if (editMessageText == null) {
throw new TelegramApiException("Parameter editMessageText can not be null");
}
@ -418,7 +418,7 @@ public abstract class AbsSender {
sendApiMethodAsync(editMessageText, sentCallback);
}
public final void editMessageCaptionAsync(EditMessageCaption editMessageCaption, SentCallback<Message> sentCallback) throws TelegramApiException {
public final void editMessageCaptionAsync(EditMessageCaption editMessageCaption, SentCallback<Serializable> sentCallback) throws TelegramApiException {
if (editMessageCaption == null) {
throw new TelegramApiException("Parameter editMessageCaption can not be null");
}
@ -429,7 +429,7 @@ public abstract class AbsSender {
sendApiMethodAsync(editMessageCaption, sentCallback);
}
public final void editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup, SentCallback<Message> sentCallback) throws TelegramApiException {
public final void editMessageReplyMarkup(EditMessageReplyMarkup editMessageReplyMarkup, SentCallback<Serializable> sentCallback) throws TelegramApiException {
if (editMessageReplyMarkup == null) {
throw new TelegramApiException("Parameter editMessageReplyMarkup can not be null");
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>2.4.4.3</version>
<version>2.4.4.4</version>
<packaging>jar</packaging>
<name>Telegram Bots</name>
@ -65,7 +65,7 @@
<json.version>20160810</json.version>
<jackson.version>2.8.5</jackson.version>
<commonio.version>2.5</commonio.version>
<bots.version>2.4.4.3</bots.version>
<bots.version>2.4.4.4</bots.version>
</properties>
<dependencyManagement>