diff --git a/pom.xml b/pom.xml
index d871895..f0594a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,17 +4,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- org.sadtech.vkbot
- core
+ org.sadtech.bot
+ bot-core
0.4.3-SNAPSHOT
+ jar
+
org.apache.maven.plugins
maven-compiler-plugin
-
- 7
+
+ 8
@@ -40,11 +42,6 @@
gson
${gson.ver}
-
- com.vk.api
- sdk
- ${vksdk.ver}
-
log4j
log4j
diff --git a/src/main/java/org/sadtech/vkbot/core/entity/BoxAnswer.java b/src/main/java/org/sadtech/bot/core/domain/BoxAnswer.java
similarity index 97%
rename from src/main/java/org/sadtech/vkbot/core/entity/BoxAnswer.java
rename to src/main/java/org/sadtech/bot/core/domain/BoxAnswer.java
index 56f6121..d0e037c 100644
--- a/src/main/java/org/sadtech/vkbot/core/entity/BoxAnswer.java
+++ b/src/main/java/org/sadtech/bot/core/domain/BoxAnswer.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.entity;
+package org.sadtech.bot.core.domain;
import java.util.Objects;
diff --git a/src/main/java/org/sadtech/vkbot/core/entity/Comment.java b/src/main/java/org/sadtech/bot/core/domain/Comment.java
similarity index 89%
rename from src/main/java/org/sadtech/vkbot/core/entity/Comment.java
rename to src/main/java/org/sadtech/bot/core/domain/Comment.java
index dc1d7e1..d69cd77 100644
--- a/src/main/java/org/sadtech/vkbot/core/entity/Comment.java
+++ b/src/main/java/org/sadtech/bot/core/domain/Comment.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.entity;
+package org.sadtech.bot.core.domain;
//@TODO: Дописать класс
public class Comment {
diff --git a/src/main/java/org/sadtech/vkbot/core/entity/Mail.java b/src/main/java/org/sadtech/bot/core/domain/Mail.java
similarity index 69%
rename from src/main/java/org/sadtech/vkbot/core/entity/Mail.java
rename to src/main/java/org/sadtech/bot/core/domain/Mail.java
index 4a47d0e..1952d8e 100644
--- a/src/main/java/org/sadtech/vkbot/core/entity/Mail.java
+++ b/src/main/java/org/sadtech/bot/core/domain/Mail.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.entity;
+package org.sadtech.bot.core.domain;
import java.util.Objects;
@@ -6,7 +6,6 @@ public class Mail {
private Integer id;
private Integer date;
- private Person person;
private Integer peerId;
private String body;
@@ -14,13 +13,6 @@ public class Mail {
}
- public Mail(Integer id, Integer date, Person userId, String body) {
- this.id = id;
- this.date = date;
- this.person = userId;
- this.body = body;
- }
-
public Integer getId() {
return id;
}
@@ -37,13 +29,6 @@ public class Mail {
this.date = date;
}
- public Person getPerson() {
- return person;
- }
-
- public void setPerson(Person person) {
- this.person = person;
- }
public String getBody() {
return body;
@@ -68,12 +53,21 @@ public class Mail {
Mail mail = (Mail) o;
return Objects.equals(id, mail.id) &&
Objects.equals(date, mail.date) &&
- Objects.equals(person, mail.person) &&
Objects.equals(body, mail.body);
}
@Override
public int hashCode() {
- return Objects.hash(id, date, person, body);
+ return Objects.hash(id, date, body);
+ }
+
+ @Override
+ public String toString() {
+ return "Mail{" +
+ "id=" + id +
+ ", date=" + date +
+ ", peerId=" + peerId +
+ ", body='" + body + '\'' +
+ '}';
}
}
diff --git a/src/main/java/org/sadtech/vkbot/core/entity/MailSend.java b/src/main/java/org/sadtech/bot/core/domain/MailSend.java
similarity index 96%
rename from src/main/java/org/sadtech/vkbot/core/entity/MailSend.java
rename to src/main/java/org/sadtech/bot/core/domain/MailSend.java
index db19bd4..8238818 100644
--- a/src/main/java/org/sadtech/vkbot/core/entity/MailSend.java
+++ b/src/main/java/org/sadtech/bot/core/domain/MailSend.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.entity;
+package org.sadtech.bot.core.domain;
public class MailSend {
diff --git a/src/main/java/org/sadtech/vkbot/core/entity/Person.java b/src/main/java/org/sadtech/bot/core/domain/Person.java
similarity index 97%
rename from src/main/java/org/sadtech/vkbot/core/entity/Person.java
rename to src/main/java/org/sadtech/bot/core/domain/Person.java
index 4a6e4d3..80970ee 100644
--- a/src/main/java/org/sadtech/vkbot/core/entity/Person.java
+++ b/src/main/java/org/sadtech/bot/core/domain/Person.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.entity;
+package org.sadtech.bot.core.domain;
import java.util.Objects;
diff --git a/src/main/java/org/sadtech/vkbot/core/insert/InsertWords.java b/src/main/java/org/sadtech/bot/core/insert/InsertWords.java
similarity index 95%
rename from src/main/java/org/sadtech/vkbot/core/insert/InsertWords.java
rename to src/main/java/org/sadtech/bot/core/insert/InsertWords.java
index ba2588e..6f0ca70 100644
--- a/src/main/java/org/sadtech/vkbot/core/insert/InsertWords.java
+++ b/src/main/java/org/sadtech/bot/core/insert/InsertWords.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.insert;
+package org.sadtech.bot.core.insert;
import java.util.List;
import java.util.regex.Matcher;
diff --git a/src/main/java/org/sadtech/bot/core/repository/CommentRepository.java b/src/main/java/org/sadtech/bot/core/repository/CommentRepository.java
new file mode 100644
index 0000000..0f9c995
--- /dev/null
+++ b/src/main/java/org/sadtech/bot/core/repository/CommentRepository.java
@@ -0,0 +1,9 @@
+package org.sadtech.bot.core.repository;
+
+import org.sadtech.bot.core.domain.Comment;
+
+public interface CommentRepository {
+
+ void add(Comment comment);
+
+}
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/EventRepository.java b/src/main/java/org/sadtech/bot/core/repository/EventRepository.java
similarity index 77%
rename from src/main/java/org/sadtech/vkbot/core/repository/EventRepository.java
rename to src/main/java/org/sadtech/bot/core/repository/EventRepository.java
index d98fedd..441c190 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/EventRepository.java
+++ b/src/main/java/org/sadtech/bot/core/repository/EventRepository.java
@@ -1,4 +1,4 @@
-package org.sadtech.vkbot.core.repository;
+package org.sadtech.bot.core.repository;
import java.util.Queue;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/MailRepository.java b/src/main/java/org/sadtech/bot/core/repository/MailRepository.java
similarity index 64%
rename from src/main/java/org/sadtech/vkbot/core/repository/MailRepository.java
rename to src/main/java/org/sadtech/bot/core/repository/MailRepository.java
index 54bcf12..0ae005f 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/MailRepository.java
+++ b/src/main/java/org/sadtech/bot/core/repository/MailRepository.java
@@ -1,6 +1,6 @@
-package org.sadtech.vkbot.core.repository;
+package org.sadtech.bot.core.repository;
-import org.sadtech.vkbot.core.entity.Mail;
+import org.sadtech.bot.core.domain.Mail;
import java.util.List;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/PersonRepository.java b/src/main/java/org/sadtech/bot/core/repository/PersonRepository.java
similarity index 53%
rename from src/main/java/org/sadtech/vkbot/core/repository/PersonRepository.java
rename to src/main/java/org/sadtech/bot/core/repository/PersonRepository.java
index f8bac8f..d0dafb4 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/PersonRepository.java
+++ b/src/main/java/org/sadtech/bot/core/repository/PersonRepository.java
@@ -1,6 +1,6 @@
-package org.sadtech.vkbot.core.repository;
+package org.sadtech.bot.core.repository;
-import org.sadtech.vkbot.core.entity.Person;
+import org.sadtech.bot.core.domain.Person;
public interface PersonRepository {
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/impl/CommentRepositoryList.java b/src/main/java/org/sadtech/bot/core/repository/impl/CommentRepositoryList.java
similarity index 63%
rename from src/main/java/org/sadtech/vkbot/core/repository/impl/CommentRepositoryList.java
rename to src/main/java/org/sadtech/bot/core/repository/impl/CommentRepositoryList.java
index e460d1d..f9cf34e 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/impl/CommentRepositoryList.java
+++ b/src/main/java/org/sadtech/bot/core/repository/impl/CommentRepositoryList.java
@@ -1,7 +1,7 @@
-package org.sadtech.vkbot.core.repository.impl;
+package org.sadtech.bot.core.repository.impl;
-import org.sadtech.vkbot.core.entity.Comment;
-import org.sadtech.vkbot.core.repository.CommentRepository;
+import org.sadtech.bot.core.domain.Comment;
+import org.sadtech.bot.core.repository.CommentRepository;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/impl/EventRepositoryQueue.java b/src/main/java/org/sadtech/bot/core/repository/impl/EventRepositoryQueue.java
similarity index 83%
rename from src/main/java/org/sadtech/vkbot/core/repository/impl/EventRepositoryQueue.java
rename to src/main/java/org/sadtech/bot/core/repository/impl/EventRepositoryQueue.java
index 61ba2b4..8f191b5 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/impl/EventRepositoryQueue.java
+++ b/src/main/java/org/sadtech/bot/core/repository/impl/EventRepositoryQueue.java
@@ -1,7 +1,7 @@
-package org.sadtech.vkbot.core.repository.impl;
+package org.sadtech.bot.core.repository.impl;
import com.google.gson.JsonObject;
-import org.sadtech.vkbot.core.repository.EventRepository;
+import org.sadtech.bot.core.repository.EventRepository;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/impl/MailRepositoryList.java b/src/main/java/org/sadtech/bot/core/repository/impl/MailRepositoryList.java
similarity index 82%
rename from src/main/java/org/sadtech/vkbot/core/repository/impl/MailRepositoryList.java
rename to src/main/java/org/sadtech/bot/core/repository/impl/MailRepositoryList.java
index 4391bec..dc753f2 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/impl/MailRepositoryList.java
+++ b/src/main/java/org/sadtech/bot/core/repository/impl/MailRepositoryList.java
@@ -1,8 +1,8 @@
-package org.sadtech.vkbot.core.repository.impl;
+package org.sadtech.bot.core.repository.impl;
-import org.sadtech.vkbot.core.entity.Mail;
-import org.sadtech.vkbot.core.repository.EventRepository;
-import org.sadtech.vkbot.core.repository.MailRepository;
+import org.sadtech.bot.core.domain.Mail;
+import org.sadtech.bot.core.repository.EventRepository;
+import org.sadtech.bot.core.repository.MailRepository;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/impl/PersonRepositoryMap.java b/src/main/java/org/sadtech/bot/core/repository/impl/PersonRepositoryMap.java
similarity index 76%
rename from src/main/java/org/sadtech/vkbot/core/repository/impl/PersonRepositoryMap.java
rename to src/main/java/org/sadtech/bot/core/repository/impl/PersonRepositoryMap.java
index cca2610..ba212f1 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/impl/PersonRepositoryMap.java
+++ b/src/main/java/org/sadtech/bot/core/repository/impl/PersonRepositoryMap.java
@@ -1,8 +1,8 @@
-package org.sadtech.vkbot.core.repository.impl;
+package org.sadtech.bot.core.repository.impl;
-import org.sadtech.vkbot.core.entity.Person;
-import org.sadtech.vkbot.core.repository.EventRepository;
-import org.sadtech.vkbot.core.repository.PersonRepository;
+import org.sadtech.bot.core.domain.Person;
+import org.sadtech.bot.core.repository.EventRepository;
+import org.sadtech.bot.core.repository.PersonRepository;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/impl/TerminalComandRepositoryQueue.java b/src/main/java/org/sadtech/bot/core/repository/impl/TerminalComandRepositoryQueue.java
similarity index 76%
rename from src/main/java/org/sadtech/vkbot/core/repository/impl/TerminalComandRepositoryQueue.java
rename to src/main/java/org/sadtech/bot/core/repository/impl/TerminalComandRepositoryQueue.java
index 90e178a..24cc99a 100644
--- a/src/main/java/org/sadtech/vkbot/core/repository/impl/TerminalComandRepositoryQueue.java
+++ b/src/main/java/org/sadtech/bot/core/repository/impl/TerminalComandRepositoryQueue.java
@@ -1,7 +1,7 @@
-package org.sadtech.vkbot.core.repository.impl;
+package org.sadtech.bot.core.repository.impl;
-import org.sadtech.vkbot.core.entity.Mail;
-import org.sadtech.vkbot.core.repository.EventRepository;
+import org.sadtech.bot.core.domain.Mail;
+import org.sadtech.bot.core.repository.EventRepository;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
diff --git a/src/main/java/org/sadtech/vkbot/core/sender/Sent.java b/src/main/java/org/sadtech/bot/core/sender/Sent.java
similarity index 60%
rename from src/main/java/org/sadtech/vkbot/core/sender/Sent.java
rename to src/main/java/org/sadtech/bot/core/sender/Sent.java
index 6ccdd09..63a33ba 100644
--- a/src/main/java/org/sadtech/vkbot/core/sender/Sent.java
+++ b/src/main/java/org/sadtech/bot/core/sender/Sent.java
@@ -1,6 +1,6 @@
-package org.sadtech.vkbot.core.sender;
+package org.sadtech.bot.core.sender;
-import org.sadtech.vkbot.core.entity.BoxAnswer;
+import org.sadtech.bot.core.domain.BoxAnswer;
public interface Sent {
diff --git a/src/main/java/org/sadtech/bot/core/service/EventService.java b/src/main/java/org/sadtech/bot/core/service/EventService.java
new file mode 100644
index 0000000..b62c1a9
--- /dev/null
+++ b/src/main/java/org/sadtech/bot/core/service/EventService.java
@@ -0,0 +1,15 @@
+package org.sadtech.bot.core.service;
+
+import java.util.List;
+
+public interface EventService {
+
+ void add(T event);
+
+ List getEvent(Integer timeFrom, Integer timeTo);
+
+ List getFirstEventByTime(Integer timeFrom, Integer timeTo);
+
+ List getLastEventByTime(Integer timeFrom, Integer timeTo);
+
+}
diff --git a/src/main/java/org/sadtech/bot/core/service/PersonService.java b/src/main/java/org/sadtech/bot/core/service/PersonService.java
new file mode 100644
index 0000000..21adbd9
--- /dev/null
+++ b/src/main/java/org/sadtech/bot/core/service/PersonService.java
@@ -0,0 +1,15 @@
+package org.sadtech.bot.core.service;
+
+import org.sadtech.bot.core.domain.Person;
+
+public interface PersonService {
+
+ void add(Person person);
+
+ Person get(Integer id);
+
+ boolean checkPerson(Integer idPerson);
+
+ Person createPerson(Integer userId);
+
+}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/RawEventService.java b/src/main/java/org/sadtech/bot/core/service/RawEventService.java
similarity index 76%
rename from src/main/java/org/sadtech/vkbot/core/service/RawEventService.java
rename to src/main/java/org/sadtech/bot/core/service/RawEventService.java
index 7396312..f627bbd 100644
--- a/src/main/java/org/sadtech/vkbot/core/service/RawEventService.java
+++ b/src/main/java/org/sadtech/bot/core/service/RawEventService.java
@@ -1,7 +1,7 @@
-package org.sadtech.vkbot.core.service;
+package org.sadtech.bot.core.service;
import com.google.gson.JsonObject;
-import org.sadtech.vkbot.core.repository.EventRepository;
+import org.sadtech.bot.core.repository.EventRepository;
import java.util.Queue;
diff --git a/src/main/java/org/sadtech/vkbot/core/service/impl/RawEventServiceImpl.java b/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java
similarity index 87%
rename from src/main/java/org/sadtech/vkbot/core/service/impl/RawEventServiceImpl.java
rename to src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java
index f150c47..f67ea02 100644
--- a/src/main/java/org/sadtech/vkbot/core/service/impl/RawEventServiceImpl.java
+++ b/src/main/java/org/sadtech/bot/core/service/impl/RawEventServiceImpl.java
@@ -1,9 +1,9 @@
-package org.sadtech.vkbot.core.service.impl;
+package org.sadtech.bot.core.service.impl;
import com.google.gson.JsonObject;
import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.repository.EventRepository;
-import org.sadtech.vkbot.core.service.RawEventService;
+import org.sadtech.bot.core.repository.EventRepository;
+import org.sadtech.bot.core.service.RawEventService;
import java.util.Queue;
diff --git a/src/main/java/org/sadtech/vkbot/core/VkApi.java b/src/main/java/org/sadtech/vkbot/core/VkApi.java
deleted file mode 100644
index b6eb483..0000000
--- a/src/main/java/org/sadtech/vkbot/core/VkApi.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.sadtech.vkbot.core;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.vk.api.sdk.client.VkApiClient;
-import com.vk.api.sdk.client.actors.GroupActor;
-import com.vk.api.sdk.exceptions.ApiException;
-import com.vk.api.sdk.exceptions.ClientException;
-import com.vk.api.sdk.objects.users.UserMin;
-import com.vk.api.sdk.objects.users.UserXtrCounters;
-import com.vk.api.sdk.queries.users.UserField;
-import org.apache.log4j.Logger;
-
-import java.util.List;
-
-public class VkApi {
-
- public static final Logger log = Logger.getLogger(String.valueOf(VkApi.class));
-
- private VkApiClient vk;
- private GroupActor actor;
-
- public VkApi(VkConnect vkConnect) {
- vk = vkConnect.getVkApiClient();
- actor = vkConnect.getGroupActor();
- }
-
- public UserMin getUserMini(Integer id) {
- UserMin userMin = null;
- Gson gson = new Gson();
- try {
- List temp = vk.users().get(actor).userIds(String.valueOf(id)).execute();
- JsonParser parser = new JsonParser();
- JsonObject object = parser.parse(temp.get(0).toString().substring(15)).getAsJsonObject();
- object.add("last_name", object.get("lastName"));
- object.add("first_name", object.get("firstName"));
- userMin = gson.fromJson(object, UserMin.class);
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
- }
- return userMin;
- }
-
- public String getUserUniver(Integer id) {
- List temp = null;
- try {
- temp = vk.users().get(actor).userIds(String.valueOf(id)).fields(UserField.UNIVERSITIES).execute();
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
- }
- return temp != null ? temp.get(0).getUniversities().get(0).getName() : null;
- }
-
- public String getUserCity(Integer id) {
- List temp = null;
- try {
- temp = vk.users().get(actor).userIds(String.valueOf(id)).fields(UserField.CITY).execute();
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
- }
- if (temp != null) {
- if (temp.get(0).getCity() != null) {
- log.info("Запрошен город пользователя: " + temp.get(0).getCity().getTitle());
- return temp.get(0).getCity().getTitle();
- }
- }
- return null;
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/VkConfig.java b/src/main/java/org/sadtech/vkbot/core/VkConfig.java
deleted file mode 100644
index 4a5d8ae..0000000
--- a/src/main/java/org/sadtech/vkbot/core/VkConfig.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.sadtech.vkbot.core;
-
-import java.util.Objects;
-
-public class VkConfig {
-
- private String groupToken;
- private Integer groupId;
- private String serviceToken;
- private Integer appId;
- private String groupSecretKey;
- private String groupPublicKey;
-
- public VkConfig() {
-
- }
-
- public String getGroupToken() {
- return groupToken;
- }
-
- public void setGroupToken(String groupToken) {
- this.groupToken = groupToken;
- }
-
- public Integer getGroupId() {
- return groupId;
- }
-
- public void setGroupId(Integer groupId) {
- this.groupId = groupId;
- }
-
- public String getServiceToken() {
- return serviceToken;
- }
-
- public void setServiceToken(String serviceToken) {
- this.serviceToken = serviceToken;
- }
-
- public Integer getAppId() {
- return appId;
- }
-
- public void setAppId(Integer appId) {
- this.appId = appId;
- }
-
- public String getGroupSecretKey() {
- return groupSecretKey;
- }
-
- public void setGroupSecretKey(String groupSecretKey) {
- this.groupSecretKey = groupSecretKey;
- }
-
- public String getGroupPublicKey() {
- return groupPublicKey;
- }
-
- public void setGroupPublicKey(String groupPublicKey) {
- this.groupPublicKey = groupPublicKey;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- VkConfig vkConfig = (VkConfig) o;
- return Objects.equals(groupToken, vkConfig.groupToken) &&
- Objects.equals(groupId, vkConfig.groupId) &&
- Objects.equals(serviceToken, vkConfig.serviceToken) &&
- Objects.equals(appId, vkConfig.appId) &&
- Objects.equals(groupSecretKey, vkConfig.groupSecretKey) &&
- Objects.equals(groupPublicKey, vkConfig.groupPublicKey);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(groupToken, groupId, serviceToken, appId, groupSecretKey, groupPublicKey);
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/VkConnect.java b/src/main/java/org/sadtech/vkbot/core/VkConnect.java
deleted file mode 100644
index c10e7bd..0000000
--- a/src/main/java/org/sadtech/vkbot/core/VkConnect.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.sadtech.vkbot.core;
-
-import com.vk.api.sdk.client.VkApiClient;
-import com.vk.api.sdk.client.actors.GroupActor;
-import com.vk.api.sdk.client.actors.ServiceActor;
-import com.vk.api.sdk.httpclient.HttpTransportClient;
-
-public class VkConnect {
-
- private VkConfig vkConfig;
-
- private VkApiClient vkApiClient;
- private GroupActor groupActor;
- private ServiceActor serviceActor;
-
- public VkConnect(VkConfig vkConfig) {
- this.vkConfig = vkConfig;
- }
-
- public VkApiClient getVkApiClient() {
- if (vkApiClient != null) {
- return vkApiClient;
- } else {
- initVkApiClient();
- return vkApiClient;
- }
- }
-
- public GroupActor getGroupActor() {
- if (groupActor != null) {
- return groupActor;
- } else {
- initGroupActor();
- return groupActor;
- }
- }
-
- public ServiceActor getServiceActor() {
- if (serviceActor != null) {
- return serviceActor;
- } else {
- initServiceActor();
- return serviceActor;
- }
- }
-
- private void initVkApiClient() {
- vkApiClient = new VkApiClient(HttpTransportClient.getInstance());
- }
-
- private void initGroupActor() {
- groupActor = new GroupActor(vkConfig.getGroupId(), vkConfig.getGroupToken());
- }
-
- private void initServiceActor() {
- serviceActor = new ServiceActor(vkConfig.getAppId(), vkConfig.getServiceToken());
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/EventDistributable.java b/src/main/java/org/sadtech/vkbot/core/distribution/EventDistributable.java
deleted file mode 100644
index b814451..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/EventDistributable.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.sadtech.vkbot.core.distribution;
-
-public interface EventDistributable {
-
- void distribute() throws Exception;
-
- void registerSubscriber(String key, EventSubscribe o);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/EventSubscribe.java b/src/main/java/org/sadtech/vkbot/core/distribution/EventSubscribe.java
deleted file mode 100644
index bd8dead..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/EventSubscribe.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.sadtech.vkbot.core.distribution;
-
-public interface EventSubscribe {
-
- void update(T object);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/impl/CommentSubscriber.java b/src/main/java/org/sadtech/vkbot/core/distribution/impl/CommentSubscriber.java
deleted file mode 100644
index c03fc7a..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/CommentSubscriber.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.sadtech.vkbot.core.distribution.impl;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.vk.api.sdk.objects.wall.WallComment;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.distribution.EventDistributable;
-import org.sadtech.vkbot.core.distribution.EventSubscribe;
-import org.sadtech.vkbot.core.service.distribution.CommentService;
-
-public class CommentSubscriber implements EventSubscribe {
-
- public static final Logger log = Logger.getLogger(CommentSubscriber.class);
-
- private CommentService commentService;
-
- public CommentSubscriber(EventDistributable distributable, CommentService commentService) {
- distributable.registerSubscriber("wall_reply_new", this);
- this.commentService = commentService;
- }
-
- @Override
- public void update(JsonObject object) {
- Gson gson = new Gson();
- WallComment wallComment = gson.fromJson(object, WallComment.class);
- log.info(wallComment);
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/impl/EventDistributorVK.java b/src/main/java/org/sadtech/vkbot/core/distribution/impl/EventDistributorVK.java
deleted file mode 100644
index d43b9b3..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/EventDistributorVK.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.sadtech.vkbot.core.distribution.impl;
-
-import com.google.gson.JsonObject;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.distribution.EventDistributable;
-import org.sadtech.vkbot.core.distribution.EventSubscribe;
-import org.sadtech.vkbot.core.service.RawEventService;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class EventDistributorVK implements EventDistributable, Runnable {
-
- public static final Logger log = Logger.getLogger(EventDistributorVK.class);
-
- private RawEventService rawEventService;
- private Map eventDistributionMap = new HashMap<>();
-
- public EventDistributorVK(RawEventService rawEventService) {
- this.rawEventService = rawEventService;
- }
-
- @Override
- public void distribute() {
- while (true) {
- if (rawEventService.getJsonObjects().peek() != null) {
- JsonObject event = rawEventService.getJsonObjects().poll();
- log.info("Главный дистрибьютор отправил событие дальше");
- if (eventDistributionMap.containsKey(event.get("type").getAsString())) {
- eventDistributionMap.get(event.get("type").getAsString()).update(event.getAsJsonObject("object"));
- }
- }
- }
- }
-
- @Override
- public void registerSubscriber(String key, EventSubscribe o) {
- eventDistributionMap.put(key, o);
- }
-
- @Override
- public void run() {
- distribute();
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailChatSubscriber.java b/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailChatSubscriber.java
deleted file mode 100644
index fe7a586..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailChatSubscriber.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.sadtech.vkbot.core.distribution.impl;
-
-import com.vk.api.sdk.objects.messages.Message;
-import org.sadtech.vkbot.core.distribution.EventDistributable;
-import org.sadtech.vkbot.core.distribution.EventSubscribe;
-import org.sadtech.vkbot.core.service.distribution.MailService;
-
-public class MailChatSubscriber implements EventSubscribe {
-
- private MailService mailService;
-
- public MailChatSubscriber(EventDistributable eventDistributable, MailService mailService) {
- this.mailService = mailService;
- eventDistributable.registerSubscriber("chat", this);
- }
-
- public MailChatSubscriber(EventDistributable eventDistributable) {
- eventDistributable.registerSubscriber("chat", this);
- }
-
- public void setMailService(MailService mailService) {
- this.mailService = mailService;
- }
-
- @Override
- public void update(Message message) {
- mailService.add(message);
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailSubscriber.java b/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailSubscriber.java
deleted file mode 100644
index 7ec7d66..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailSubscriber.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.sadtech.vkbot.core.distribution.impl;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.vk.api.sdk.objects.messages.Message;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.distribution.EventDistributable;
-import org.sadtech.vkbot.core.distribution.EventSubscribe;
-import org.sadtech.vkbot.core.service.distribution.MailService;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class MailSubscriber implements EventSubscribe, EventDistributable {
-
- public static final Logger log = Logger.getLogger(MailSubscriber.class);
-
- private MailService mailService;
- private Set admins = new HashSet<>();
- private Map> eventDistributionMap = new HashMap<>();
-
- public MailSubscriber(EventDistributable eventDistributable, MailService mailService) {
- this.mailService = mailService;
- eventDistributable.registerSubscriber("message_new", this);
- }
-
- public MailService getMailService() {
- return mailService;
- }
-
- public void setMailService(MailService mailService) {
- this.mailService = mailService;
- }
-
- public void setAdmins(Set admins) {
- this.admins = admins;
- }
-
- public Set getAdmins() {
- return admins;
- }
-
- @Override
- public void update(JsonObject object) {
- log.info("Дистрибьютор получил событие - сообщение");
- Gson gson = new Gson();
- Message userMessage = gson.fromJson(object, Message.class);
- if (userMessage.getPeerId() > 2000000000) {
- if (eventDistributionMap.containsKey("chat")) {
- eventDistributionMap.get("chat").update(userMessage);
- }
- } else {
- if (admins.contains(userMessage.getUserId()) && eventDistributionMap.containsKey("terminal")) {
- log.info("Сообщение отправлено в репозиторий команд");
- eventDistributionMap.get("terminal").update(userMessage);
- } else {
- log.info("Сообщение отправленно на добавление в репозиторий");
- mailService.add(userMessage);
- }
- }
- }
-
-
- @Override
- public void distribute() throws Exception {
-
- }
-
- @Override
- public void registerSubscriber(String key, EventSubscribe o) {
- eventDistributionMap.put(key, o);
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/impl/TerminalSubscriber.java b/src/main/java/org/sadtech/vkbot/core/distribution/impl/TerminalSubscriber.java
deleted file mode 100644
index 75b4f7d..0000000
--- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/TerminalSubscriber.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.sadtech.vkbot.core.distribution.impl;
-
-import com.vk.api.sdk.objects.messages.Message;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.distribution.EventSubscribe;
-import org.sadtech.vkbot.core.service.distribution.MailService;
-
-public class TerminalSubscriber implements EventSubscribe {
-
- public static final Logger log = Logger.getLogger(TerminalSubscriber.class);
-
- private MailService mailService;
-
- public TerminalSubscriber(MailSubscriber mailSubscriber, MailService mailService) {
- this.mailService = mailService;
- mailSubscriber.registerSubscriber("terminal", this);
- }
-
- public MailService getMailService() {
- return mailService;
- }
-
- public void setMailService(MailService mailService) {
- this.mailService = mailService;
- }
-
- @Override
- public void update(Message object) {
- log.info("Сообщение отправленно на добавление в репозиторий команд");
- mailService.add(object);
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/insert/VkInsertData.java b/src/main/java/org/sadtech/vkbot/core/insert/VkInsertData.java
deleted file mode 100644
index da628a5..0000000
--- a/src/main/java/org/sadtech/vkbot/core/insert/VkInsertData.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.sadtech.vkbot.core.insert;
-
-import org.sadtech.vkbot.core.VkApi;
-import org.sadtech.vkbot.core.VkConnect;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class VkInsertData {
-
- private VkApi vkApi;
-
- public VkInsertData(VkConnect vkConnect) {
- this.vkApi = new VkApi(vkConnect);
- }
-
- public String insertWords(String message, Integer idUser) {
- Pattern pattern = Pattern.compile("%(\\w+)%");
- Matcher m = pattern.matcher(message);
- StringBuffer result = new StringBuffer();
- while (m.find()) {
- m.appendReplacement(result, insert(m.group(0), idUser));
- }
- m.appendTail(result);
- return result.toString();
- }
-
- private String insert(String key, Integer userId) {
- String string = "";
- switch (key) {
- case "%firstname%":
- string = vkApi.getUserMini(userId).getFirstName();
- break;
- case "%lastname%":
- string = vkApi.getUserMini(userId).getLastName();
- break;
- }
- return string;
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java b/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java
deleted file mode 100644
index fa9612f..0000000
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.sadtech.vkbot.core.keyboard;
-
-import com.google.gson.JsonObject;
-
-public class ButtonKeyBoard {
-
- private String type = "text";
- private String payload;
- private String label;
- private ColorButton color = ColorButton.PRIMARY;
-
- public ButtonKeyBoard() {
-
- }
-
- public ButtonKeyBoard(String type, String payload, String label, ColorButton color) {
- this.type = type;
- this.payload = payload;
- this.label = label;
- this.color = color;
- }
-
- public JsonObject getButton() {
- JsonObject newButton = new JsonObject();
- newButton.addProperty("color", color.toString().toLowerCase());
- newButton.add("action", generateAction());
- return newButton;
- }
-
- private JsonObject generateAction() {
- JsonObject action = new JsonObject();
- action.addProperty("type", type);
- action.addProperty("payload", payload);
- action.addProperty("label", label);
- return action;
- }
-
- public static Builder builder() {
- return new ButtonKeyBoard().new Builder();
- }
-
- public class Builder {
-
- private Builder() {
-
- }
-
- public Builder setColor(ColorButton color) {
- ButtonKeyBoard.this.color = color;
- return this;
- }
-
- public Builder setLabel(String label) {
- ButtonKeyBoard.this.label = label;
- return this;
- }
-
- public Builder setPayload(String payload) {
- ButtonKeyBoard.this.payload = payload;
- return this;
- }
-
- public Builder setType(String type) {
- ButtonKeyBoard.this.type = type;
- return this;
- }
-
- public ButtonKeyBoard build() {
- return ButtonKeyBoard.this;
- }
-
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/ColorButton.java b/src/main/java/org/sadtech/vkbot/core/keyboard/ColorButton.java
deleted file mode 100644
index 6eb856b..0000000
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/ColorButton.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.sadtech.vkbot.core.keyboard;
-
-public enum ColorButton {
-
- PRIMARY, DEFAULT, NEGATIVE, POSITIVE
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoard.java b/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoard.java
deleted file mode 100644
index 08cdf86..0000000
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoard.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.sadtech.vkbot.core.keyboard;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class KeyBoard {
-
- private List lineKeyBoards = new ArrayList<>();
- private boolean oneTime;
-
- public KeyBoard() {
-
- }
-
- public KeyBoard(List lineKeyBoards, boolean oneTime) {
- this.lineKeyBoards = lineKeyBoards;
- this.oneTime = oneTime;
- }
-
- public void setOneTime(boolean oneTime) {
- this.oneTime = oneTime;
- }
-
- public JsonObject getKeyboard() {
- JsonObject keyboard = new JsonObject();
- keyboard.addProperty("one_time", oneTime);
-
- JsonArray menuLine = new JsonArray();
- for (LineKeyBoard lineKeyboard : lineKeyBoards) {
- menuLine.add(lineKeyboard.getLine());
- }
-
- keyboard.add("buttons", menuLine);
- return keyboard;
- }
-
- public void addLine(LineKeyBoard lineKeyBoard) {
- lineKeyBoards.add(lineKeyBoard);
- }
-
- public static Builder builder() {
- return new KeyBoard().new Builder();
- }
-
- public class Builder {
-
- private Builder() {
-
- }
-
- public Builder setLineKeyBoard(LineKeyBoard lineKeyBoard) {
- KeyBoard.this.lineKeyBoards.add(lineKeyBoard);
- return this;
- }
-
- public Builder setOneTime(boolean oneTime) {
- KeyBoard.this.oneTime = oneTime;
- return this;
- }
-
- public KeyBoard build() {
- return KeyBoard.this;
- }
-
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoardService.java b/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoardService.java
deleted file mode 100644
index ade5e6e..0000000
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/KeyBoardService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.sadtech.vkbot.core.keyboard;
-
-import java.util.List;
-
-public class KeyBoardService {
-
- public static KeyBoard keyBoardYesNo() {
- ButtonKeyBoard yesButton = ButtonKeyBoard.builder().setColor(ColorButton.POSITIVE).setLabel("Да").setPayload("{\"button\": \"yes\"}").build();
- ButtonKeyBoard noButton = ButtonKeyBoard.builder().setColor(ColorButton.NEGATIVE).setLabel("Нет").setPayload("{\"button\": \"no\"}").build();
- LineKeyBoard lineKeyBoard = LineKeyBoard.builder().setButtonKeyBoard(yesButton).setButtonKeyBoard(noButton).build();
- KeyBoard keyBoard = KeyBoard.builder().setLineKeyBoard(lineKeyBoard).build();
- keyBoard.setOneTime(true);
- return keyBoard;
- }
-
- public static KeyBoard verticalMenuString(List labelButtons) {
- KeyBoard keyBoard = new KeyBoard();
- for (String labelButton : labelButtons) {
- ButtonKeyBoard buttonKeyBoard = ButtonKeyBoard.builder().setLabel(labelButton).setType("text").setPayload("{\"button\": \"" + labelButton + "\"}").build();
- keyBoard.addLine(LineKeyBoard.builder().setButtonKeyBoard(buttonKeyBoard).build());
- }
- keyBoard.setOneTime(true);
- return keyBoard;
- }
-
- public static KeyBoard verticalMenuButton(List buttonKeyBoards) {
- KeyBoard keyBoard = new KeyBoard();
- for (ButtonKeyBoard buttonKeyBoard : buttonKeyBoards) {
- keyBoard.addLine(LineKeyBoard.builder().setButtonKeyBoard(buttonKeyBoard).build());
- }
- keyBoard.setOneTime(true);
- return keyBoard;
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/LineKeyBoard.java b/src/main/java/org/sadtech/vkbot/core/keyboard/LineKeyBoard.java
deleted file mode 100644
index 6b28849..0000000
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/LineKeyBoard.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.sadtech.vkbot.core.keyboard;
-
-import com.google.gson.JsonArray;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class LineKeyBoard {
-
- private List buttonKeyBoards = new ArrayList<>();
-
- public LineKeyBoard() {
-
- }
-
- public LineKeyBoard(List buttonKeyBoards) {
- this.buttonKeyBoards = buttonKeyBoards;
- }
-
- public JsonArray getLine() {
- JsonArray line = new JsonArray();
- for (ButtonKeyBoard buttonKeyBoard : buttonKeyBoards) {
- line.add(buttonKeyBoard.getButton());
- }
- return line;
- }
-
- public static Builder builder() {
- return new LineKeyBoard().new Builder();
- }
-
- public class Builder {
-
- private Builder() {
-
- }
-
- public Builder setButtonKeyBoard(ButtonKeyBoard buttonKeyBoard) {
- LineKeyBoard.this.buttonKeyBoards.add(buttonKeyBoard);
- return this;
- }
-
- public LineKeyBoard build() {
- return LineKeyBoard.this;
- }
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/listener/EventListener.java b/src/main/java/org/sadtech/vkbot/core/listener/EventListener.java
deleted file mode 100644
index 3109603..0000000
--- a/src/main/java/org/sadtech/vkbot/core/listener/EventListener.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.sadtech.vkbot.core.listener;
-
-public interface EventListener extends Runnable {
-
- void listen() throws Exception;
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/listener/EventListenerVk.java b/src/main/java/org/sadtech/vkbot/core/listener/EventListenerVk.java
deleted file mode 100644
index 8502663..0000000
--- a/src/main/java/org/sadtech/vkbot/core/listener/EventListenerVk.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.sadtech.vkbot.core.listener;
-
-import com.google.gson.JsonObject;
-import com.vk.api.sdk.callback.longpoll.responses.GetLongPollEventsResponse;
-import com.vk.api.sdk.client.VkApiClient;
-import com.vk.api.sdk.client.actors.GroupActor;
-import com.vk.api.sdk.exceptions.ApiException;
-import com.vk.api.sdk.exceptions.ClientException;
-import com.vk.api.sdk.exceptions.LongPollServerKeyExpiredException;
-import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.VkConnect;
-import org.sadtech.vkbot.core.repository.impl.EventRepositoryQueue;
-import org.sadtech.vkbot.core.service.RawEventService;
-import org.sadtech.vkbot.core.service.impl.RawEventServiceImpl;
-
-public class EventListenerVk implements EventListener, Runnable {
-
- public static final Logger log = Logger.getLogger(EventListenerVk.class);
-
- private VkApiClient vk;
- private GroupActor actor;
-
- private static Integer DEFAULT_WAIT_TIME = 10;
-
- private RawEventService rawEventService;
-
- public EventListenerVk(VkConnect vkConnect) {
- vk = vkConnect.getVkApiClient();
- actor = vkConnect.getGroupActor();
- rawEventService = new RawEventServiceImpl(new EventRepositoryQueue());
- }
-
- public EventListenerVk(VkConnect vkConnect, RawEventService rawEventService) {
- this.vk = vkConnect.getVkApiClient();
- this.actor = vkConnect.getGroupActor();
- this.rawEventService = rawEventService;
- }
-
- public RawEventService getRawEventService() {
- return rawEventService;
- }
-
- public void listen() throws ClientException, ApiException {
- GetLongPollServerResponse longPollServer = getLongPollServer();
- int lastTimeStamp = longPollServer.getTs();
- while (true) {
- try {
- GetLongPollEventsResponse eventsResponse = vk.longPoll().getEvents(longPollServer.getServer(), longPollServer.getKey(), lastTimeStamp).waitTime(DEFAULT_WAIT_TIME).execute();
- for (JsonObject jsonObject: eventsResponse.getUpdates()) {
- log.info("Новое событие от LongPoll\n" + jsonObject);
- rawEventService.add(jsonObject);
- }
- lastTimeStamp = eventsResponse.getTs();
- } catch (LongPollServerKeyExpiredException e) {
- longPollServer = getLongPollServer();
- lastTimeStamp = longPollServer.getTs();
- }
- }
-
- }
-
- private GetLongPollServerResponse getLongPollServer() throws ClientException, ApiException {
- log.info("LongPoll сервер инициализирован");
- if (actor != null) {
- return vk.groups().getLongPollServer(actor).execute();
- }
- return null;
- }
-
- @Override
- public void run() {
- try {
- listen();
- } catch (ClientException | ApiException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/repository/CommentRepository.java b/src/main/java/org/sadtech/vkbot/core/repository/CommentRepository.java
deleted file mode 100644
index bd9bbf0..0000000
--- a/src/main/java/org/sadtech/vkbot/core/repository/CommentRepository.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.sadtech.vkbot.core.repository;
-
-import org.sadtech.vkbot.core.entity.Comment;
-
-public interface CommentRepository {
-
- void add(Comment comment);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java
deleted file mode 100644
index b84c07b..0000000
--- a/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.sadtech.vkbot.core.sender;
-
-import com.vk.api.sdk.client.VkApiClient;
-import com.vk.api.sdk.client.actors.GroupActor;
-import com.vk.api.sdk.exceptions.ApiException;
-import com.vk.api.sdk.exceptions.ClientException;
-import com.vk.api.sdk.queries.messages.MessagesSendQuery;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.VkConnect;
-import org.sadtech.vkbot.core.entity.BoxAnswer;
-import org.sadtech.vkbot.core.insert.VkInsertData;
-
-public class MailSenderVk implements Sent {
-
- public static final Logger log = Logger.getLogger(MailSenderVk.class);
-
- private VkApiClient vkApiClient;
- private GroupActor groupActor;
-
- private VkInsertData vkInsertData;
-
- public MailSenderVk(VkConnect vkConnect) {
- this.vkApiClient = vkConnect.getVkApiClient();
- this.groupActor = vkConnect.getGroupActor();
- this.vkInsertData = new VkInsertData(vkConnect);
- }
-
- @Override
- public void send(Integer idPerson, String message) {
- sendMessage(vkApiClient.messages().send(groupActor).peerId(idPerson).message(message));
- }
-
- @Override
- public void send(Integer idPerson, BoxAnswer boxAnswer) {
- MessagesSendQuery messagesSendQuery = createMessage(boxAnswer, idPerson);
- sendMessage(messagesSendQuery);
- }
-
- private MessagesSendQuery createMessage(BoxAnswer boxAnswer, Integer peerId) {
- MessagesSendQuery messages = vkApiClient.messages().send(groupActor).peerId(peerId).message(vkInsertData.insertWords(boxAnswer.getMessage(), peerId));
- if (boxAnswer.getKeyboard() != null) {
- messages.keyboard(boxAnswer.getKeyboard());
- } else {
- messages.keyboard("{\"buttons\":[],\"one_time\":true}");
- }
- if (boxAnswer.getLat() != null && boxAnswer.getaLong() != null) {
- messages.lat(boxAnswer.getLat()).lng(boxAnswer.getaLong());
- }
- if (boxAnswer.getStickerId() != null) {
- try {
- vkApiClient.messages().send(groupActor).peerId(peerId).stickerId(boxAnswer.getStickerId()).execute();
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
- }
- }
- return messages;
- }
-
- private void sendMessage(MessagesSendQuery messages) {
- try {
- messages.execute();
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/PersonService.java b/src/main/java/org/sadtech/vkbot/core/service/PersonService.java
deleted file mode 100644
index af2fe2b..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/PersonService.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.sadtech.vkbot.core.service;
-
-import com.vk.api.sdk.objects.users.User;
-import com.vk.api.sdk.objects.users.UserMin;
-import org.sadtech.vkbot.core.entity.Person;
-
-public interface PersonService {
-
- void add(User person);
-
- void add(Person person);
-
- void add(UserMin userMin);
-
- Person get(Integer id);
-
- boolean checkPerson(Integer idPerson);
-
- Person createPerson(Integer userId);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/CommentService.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/CommentService.java
deleted file mode 100644
index e62efd5..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/distribution/CommentService.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.sadtech.vkbot.core.service.distribution;
-
-import org.sadtech.vkbot.core.entity.Comment;
-import org.sadtech.vkbot.core.service.distribution.impl.EventService;
-
-//@TODO: Дописать класс
-public interface CommentService extends EventService {
-
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java
deleted file mode 100644
index 1a830d6..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.sadtech.vkbot.core.service.distribution;
-
-import com.vk.api.sdk.objects.messages.Message;
-import org.sadtech.vkbot.core.entity.Mail;
-import org.sadtech.vkbot.core.service.distribution.impl.EventService;
-
-public interface MailService extends EventService {
-
- void add(Message message);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/CommentServiceImpl.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/CommentServiceImpl.java
deleted file mode 100644
index 074325b..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/CommentServiceImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.sadtech.vkbot.core.service.distribution.impl;
-
-import org.sadtech.vkbot.core.entity.Comment;
-import org.sadtech.vkbot.core.repository.CommentRepository;
-import org.sadtech.vkbot.core.service.distribution.CommentService;
-
-import java.util.List;
-
-public class CommentServiceImpl implements CommentService {
-
- private CommentRepository commentRepository;
-
- public CommentServiceImpl(CommentRepository commentRepository) {
- this.commentRepository = commentRepository;
- }
-
- @Override
- public void add(Comment comment) {
- commentRepository.add(comment);
- }
-
- @Override
- public List getEvent(Integer timeFrom, Integer timeTo) {
- return null;
- }
-
- @Override
- public List getFirstMailByTime(Integer timeFrom, Integer timeTo) {
- return null;
- }
-
- @Override
- public List getLastMailByTime(Integer timeFrom, Integer timeTo) {
- return null;
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/EventService.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/EventService.java
deleted file mode 100644
index e48ae28..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/EventService.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.sadtech.vkbot.core.service.distribution.impl;
-
-import java.util.List;
-
-public interface EventService {
-
- void add(T event);
-
- List getEvent(Integer timeFrom, Integer timeTo);
-
- List getFirstMailByTime(Integer timeFrom, Integer timeTo);
-
- List getLastMailByTime(Integer timeFrom, Integer timeTo);
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java
deleted file mode 100644
index 7a6560f..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.sadtech.vkbot.core.service.distribution.impl;
-
-import com.vk.api.sdk.objects.messages.Message;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.entity.Mail;
-import org.sadtech.vkbot.core.entity.Person;
-import org.sadtech.vkbot.core.repository.MailRepository;
-import org.sadtech.vkbot.core.repository.impl.MailRepositoryList;
-import org.sadtech.vkbot.core.service.PersonService;
-import org.sadtech.vkbot.core.service.distribution.MailService;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class MailServiceImpl implements MailService {
-
- public static final Logger log = Logger.getLogger(MailServiceImpl.class);
-
- private MailRepository mailRepository;
- private PersonService personService;
-
- public MailServiceImpl(PersonService personService) {
- this.mailRepository = new MailRepositoryList();
- this.personService = personService;
- }
-
- public MailServiceImpl(MailRepository mailRepository, PersonService personService) {
- this.mailRepository = mailRepository;
- this.personService = personService;
- }
-
- @Override
- public void add(Mail mail) {
- mailRepository.add(mail);
- log.info("Сообщение добавлено в репозиторий");
- }
-
- @Override
- public void add(Message message) {
- Mail mail = new Mail();
- mail.setDate(message.getDate());
- if (!message.getFromId().equals(message.getPeerId())) {
- mail.setBody(message.getBody().replaceFirst("\\[club([0-9]+)\\|\\@\\w+][ ,.]", ""));
- } else {
- mail.setBody(message.getBody());
- }
- mail.setId(message.getId());
- mail.setPeerId(message.getPeerId());
- if (!personService.checkPerson(message.getFromId())) {
- personService.add(personService.createPerson(message.getFromId()));
- }
- mail.setPerson(personService.get(message.getFromId()));
- log.info("Сообщение добавлено в репозиторий");
- mailRepository.add(mail);
- }
-
- private void clean() {
-
- }
-
- @Override
- public List getFirstMailByTime(Integer timeFrom, Integer timeTo) {
- List mails = mailRepository.getMailByTime(timeFrom, timeTo);
- Set people = new HashSet<>();
- List returnMails = new ArrayList<>();
- for (int i = mails.size() - 1; i >= 0; i--) {
- if (!people.contains(mails.get(i).getPerson())) {
- returnMails.add(mails.get(i));
- people.add(mails.get(i).getPerson());
- }
- }
- return returnMails;
- }
-
- @Override
- public List getLastMailByTime(Integer timeFrom, Integer timeTo) {
- List mails = mailRepository.getMailByTime(timeFrom, timeTo);
- Set people = new HashSet<>();
- List returnMails = new ArrayList<>();
- for (Mail mail : mails) {
- if (!people.contains(mail.getPerson())) {
- returnMails.add(mail);
- people.add(mail.getPerson());
- }
- }
- return returnMails;
- }
-
- @Override
- public List getEvent(Integer timeFrom, Integer timeTo) {
- log.info("Запрос на получение сообщений в интервале от " + timeFrom + " до " + timeTo);
- return mailRepository.getMailByTime(timeFrom, timeTo);
- }
-
-}
diff --git a/src/main/java/org/sadtech/vkbot/core/service/impl/PersonServiceImpl.java b/src/main/java/org/sadtech/vkbot/core/service/impl/PersonServiceImpl.java
deleted file mode 100644
index e4240c1..0000000
--- a/src/main/java/org/sadtech/vkbot/core/service/impl/PersonServiceImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.sadtech.vkbot.core.service.impl;
-
-import com.vk.api.sdk.objects.users.User;
-import com.vk.api.sdk.objects.users.UserMin;
-import org.apache.log4j.Logger;
-import org.sadtech.vkbot.core.VkApi;
-import org.sadtech.vkbot.core.VkConnect;
-import org.sadtech.vkbot.core.entity.Person;
-import org.sadtech.vkbot.core.repository.PersonRepository;
-import org.sadtech.vkbot.core.repository.impl.PersonRepositoryMap;
-import org.sadtech.vkbot.core.service.PersonService;
-
-public class PersonServiceImpl implements PersonService {
-
- public static final Logger log = Logger.getLogger(PersonServiceImpl.class);
-
- private PersonRepository personRepository;
- private VkApi vkApi;
-
- public PersonServiceImpl(VkConnect vkConnect) {
- this.personRepository = new PersonRepositoryMap();
- vkApi = new VkApi(vkConnect);
- }
-
- public PersonServiceImpl(PersonRepository personRepository, VkConnect vkConnect) {
- this.personRepository = personRepository;
- vkApi = new VkApi(vkConnect);
- }
-
- @Override
- public void add(User user) {
- Person person = new Person();
- person.setId(user.getId());
- person.setLastName(user.getLastName());
- person.setFirstName(user.getFirstName());
- personRepository.add(person);
- log.info("Пользователь добавлен в репозиторий");
- }
-
- @Override
- public void add(Person person) {
- personRepository.add(person);
- log.info("Пользователь добавлен в репозиторий");
- }
-
- @Override
- public void add(UserMin userMin) {
- Person person = new Person();
- person.setId(userMin.getId());
- person.setFirstName(userMin.getFirstName());
- person.setLastName(userMin.getLastName());
- personRepository.add(person);
- }
-
- @Override
- public Person get(Integer id) {
- return personRepository.get(id);
- }
-
- @Override
- public boolean checkPerson(Integer idPerson) {
- log.info("Проверка наличия пользователя в репозитории");
- return get(idPerson) != null;
- }
-
- @Override
- public Person createPerson(Integer userId) {
- Person person = new Person();
- UserMin userMin = vkApi.getUserMini(userId);
- person.setId(userMin.getId());
- person.setLastName(userMin.getLastName());
- person.setFirstName(userMin.getFirstName());
- return person;
- }
-
-}