From 3b29921d2e48c3d08014d4ea3b29183d22cc17fc Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Wed, 6 Feb 2019 17:24:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D1=80=D1=85=D0=B8=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D1=83=D1=80=D0=BD=D1=8B=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BE?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D1=82=D1=87=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../distribution/impl/CommentSubscriber.java | 13 ++++++++++ .../distribution/impl/EventDistributorVK.java | 4 ++- .../distribution/impl/MailChatSubscriber.java | 2 +- .../distribution/impl/MailSubscriber.java | 2 +- .../sadtech/vkbot/core/entity/Comment.java | 4 +++ .../{MailSanderVk.java => MailSenderVk.java} | 26 +++---------------- .../{MailSandler.java => MailSent.java} | 6 +---- 7 files changed, 26 insertions(+), 31 deletions(-) create mode 100644 src/main/java/org/sadtech/vkbot/core/distribution/impl/CommentSubscriber.java create mode 100644 src/main/java/org/sadtech/vkbot/core/entity/Comment.java rename src/main/java/org/sadtech/vkbot/core/sender/{MailSanderVk.java => MailSenderVk.java} (75%) rename src/main/java/org/sadtech/vkbot/core/sender/{MailSandler.java => MailSent.java} (63%) 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 new file mode 100644 index 0000000..7800ef8 --- /dev/null +++ b/src/main/java/org/sadtech/vkbot/core/distribution/impl/CommentSubscriber.java @@ -0,0 +1,13 @@ +package org.sadtech.vkbot.core.distribution.impl; + +import org.sadtech.vkbot.core.distribution.EventSubscribe; +import org.sadtech.vkbot.core.entity.Comment; + +public class CommentSubscriber implements EventSubscribe { + + + @Override + public void update(Comment object) { + + } +} 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 index d8b5d76..9b16545 100644 --- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/EventDistributorVK.java +++ b/src/main/java/org/sadtech/vkbot/core/distribution/impl/EventDistributorVK.java @@ -26,7 +26,9 @@ public class EventDistributorVK implements EventDistributable, Runnable { if (eventService.getJsonObjects().peek() != null) { JsonObject event = eventService.getJsonObjects().poll(); log.info("Главный дистрибьютор отправил событие дальше"); - eventDistributionMap.get(event.get("type").getAsString()).update(event.getAsJsonObject("object")); + if (eventDistributionMap.containsKey(event.get("type").getAsString())) { + eventDistributionMap.get(event.get("type").getAsString()).update(event.getAsJsonObject("object")); + } } } } 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 index 33c56fa..00c6fcc 100644 --- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailChatSubscriber.java +++ b/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailChatSubscriber.java @@ -9,7 +9,7 @@ public class MailChatSubscriber implements EventSubscribe { private MailService mailService; - public MailChatSubscriber(MailService mailService, EventDistributable eventDistributable) { + public MailChatSubscriber(EventDistributable eventDistributable, MailService mailService) { this.mailService = mailService; eventDistributable.registerSubscriber("chat", this); } 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 index 55cd800..f55e9e4 100644 --- a/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailSubscriber.java +++ b/src/main/java/org/sadtech/vkbot/core/distribution/impl/MailSubscriber.java @@ -52,7 +52,7 @@ public class MailSubscriber implements EventSubscribe, EventDistribu eventDistributionMap.get("chat").update(userMessage); } } else { - if (admins.contains(userMessage.getUserId())) { + if (admins.contains(userMessage.getUserId()) && eventDistributionMap.containsKey("terminal")) { log.info("Сообщение отправлено в репозиторий команд"); eventDistributionMap.get("terminal").update(userMessage); } else { diff --git a/src/main/java/org/sadtech/vkbot/core/entity/Comment.java b/src/main/java/org/sadtech/vkbot/core/entity/Comment.java new file mode 100644 index 0000000..ebb76d9 --- /dev/null +++ b/src/main/java/org/sadtech/vkbot/core/entity/Comment.java @@ -0,0 +1,4 @@ +package org.sadtech.vkbot.core.entity; + +public class Comment { +} diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java similarity index 75% rename from src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java rename to src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java index aa72851..08873e6 100644 --- a/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java +++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java @@ -13,16 +13,16 @@ import org.sadtech.vkbot.core.insert.InsertWords; import java.util.List; -public class MailSanderVk implements MailSandler { +public class MailSenderVk implements MailSent { - public static final Logger log = Logger.getLogger(MailSanderVk.class); + public static final Logger log = Logger.getLogger(MailSenderVk.class); private VkApiClient vkApiClient; private GroupActor groupActor; private VkInsertData vkInsertData; - public MailSanderVk(VkConnect vkConnect) { + public MailSenderVk(VkConnect vkConnect) { this.vkApiClient = vkConnect.getVkApiClient(); this.groupActor = vkConnect.getGroupActor(); this.vkInsertData = new VkInsertData(vkConnect); @@ -48,15 +48,6 @@ public class MailSanderVk implements MailSandler { return messages; } - @Override - public void send(MailSend mailSend, Integer peerId) { - MessagesSendQuery messages = createMessage(mailSend, peerId); - if (mailSend.getMessage() != null) { - messages.message(mailSend.getMessage()); - } - sendMessage(messages); - } - @Override public void send(MailSend mailSend, Integer peerId, Integer userId) { MessagesSendQuery messages = createMessage(mailSend, peerId); @@ -66,17 +57,6 @@ public class MailSanderVk implements MailSandler { sendMessage(messages); } - public void send(MailSend mailSend, Integer peerId, List insertWords) { - MessagesSendQuery messages = createMessage(mailSend, peerId); - if (mailSend.getMessage() != null) { - InsertWords insert = new InsertWords(); - insert.setInText(mailSend.getMessage()); - insert.insert(insertWords); - messages.message(insert.getOutText()); - } - sendMessage(messages); - } - @Override public void send(MailSend mailSend, Integer peerId, Integer userId, List insertWords) { MessagesSendQuery messages = createMessage(mailSend, peerId); diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSent.java similarity index 63% rename from src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java rename to src/main/java/org/sadtech/vkbot/core/sender/MailSent.java index bdcce23..19bab9f 100644 --- a/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java +++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSent.java @@ -4,14 +4,10 @@ import org.sadtech.vkbot.core.entity.MailSend; import java.util.List; -public interface MailSandler { - - void send(MailSend mailSend, Integer peerId); +public interface MailSent { void send(MailSend mailSend, Integer peerId, Integer userId); - void send(MailSend mailSend, Integer peerId, List insertWords); - void send(MailSend mailSend, Integer peerId, Integer userId, List insertWords); }