Архитектурные изменения автоответчика
This commit is contained in:
parent
f4d5946d77
commit
3b29921d2e
@ -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<Comment> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Comment object) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -26,10 +26,12 @@ public class EventDistributorVK implements EventDistributable, Runnable {
|
|||||||
if (eventService.getJsonObjects().peek() != null) {
|
if (eventService.getJsonObjects().peek() != null) {
|
||||||
JsonObject event = eventService.getJsonObjects().poll();
|
JsonObject event = eventService.getJsonObjects().poll();
|
||||||
log.info("Главный дистрибьютор отправил событие дальше");
|
log.info("Главный дистрибьютор отправил событие дальше");
|
||||||
|
if (eventDistributionMap.containsKey(event.get("type").getAsString())) {
|
||||||
eventDistributionMap.get(event.get("type").getAsString()).update(event.getAsJsonObject("object"));
|
eventDistributionMap.get(event.get("type").getAsString()).update(event.getAsJsonObject("object"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerSubscriber(String key, EventSubscribe o) {
|
public void registerSubscriber(String key, EventSubscribe o) {
|
||||||
|
@ -9,7 +9,7 @@ public class MailChatSubscriber implements EventSubscribe<Message> {
|
|||||||
|
|
||||||
private MailService mailService;
|
private MailService mailService;
|
||||||
|
|
||||||
public MailChatSubscriber(MailService mailService, EventDistributable eventDistributable) {
|
public MailChatSubscriber(EventDistributable eventDistributable, MailService mailService) {
|
||||||
this.mailService = mailService;
|
this.mailService = mailService;
|
||||||
eventDistributable.registerSubscriber("chat", this);
|
eventDistributable.registerSubscriber("chat", this);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class MailSubscriber implements EventSubscribe<JsonObject>, EventDistribu
|
|||||||
eventDistributionMap.get("chat").update(userMessage);
|
eventDistributionMap.get("chat").update(userMessage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (admins.contains(userMessage.getUserId())) {
|
if (admins.contains(userMessage.getUserId()) && eventDistributionMap.containsKey("terminal")) {
|
||||||
log.info("Сообщение отправлено в репозиторий команд");
|
log.info("Сообщение отправлено в репозиторий команд");
|
||||||
eventDistributionMap.get("terminal").update(userMessage);
|
eventDistributionMap.get("terminal").update(userMessage);
|
||||||
} else {
|
} else {
|
||||||
|
4
src/main/java/org/sadtech/vkbot/core/entity/Comment.java
Normal file
4
src/main/java/org/sadtech/vkbot/core/entity/Comment.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package org.sadtech.vkbot.core.entity;
|
||||||
|
|
||||||
|
public class Comment {
|
||||||
|
}
|
@ -13,16 +13,16 @@ import org.sadtech.vkbot.core.insert.InsertWords;
|
|||||||
|
|
||||||
import java.util.List;
|
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 VkApiClient vkApiClient;
|
||||||
private GroupActor groupActor;
|
private GroupActor groupActor;
|
||||||
|
|
||||||
private VkInsertData vkInsertData;
|
private VkInsertData vkInsertData;
|
||||||
|
|
||||||
public MailSanderVk(VkConnect vkConnect) {
|
public MailSenderVk(VkConnect vkConnect) {
|
||||||
this.vkApiClient = vkConnect.getVkApiClient();
|
this.vkApiClient = vkConnect.getVkApiClient();
|
||||||
this.groupActor = vkConnect.getGroupActor();
|
this.groupActor = vkConnect.getGroupActor();
|
||||||
this.vkInsertData = new VkInsertData(vkConnect);
|
this.vkInsertData = new VkInsertData(vkConnect);
|
||||||
@ -48,15 +48,6 @@ public class MailSanderVk implements MailSandler {
|
|||||||
return messages;
|
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
|
@Override
|
||||||
public void send(MailSend mailSend, Integer peerId, Integer userId) {
|
public void send(MailSend mailSend, Integer peerId, Integer userId) {
|
||||||
MessagesSendQuery messages = createMessage(mailSend, peerId);
|
MessagesSendQuery messages = createMessage(mailSend, peerId);
|
||||||
@ -66,17 +57,6 @@ public class MailSanderVk implements MailSandler {
|
|||||||
sendMessage(messages);
|
sendMessage(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(MailSend mailSend, Integer peerId, List<String> 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
|
@Override
|
||||||
public void send(MailSend mailSend, Integer peerId, Integer userId, List<String> insertWords) {
|
public void send(MailSend mailSend, Integer peerId, Integer userId, List<String> insertWords) {
|
||||||
MessagesSendQuery messages = createMessage(mailSend, peerId);
|
MessagesSendQuery messages = createMessage(mailSend, peerId);
|
@ -4,14 +4,10 @@ import org.sadtech.vkbot.core.entity.MailSend;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MailSandler {
|
public interface MailSent {
|
||||||
|
|
||||||
void send(MailSend mailSend, Integer peerId);
|
|
||||||
|
|
||||||
void send(MailSend mailSend, Integer peerId, Integer userId);
|
void send(MailSend mailSend, Integer peerId, Integer userId);
|
||||||
|
|
||||||
void send(MailSend mailSend, Integer peerId, List<String> insertWords);
|
|
||||||
|
|
||||||
void send(MailSend mailSend, Integer peerId, Integer userId, List<String> insertWords);
|
void send(MailSend mailSend, Integer peerId, Integer userId, List<String> insertWords);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user