Skip to content

Commit

Permalink
Merge pull request rubenlagus#496 from rubenlagus/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rubenlagus authored Jul 26, 2018
2 parents 431d945 + ed1df44 commit 01765d0
Show file tree
Hide file tree
Showing 283 changed files with 6,718 additions and 3,976 deletions.
251 changes: 211 additions & 40 deletions Bots.ipr

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
</dependency>
```

Expand All @@ -43,7 +43,7 @@ In order to use Long Polling mode, just create your own bot extending `org.teleg
If you like to use Webhook, extend `org.telegram.telegrambots.bots.TelegramWebhookBot`


Once done, you just need to create a `org.telegram.telegrambots.TelegramBotsApi`and register your bots:
Once done, you just need to create a `org.telegram.telegrambots.meta.TelegramBotsApi`and register your bots:

```java

Expand Down Expand Up @@ -93,6 +93,12 @@ This library use [Telegram bot API](https://core.telegram.org/bots), you can fin
## Questions or Suggestions
Feel free to create issues [here](https://github.com/rubenlagus/TelegramBots/issues) as you need or join the [chat](https://telegram.me/JavaBotsApi)

## Powered by Intellij
<p align="center">
<a href="https://www.jetbrains.com"><img src="jetbrains.png" width="75"></a>
</p>


## License
MIT License

Expand Down
10 changes: 10 additions & 0 deletions TelegramBots.wiki/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### <a id="4.0.0"></a>4.0.0 ###
1. Support for Api Version [4.0](https://core.telegram.org/bots/api-changelog#july-26-2018)
2. Abilities: Internationalization
3. Socks 5 support
4. Improved spring boot start configuration
5. Removed previously deprecated methods
6. Support usage in Java 9 (library is still using java 8)

**[[How to update to version 4.0.0|How-To-Update#4.0.0]]**

### <a id="3.6.1"></a>3.6.1 ###
1. Support for proxy connections
2. New module for Spring
Expand Down
4 changes: 2 additions & 2 deletions TelegramBots.wiki/Errors-Handling.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
* [Terminated by other long poll or webhook](#terminted_by_other)
* ["No implementation for org.telegram.telegrambots.generics.BotSession was bound"](#no_implementation_was_bound)
* ["No implementation for org.telegram.telegrambots.meta.generics.BotSession was bound"](#no_implementation_was_bound)

## <a id="terminted_by_other"></a>Terminated by other long poll or webhook ##

It means that you have already a running instance of your bot. To solve it, close all running ones and then you can start a new instance.

## <a id="no_implementation_was_bound"></a>No implementation for org.telegram.telegrambots.generics.BotSession was bound ##
## <a id="no_implementation_was_bound"></a>No implementation for org.telegram.meta.telegrambots.generics.BotSession was bound ##
Please follow the steps as explained [here](https://github.com/rubenlagus/TelegramBots/wiki/How-To-Update#to-version-243) in "How To Update"
> At the beginning of your program (before creating your TelegramBotsApi instance, add the following line:
```
Expand Down
8 changes: 4 additions & 4 deletions TelegramBots.wiki/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
sendPhotoRequest.setPhoto(url);
try {
// Execute the method
sendPhoto(sendPhotoRequest);
execute(sendPhotoRequest);
} catch (TelegramApiException e) {
e.printStackTrace();
}
Expand All @@ -103,7 +103,7 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
sendPhotoRequest.setPhoto(fileId);
try {
// Execute the method
sendPhoto(sendPhotoRequest);
execute(sendPhotoRequest);
} catch (TelegramApiException e) {
e.printStackTrace();
}
Expand All @@ -118,7 +118,7 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
sendPhotoRequest.setNewPhoto(new File(filePath));
try {
// Execute the method
sendPhoto(sendPhotoRequest);
execute(sendPhotoRequest);
} catch (TelegramApiException e) {
e.printStackTrace();
}
Expand All @@ -144,7 +144,7 @@ if (update.hasMessage() && update.getMessage().hasPhoto()) {
.setPhoto(f_id)
.setCaption("Photo");
try {
sendPhoto(msg); // Call method to send the photo
execute(msg); // Call method to send the photo
} catch (TelegramApiException e) {
e.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion TelegramBots.wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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>3.6.1</version>
<version>4.0.0</version>
</dependency>
```
* With **Gradle**:
Expand Down
6 changes: 6 additions & 0 deletions TelegramBots.wiki/How-To-Update.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### <a id="4.0.0"></a>To version 4.0.0 ###
1. Replace removed method from AbsSender with `execute` requests.
2. Everything under "Telegrambots-meta" has been moved to package `org.telegram.telegrambots.meta`.
3. `close` method has been removed from `BotSession`, use `stop` instead.
4. All methods that are intended to upload files are using now `InputMedia` and `InputFile`.

### <a id="2.4.3"></a>To version 2.4.3 ###
1. Replace `BotOptions` by `DefaultBotOptions`.
2. At the beginning of your program (before creating your `TelegramBotsApi` or `Bot` instance, add the following line:
Expand Down
42 changes: 22 additions & 20 deletions TelegramBots.wiki/Using-Http-Proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MyBot extends AbilityBot {

Now you are able to set up your proxy

#### without authentication
#### Without authentication

```java
public class Main {
Expand All @@ -51,13 +51,12 @@ public class Main {
TelegramBotsApi botsApi = new TelegramBotsApi();

// Set up Http proxy
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);

HttpHost httpHost = new HttpHost(PROXY_HOST, PROXY_PORT);

RequestConfig requestConfig = RequestConfig.custom().setProxy(httpHost).setAuthenticationEnabled(false).build();
botOptions.setRequestConfig(requestConfig);
botOptions.setHttpProxy(httpHost);
botOptions.setProxyHost(PROXY_HOST);
botOptions.setProxyPort(PROXY_PORT);
// Select proxy type: [HTTP|SOCKS4|SOCKS5] (default: NO_PROXY)
botOptions.setProxyType(DefaultBotOptions.ProxyType.SOCKS5);

// Register your newly created AbilityBot
MyBot bot = new MyBot(BOT_TOKEN, BOT_NAME, botOptions);
Expand Down Expand Up @@ -89,25 +88,26 @@ public class Main {
public static void main(String[] args) {
try {

// Create the Authenticator that will return auth's parameters for proxy authentication
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(PROXY_USER, PROXY_PASSWORD.toCharArray());
}
});

ApiContextInitializer.init();

// Create the TelegramBotsApi object to register your bots
TelegramBotsApi botsApi = new TelegramBotsApi();

// Set up Http proxy
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);

CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(PROXY_HOST, PROXY_PORT),
new UsernamePasswordCredentials(PROXY_USER, PROXY_PASSWORD));

HttpHost httpHost = new HttpHost(PROXY_HOST, PROXY_PORT);
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);

