Skip to content

Commit

Permalink
Merge pull request #160 from rubenlagus/dev
Browse files Browse the repository at this point in the history
Version 2.4.2
  • Loading branch information
rubenlagus authored Nov 17, 2016
2 parents 548aeca + 49e87b1 commit 777c800
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>2.4.1</version>
<version>2.4.2</version>
</dependency>
```

2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/v2.4.1)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.4.1)
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/v2.4.2)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.4.2)

In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

Expand Down
7 changes: 4 additions & 3 deletions TelegramBots.wiki/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
### <a id="2.4.1"></a>2.4.1 ###
### <a id="2.4.2"></a>2.4.2 ###
1. Split library in two modules to allow custom implementations.
2. Use [Guice](https://github.com/google/guice) for dependency injection.
3. Use [Jackson](https://github.com/FasterXML/jackson) for json (de)serialization.
4. Added extra validation to methods before performing requests.
5. BotOptions has been renamed ot DefaultBotOptions. It allows now to set number of threads for async methods execution and the complete `RequestConfig` for customization purpose.
6. Added convenient method for `setChatId` using just a `Long` value instead of an String.
7. Moved to MIT license
7. In `SentCallback` method `onError` changed second parameter to `TelegramApiRequestException` and `onResult` now receives the deserialized answer (of type `T`) instead of a `JSONObject` as second parameter
8. Moved to MIT license

**[[How to update to version 2.4.1|How-To-Update#2.4.1]]**
**[[How to update to version 2.4.2|How-To-Update#2.4.2]]**
4 changes: 2 additions & 2 deletions TelegramBots.wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.1</version>
<version>2.4.2</version>
</dependency>
```
* With **Gradle**:

```groovy
compile group: 'org.telegram', name: 'telegrambots', version: '2.4.1'
compile group: 'org.telegram', name: 'telegrambots', version: '2.4.2'
```

2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
Expand Down
3 changes: 2 additions & 1 deletion TelegramBots.wiki/How-To-Update.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
### <a id="2.4.1"></a>To version 2.4.1 ###
### <a id="2.4.2"></a>To version 2.4.2 ###
1. Replace `BotOptions` by `DefaultBotOptions`.
2. At the beginning of your program (before creating your `TelegramBotsApi` instance, add the following line:
```java
ApiContextInitializer.init();
```
3. In `SentCallback`, update parameter types of `onResult` and `onError`. Inside those two method, you don't need to deserialize anything now, it comes already done.
3. **Deprecated** (will be removed in next version):
* `org.telegram.telegrambots.bots.BotOptions`. Use `org.telegram.telegrambots.bots.DefaultBotOptions` instead.
* `getPersonal` from `AnswerInlineQuery`. Use `isPersonal` instead.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>2.4.1</version>
<version>2.4.2</version>

<modules>
<module>telegrambots</module>
Expand All @@ -24,6 +24,6 @@

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<bots.version>2.4.1</bots.version>
<bots.version>2.4.2</bots.version>
</properties>
</project>
2 changes: 1 addition & 1 deletion telegrambots-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>2.4.1</version>
<version>2.4.2</version>
<packaging>jar</packaging>

<name>Telegram Bots Meta</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.telegram.telegrambots.updateshandlers;

import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;

import java.io.Serializable;

Expand All @@ -15,16 +15,16 @@ public interface SentCallback<T extends Serializable> {
/**
* Called when the request is successful
* @param method Method executed
* @param jsonObject Answer from Telegram server
* @param response Answer from Telegram server
*/
void onResult(BotApiMethod<T> method, JSONObject jsonObject);
void onResult(BotApiMethod<T> method, T response);

/**
* Called when the request fails
* @param method Method executed
* @param jsonObject Answer from Telegram server (contains error information)
* @param apiException Answer from Telegram server (contains error information)
*/
void onError(BotApiMethod<T> method, JSONObject jsonObject);
void onError(BotApiMethod<T> method, TelegramApiRequestException apiException);

/**
* Called when the http request throw an exception
Expand Down
4 changes: 2 additions & 2 deletions telegrambots/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>2.4.1</version>
<version>2.4.2</version>
<packaging>jar</packaging>

<name>Telegram Bots</name>
Expand Down Expand Up @@ -60,7 +60,7 @@
<json.version>20160810</json.version>
<jackson.version>2.8.5</jackson.version>
<commonio.version>2.5</commonio.version>
<bots.version>2.4.1</bots.version>
<bots.version>2.4.2</bots.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.telegram.telegrambots.ApiConstants;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.methods.send.SendAudio;
Expand Down Expand Up @@ -643,12 +642,11 @@ public void run() {
HttpEntity ht = response.getEntity();
BufferedHttpEntity buf = new BufferedHttpEntity(ht);
String responseContent = EntityUtils.toString(buf, StandardCharsets.UTF_8);

JSONObject jsonObject = new JSONObject(responseContent);
if (!jsonObject.getBoolean(ApiConstants.RESPONSE_FIELD_OK)) {
callback.onError(method, jsonObject);
try {
callback.onResult(method, method.deserializeResponse(responseContent));
} catch (TelegramApiRequestException e) {
callback.onError(method, e);
}
callback.onResult(method, jsonObject);
}
} catch (IOException | TelegramApiValidationException e) {
callback.onException(method, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
* <a href="https://core.telegram.org/bots/api#setwebhook">webhook</a>
* @date 14 of January of 2016
*/
public abstract class TelegramWebhookBot extends AbsSender implements WebhookBot {
public abstract class TelegramWebhookBot extends DefaultAbsSender implements WebhookBot {
private final DefaultBotOptions botOptions;

public TelegramWebhookBot() {
this(ApiContext.getInstance(DefaultBotOptions.class));
}

public TelegramWebhookBot(DefaultBotOptions options) {
super();
super(options);
this.botOptions = options;
}

Expand Down

0 comments on commit 777c800

Please sign in to comment.