Рефакторинг
This commit is contained in:
parent
a94238ee23
commit
e2ed76abbe
10
pom.xml
10
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.sadtech.vkbot</groupId>
|
||||
<artifactId>vkbot-core</artifactId>
|
||||
<version>0.2.1-RELEASE</version>
|
||||
<version>0.2.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
@ -23,7 +23,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<bot.core.ver>0.6.2-RELEASE</bot.core.ver>
|
||||
<social.core.ver>0.6.3-SNAPSHOT</social.core.ver>
|
||||
|
||||
<vksdk.ver>0.5.13-FORK</vksdk.ver>
|
||||
<log4j.ver>1.2.17</log4j.ver>
|
||||
@ -43,9 +43,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>${bot.core.ver}</version>
|
||||
<groupId>org.sadtech.social</groupId>
|
||||
<artifactId>social-core</artifactId>
|
||||
<version>${social.core.ver}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -1,12 +1,16 @@
|
||||
package org.sadtech.vkbot.core.convert;
|
||||
|
||||
import com.vk.api.sdk.objects.messages.*;
|
||||
import org.sadtech.bot.core.domain.keyboard.ButtonColor;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardLine;
|
||||
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonAccount;
|
||||
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonText;
|
||||
import com.vk.api.sdk.objects.messages.Keyboard;
|
||||
import com.vk.api.sdk.objects.messages.KeyboardButton;
|
||||
import com.vk.api.sdk.objects.messages.KeyboardButtonAction;
|
||||
import com.vk.api.sdk.objects.messages.KeyboardButtonActionType;
|
||||
import com.vk.api.sdk.objects.messages.KeyboardButtonColor;
|
||||
import org.sadtech.social.core.domain.keyboard.ButtonColor;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoard;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
||||
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonAccount;
|
||||
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
||||
import org.sadtech.vkbot.core.config.VkConnect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -73,7 +77,7 @@ public class KeyBoardConvert {
|
||||
|
||||
private String createHash(KeyBoardButtonAccount button) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (button.getAmount()!=null) {
|
||||
if (button.getAmount() != null) {
|
||||
stringBuilder
|
||||
.append("action=pay-to-group&amount=")
|
||||
.append(button.getAmount()).append("&group_id=")
|
||||
@ -84,7 +88,7 @@ public class KeyBoardConvert {
|
||||
.append(button.getAmount()).append("&group_id=")
|
||||
.append(vkConnect.getGroupActor().getGroupId());
|
||||
}
|
||||
if (button.getAccountId()!=null) {
|
||||
if (button.getAccountId() != null) {
|
||||
stringBuilder.append("&description=").append(button.getAccountId());
|
||||
}
|
||||
return stringBuilder.append("&aid=").append(vkConnect.getServiceActor().getId()).toString();
|
||||
|
@ -2,10 +2,10 @@ package org.sadtech.vkbot.core.convert;
|
||||
|
||||
import com.vk.api.sdk.objects.messages.Message;
|
||||
import com.vk.api.sdk.objects.messages.MessageAttachment;
|
||||
import org.sadtech.bot.core.domain.content.Mail;
|
||||
import org.sadtech.bot.core.domain.content.attachment.Attachment;
|
||||
import org.sadtech.bot.core.domain.content.attachment.AudioMessage;
|
||||
import org.sadtech.bot.core.domain.content.attachment.Geo;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.sadtech.social.core.domain.content.attachment.Attachment;
|
||||
import org.sadtech.social.core.domain.content.attachment.AudioMessage;
|
||||
import org.sadtech.social.core.domain.content.attachment.Geo;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
@ -17,7 +17,7 @@ public class MessageMailConvert implements Convert<Message, Mail> {
|
||||
@Override
|
||||
public Mail converting(Message message) {
|
||||
Mail mail = new Mail();
|
||||
mail.setMessage(message.getText());
|
||||
mail.setText(message.getText());
|
||||
mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), TimeZone.getDefault().toZoneId()));
|
||||
mail.setId(message.getId());
|
||||
mail.setPersonId(message.getPeerId());
|
||||
@ -25,7 +25,7 @@ public class MessageMailConvert implements Convert<Message, Mail> {
|
||||
.stream()
|
||||
.map(this::convertAttachment)
|
||||
.collect(Collectors.toList()));
|
||||
if (message.getGeo()!=null) {
|
||||
if (message.getGeo() != null) {
|
||||
mail.getAttachments().add(convertGeo(message.getGeo()));
|
||||
}
|
||||
return mail;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.sadtech.vkbot.core.convert;
|
||||
|
||||
import com.vk.api.sdk.objects.board.TopicComment;
|
||||
import org.sadtech.bot.core.domain.content.BoardComment;
|
||||
import org.sadtech.social.core.domain.content.BoardComment;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,7 +13,7 @@ public class TopicCommentToBoardComment implements Convert<TopicComment, BoardCo
|
||||
BoardComment boardComment = new BoardComment();
|
||||
boardComment.setContentId(target.getTopicId());
|
||||
boardComment.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(target.getDate()), TimeZone.getDefault().toZoneId()));
|
||||
boardComment.setMessage(target.getText());
|
||||
boardComment.setText(target.getText());
|
||||
boardComment.setPersonId(target.getFromId());
|
||||
|
||||
|
||||
|
@ -2,10 +2,10 @@ package org.sadtech.vkbot.core.distribution;
|
||||
|
||||
import com.vk.api.sdk.objects.messages.Message;
|
||||
import com.vk.api.sdk.objects.messages.MessageAttachmentType;
|
||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
||||
import org.sadtech.bot.core.exception.PaymentException;
|
||||
import org.sadtech.bot.core.service.AccountService;
|
||||
import org.sadtech.bot.core.service.sender.Sent;
|
||||
import org.sadtech.social.core.domain.BoxAnswer;
|
||||
import org.sadtech.social.core.exception.PaymentException;
|
||||
import org.sadtech.social.core.service.AccountService;
|
||||
import org.sadtech.social.core.service.sender.Sent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -3,8 +3,8 @@ package org.sadtech.vkbot.core.distribution;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.vk.api.sdk.objects.board.TopicComment;
|
||||
import org.sadtech.bot.core.domain.content.BoardComment;
|
||||
import org.sadtech.bot.core.service.BoardCommentService;
|
||||
import org.sadtech.social.core.domain.content.BoardComment;
|
||||
import org.sadtech.social.core.service.BoardCommentService;
|
||||
import org.sadtech.vkbot.core.convert.Convert;
|
||||
import org.sadtech.vkbot.core.convert.TopicCommentToBoardComment;
|
||||
|
||||
|
@ -2,8 +2,9 @@ package org.sadtech.vkbot.core.distribution;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.sadtech.bot.core.service.RawEventService;
|
||||
import org.sadtech.social.core.service.RawEventService;
|
||||
|
||||
// todo [upagge] [12/07/2019]: Рефакторинг - отказаться от наследования
|
||||
public class EventDistributor extends AbstractBasketSubscribe<JsonObject, JsonObject> implements Runnable {
|
||||
|
||||
private static final Logger log = Logger.getLogger(EventDistributor.class);
|
||||
|
@ -3,8 +3,8 @@ package org.sadtech.vkbot.core.distribution;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.vk.api.sdk.objects.messages.Message;
|
||||
import org.sadtech.bot.core.domain.content.Mail;
|
||||
import org.sadtech.bot.core.service.MailService;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.sadtech.social.core.service.MailService;
|
||||
import org.sadtech.vkbot.core.convert.Convert;
|
||||
import org.sadtech.vkbot.core.convert.MessageMailConvert;
|
||||
|
||||
|
@ -8,9 +8,9 @@ import com.vk.api.sdk.exceptions.LongPollServerKeyExpiredException;
|
||||
import com.vk.api.sdk.objects.callback.longpoll.responses.GetLongPollEventsResponse;
|
||||
import com.vk.api.sdk.objects.groups.LongPollServer;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.sadtech.bot.core.repository.impl.EventRepositoryQueue;
|
||||
import org.sadtech.bot.core.service.RawEventService;
|
||||
import org.sadtech.bot.core.service.impl.RawEventServiceImpl;
|
||||
import org.sadtech.social.core.repository.impl.EventRepositoryQueue;
|
||||
import org.sadtech.social.core.service.RawEventService;
|
||||
import org.sadtech.social.core.service.impl.RawEventServiceImpl;
|
||||
import org.sadtech.vkbot.core.config.VkConnect;
|
||||
|
||||
public class EventListenerVk implements Runnable {
|
||||
|
@ -5,12 +5,12 @@ import com.vk.api.sdk.client.actors.GroupActor;
|
||||
import com.vk.api.sdk.client.actors.UserActor;
|
||||
import com.vk.api.sdk.exceptions.ApiException;
|
||||
import com.vk.api.sdk.exceptions.ClientException;
|
||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardLine;
|
||||
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonText;
|
||||
import org.sadtech.bot.core.exception.MailSendException;
|
||||
import org.sadtech.bot.core.service.sender.Sent;
|
||||
import org.sadtech.social.core.domain.BoxAnswer;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
||||
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
||||
import org.sadtech.social.core.exception.MailSendException;
|
||||
import org.sadtech.social.core.service.sender.Sent;
|
||||
import org.sadtech.vkbot.core.config.VkConnect;
|
||||
import org.sadtech.vkbot.core.utils.VkInsertData;
|
||||
|
||||
@ -43,7 +43,7 @@ public class BoardCommentSenderVk implements Sent {
|
||||
for (KeyBoardButton keyBoardButton : keyBoardLine.getKeyBoardButtons()) {
|
||||
switch (keyBoardButton.getType()) {
|
||||
case TEXT:
|
||||
insertAnswer.append("- ").append(((KeyBoardButtonText)keyBoardButton).getLabel()).append("\n");
|
||||
insertAnswer.append("- ").append(((KeyBoardButtonText) keyBoardButton).getLabel()).append("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ import com.vk.api.sdk.exceptions.ClientException;
|
||||
import com.vk.api.sdk.objects.messages.Keyboard;
|
||||
import com.vk.api.sdk.queries.messages.MessagesSendQuery;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
||||
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
|
||||
import org.sadtech.bot.core.service.sender.Sent;
|
||||
import org.sadtech.social.core.domain.BoxAnswer;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoard;
|
||||
import org.sadtech.social.core.service.sender.Sent;
|
||||
import org.sadtech.vkbot.core.config.VkConnect;
|
||||
import org.sadtech.vkbot.core.convert.KeyBoardConvert;
|
||||
import org.sadtech.vkbot.core.utils.VkInsertData;
|
||||
|
Reference in New Issue
Block a user