Добавил версию vk-api snapshot
This commit is contained in:
parent
9a719d70b8
commit
edebc5c4fa
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
<artifactId>vk-bot</artifactId>
|
<artifactId>vk-bot</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -35,7 +34,7 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<vk.api.ver>0.5.12</vk.api.ver>
|
<vk.api.ver>0.5.13-SNAPSHOT</vk.api.ver>
|
||||||
|
|
||||||
<spring.core>5.1.3.RELEASE</spring.core>
|
<spring.core>5.1.3.RELEASE</spring.core>
|
||||||
<spring.context>5.1.3.RELEASE</spring.context>
|
<spring.context>5.1.3.RELEASE</spring.context>
|
||||||
@ -64,6 +63,12 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vk.api</groupId>
|
||||||
|
<artifactId>sdk</artifactId>
|
||||||
|
<version>${vk.api.ver}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@ -76,12 +81,6 @@
|
|||||||
<version>${log4j}</version>
|
<version>${log4j}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.vk.api</groupId>
|
|
||||||
<artifactId>sdk</artifactId>
|
|
||||||
<version>${vk.api.ver}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
@ -119,6 +118,12 @@
|
|||||||
<version>${javax.servlet}</version>
|
<version>${javax.servlet}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
<artifactId>jetty-util</artifactId>
|
<artifactId>jetty-util</artifactId>
|
||||||
@ -153,5 +158,6 @@
|
|||||||
<version>${hibernate.core}</version>
|
<version>${hibernate.core}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -17,5 +17,8 @@ public class VkOpenMethod {
|
|||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendMessage(Integer id, String text) {
|
||||||
|
vk.messages().send(actor).userId(id).peerId(id).message(text);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,6 @@ import com.vk.api.sdk.exceptions.ApiException;
|
|||||||
import com.vk.api.sdk.exceptions.ClientException;
|
import com.vk.api.sdk.exceptions.ClientException;
|
||||||
import com.vk.api.sdk.httpclient.HttpTransportClient;
|
import com.vk.api.sdk.httpclient.HttpTransportClient;
|
||||||
import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse;
|
import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse;
|
||||||
import org.sadtech.vkbot.listener.data.impl.ResponseDataVk;
|
|
||||||
import org.sadtech.vkbot.listener.impl.EventListenerVk;
|
|
||||||
import org.sadtech.vkbot.service.UserService;
|
|
||||||
import org.sadtech.vkbot.service.impl.UserServiceImpl;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
package org.sadtech.vkbot.config;
|
package org.sadtech.vkbot.config;
|
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j;
|
||||||
import org.sadtech.vkbot.listener.EventListenable;
|
import org.sadtech.vkbot.listener.EventListenable;
|
||||||
import org.sadtech.vkbot.listener.Observable;
|
import org.sadtech.vkbot.listener.Observable;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
|
@Log4j
|
||||||
public class TestMain {
|
public class TestMain {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
log.info("\n\n\n\n=== Запуск прогарммы ===\n\n");
|
||||||
|
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfigVk.class);
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfigVk.class);
|
||||||
context.register(DataConfig.class);
|
context.register(DataConfig.class);
|
||||||
EventListenable eventListener = context.getBean(EventListenable.class);
|
EventListenable eventListener = context.getBean(EventListenable.class);
|
||||||
eventListener.listen();
|
eventListener.listen();
|
||||||
Observable dispetcherHandler = context.getBean(Observable.class);
|
Observable dispetcherHandler = context.getBean(Observable.class);
|
||||||
dispetcherHandler.packaging();
|
dispetcherHandler.packaging();
|
||||||
|
|
||||||
|
log.info("\n\n=== Конец программы ===\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class DispetcherHandler implements Observable {
|
|||||||
objects = new ArrayList<JsonObject>(date.getJsonObjects());
|
objects = new ArrayList<JsonObject>(date.getJsonObjects());
|
||||||
date.cleanAll();
|
date.cleanAll();
|
||||||
for (JsonObject object : objects) {
|
for (JsonObject object : objects) {
|
||||||
System.out.println(object);
|
log.info(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.sadtech.vkbot.listener.impl;
|
package org.sadtech.vkbot.listener.impl;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import com.vk.api.sdk.actions.LongPoll;
|
import com.vk.api.sdk.actions.LongPoll;
|
||||||
import com.vk.api.sdk.callback.longpoll.queries.GetLongPollEventsQuery;
|
import com.vk.api.sdk.callback.longpoll.queries.GetLongPollEventsQuery;
|
||||||
import com.vk.api.sdk.callback.longpoll.responses.GetLongPollEventsResponse;
|
import com.vk.api.sdk.callback.longpoll.responses.GetLongPollEventsResponse;
|
||||||
@ -8,9 +10,12 @@ import com.vk.api.sdk.client.actors.GroupActor;
|
|||||||
import com.vk.api.sdk.exceptions.ApiException;
|
import com.vk.api.sdk.exceptions.ApiException;
|
||||||
import com.vk.api.sdk.exceptions.ClientException;
|
import com.vk.api.sdk.exceptions.ClientException;
|
||||||
import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse;
|
import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse;
|
||||||
|
import jdk.nashorn.internal.parser.JSONParser;
|
||||||
import lombok.extern.log4j.Log4j;
|
import lombok.extern.log4j.Log4j;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.sadtech.vkbot.listener.EventListenable;
|
import org.sadtech.vkbot.listener.EventListenable;
|
||||||
import org.sadtech.vkbot.listener.data.ResponsibleData;
|
import org.sadtech.vkbot.listener.data.ResponsibleData;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -43,18 +48,24 @@ public class EventListenerVk implements EventListenable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void listen() throws ClientException, ApiException {
|
public void listen() throws Exception {
|
||||||
initServer();
|
initServer();
|
||||||
do {
|
do {
|
||||||
GetLongPollEventsResponse eventsResponse;
|
GetLongPollEventsResponse eventsResponse;
|
||||||
eventsResponse = longPollEventsQuery.execute();
|
eventsResponse = longPollEventsQuery.execute();
|
||||||
log.info(eventsResponse);
|
|
||||||
if (eventsResponse.getUpdates().toArray().length != 0) {
|
if (eventsResponse.getUpdates().toArray().length != 0) {
|
||||||
responseData.add(eventsResponse.getUpdates().get(0));
|
responseData.add(eventsResponse.getUpdates().get(0));
|
||||||
// log.info(eventsResponse.getUpdates());
|
log.info(eventsResponse.getUpdates());
|
||||||
|
String test = "{\"one_time\":false,\"buttons\":[[{\"action\":{\"type\":\"text\",\"payload\":\"{\\\"button\\\": \\\"1\\\"}\",\"label\":\"Red2\"},\"color\":\"negative\"},{\"action\":{\"type\":\"text\",\"payload\":\"{\\\"button\\\": \\\"2\\\"}\",\"label\":\"Green\"},\"color\":\"positive\"}],[{\"action\":{\"type\":\"text\",\"payload\":\"{\\\"button\\\": \\\"3\\\"}\",\"label\":\"White\"},\"color\":\"default\"},{\"action\":{\"type\":\"text\",\"payload\":\"{\\\"button\\\": \\\"4\\\"}\",\"label\":\"Blue\"},\"color\":\"primary\"}]]}";
|
||||||
|
vk.messages().send(actor).peerId(244319573).keyboard(test).message("Сообщение получено").execute();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
longPollEventsQuery = longPoll.getEvents(server.getServer(), server.getKey(), eventsResponse.getTs()).waitTime(20);
|
longPollEventsQuery = longPoll.getEvents(server.getServer(), server.getKey(), eventsResponse.getTs()).waitTime(20);
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user