RequestConfig requestConfig = RequestConfig.custom().setProxy(httpHost).setAuthenticationEnabled(true).build();
botOptions.setRequestConfig(requestConfig);
botOptions.setCredentialsProvider(credsProvider);
botOptions.setHttpProxy(httpHost);
botOptions.setProxyHost(PROXY_HOST);
botOptions.setProxyPort(PROXY_PORT);
// Select proxy type: [HTTP|SOCKS4|SOCKS5] (default: NO_PROXY)
botOptions.setProxyType(DefaultBotOptions.ProxyType.SOCKS5);

// Register your newly created AbilityBot
MyBot bot = new MyBot(BOT_TOKEN, BOT_NAME, botOptions);
Expand All @@ -119,4 +119,6 @@ public class Main {
}
}
}
```
```

If you need something more complex than one proxy, then you can create more complex Authenticator that will check host and other parameters of proxy and return auth values based on them (for more information see code of java.net.Authenticator class)
2 changes: 1 addition & 1 deletion TelegramBots.wiki/abilities/Bot-Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import org.telegram.abilitybots.api.db.MapDBContext;
import org.telegram.abilitybots.api.objects.EndUser;
import org.telegram.abilitybots.api.objects.MessageContext;
import org.telegram.abilitybots.api.sender.MessageSender;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.Update;

import static org.mockito.Mockito.*;

Expand Down
7 changes: 4 additions & 3 deletions TelegramBots.wiki/abilities/Simple-Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ As with any Java project, you will need to set your dependencies.
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
</dependency>
```
* **Gradle**
Expand Down Expand Up @@ -102,8 +102,9 @@ If you're in doubt that you're missing some code, the full code example can be i
Go ahead and "/hello" to your bot. It should respond back with "Hello World!".

Since you've implemented an AbilityBot, you get **factory abilities** as well. Try:
* /commands - Prints all commands supported by the bot
* This will essentially print "hello - says hello world!". Yes! This is the information we supplied to the ability. The bot prints the commands in the format accepted by BotFather. So, whenever you change, add or remove commands, you can simply /commands and forward that message to BotFather.
* /report - Prints all user-defined commands supported by the bot
* This will essentially print "hello - says hello world!". Yes! This is the information we supplied to the ability. The bot prints the commands in the format accepted by BotFather. So, whenever you change, add or remove commands, you can simply /report and forward that message to BotFather.
* /commands - Prints all commands exposed by the bot (factory and user-defined, with and without info)
* /claim - Claims this bot
* /backup - returns a backup of the bot database
* /recover - recovers the database
Expand Down
Binary file added jetbrains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>3.6.1</version>
<version>4.0.0</version>

<modules>
<module>telegrambots</module>
<module>telegrambots-meta</module>
<module>telegrambots-extensions</module>
<module>telegrambots-abilities</module>
<module>telegrambots-spring-boot-starter</module>
<module>telegrambots-chat-session-bot</module>
</modules>

<licenses>
Expand All @@ -27,6 +28,6 @@

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<bots.version>3.6.1</bots.version>
<bots.version>4.0.0</bots.version>
</properties>
</project>
2 changes: 1 addition & 1 deletion telegrambots-abilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions telegrambots-abilities/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-abilities</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
<packaging>jar</packaging>

<name>Telegram Ability Bot</name>
Expand Down Expand Up @@ -65,7 +65,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bots.version>3.6.1</bots.version>
<bots.version>4.0.0</bots.version>
<commonslang.version>3.5</commonslang.version>
<mapdb.version>3.0.4</mapdb.version>
<guava.version>19.0</guava.version>
Expand Down
Loading

0 comments on commit 01765d0

Please sign in to comment.