Skip to content

Commit

Permalink
Merge pull request #57 from yvasyliev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yvasyliev authored Jun 4, 2021
2 parents f14dddf + c056dd7 commit cd054dc
Show file tree
Hide file tree
Showing 157 changed files with 933 additions and 151 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Total alerts](https://img.shields.io/lgtm/alerts/g/yvasyliev/java-vk-bots-long-poll-api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/yvasyliev/java-vk-bots-long-poll-api/alerts/)
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/yvasyliev/java-vk-bots-long-poll-api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/yvasyliev/java-vk-bots-long-poll-api/context:java)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
[![javadoc](https://javadoc.io/badge2/com.github.yvasyliev/java-vk-bots-longpoll-api/javadoc.svg)](https://javadoc.io/doc/com.github.yvasyliev/java-vk-bots-longpoll-api)
# Java VK Bots Long Poll API
A Java library to create VK bots using Bots Long Poll API.

Expand Down Expand Up @@ -32,7 +33,7 @@ This library uses the next third-party dependencies:
<dependency>
<groupId>com.github.yvasyliev</groupId>
<artifactId>java-vk-bots-longpoll-api</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
</dependency>
```
4. Extend `LongPollBot` class and override necessary methods:
Expand All @@ -49,7 +50,7 @@ public class HelloBot extends LongPollBot {
.setMessage(response)
.execute();
}
} catch (BotsLongPollAPIException | BotsLongPollException e) {
} catch (BotsLongPollException e) {
e.printStackTrace();
}
}
Expand All @@ -64,7 +65,7 @@ public class HelloBot extends LongPollBot {
return 999999999;
}

public static void main(String[] args) throws BotsLongPollAPIException, BotsLongPollException {
public static void main(String[] args) throws BotsLongPollException {
new BotsLongPoll(new HelloBot()).run();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.yvasyliev</groupId>
<artifactId>java-vk-bots-longpoll-api</artifactId>
<packaging>jar</packaging>
<version>1.5.1</version>
<version>1.5.2</version>

<name>Java VK Bots Long Poll API</name>
<description>A Java library to create VK bots using Bots Long Poll API</description>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/api/longpoll/bots/BotsLongPoll.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package api.longpoll.bots;

import api.longpoll.bots.exceptions.BotsLongPollAPIException;
import api.longpoll.bots.exceptions.BotsLongPollException;
import api.longpoll.bots.handlers.update.LongPollBotUpdateHandler;
import api.longpoll.bots.handlers.update.UpdateHandler;
import api.longpoll.bots.server.Client;
import api.longpoll.bots.server.InitializedLongPollClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Bots Long Poll entry point. Takes {@link LongPollBot} and listens to VK server.
*/
public class BotsLongPoll {
private static final Logger log = LoggerFactory.getLogger(BotsLongPoll.class);
private boolean running = true;
Expand All @@ -20,7 +24,12 @@ public BotsLongPoll(LongPollBot bot) {
this.updateHandler = new LongPollBotUpdateHandler(bot);
}

public void run() throws BotsLongPollAPIException, BotsLongPollException {
/**
* Starts listening to VK server.
*
* @throws BotsLongPollException if error occurs.
*/
public void run() throws BotsLongPollException {
log.debug("Starting bot with group_id = {}", bot.getGroupId());
while (running) {
updateHandler.handleUpdates(client.getUpdates());
Expand Down
Loading

0 comments on commit cd054dc

Please sign in to comment.