aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-bot/src/main/java/com/juick/components
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp-bot/src/main/java/com/juick/components')
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java5
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotAppConfiguration.java5
2 files changed, 8 insertions, 2 deletions
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
index 55ae0b7d..6b716630 100644
--- a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
+++ b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
@@ -32,6 +32,8 @@ public class XMPPBot implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class);
@Inject
UserService userService;
+ @Inject
+ JuickProtocol juickProtocol;
private ExternalComponent component;
@@ -50,7 +52,6 @@ public class XMPPBot implements AutoCloseable {
ownVCard.setUrl(new URL("http://juick.com/"));
ownVCard.setPhoto(new VCard.Image("image/png", IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("vCard.png"))));
vCardManager.setVCard(ownVCard);
- JuickProtocol protocol = new JuickProtocol("http://juick.com/");
component.addInboundMessageListener(e -> {
Message message = e.getMessage();
if (message.getType().equals(Message.Type.ERROR) || message.getType().equals(Message.Type.GROUPCHAT)) {
@@ -73,7 +74,7 @@ public class XMPPBot implements AutoCloseable {
}
} else {
try {
- ProtocolReply reply = protocol.getReply(user, text);
+ ProtocolReply reply = juickProtocol.getReply(user, text);
Message replyMessage = new Message(message.getFrom(), Message.Type.CHAT);
replyMessage.setBody(reply.getDescription());
replyMessage.setFrom(juickJid);
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotAppConfiguration.java b/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotAppConfiguration.java
index 0c5f10c1..d6905c1b 100644
--- a/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotAppConfiguration.java
+++ b/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotAppConfiguration.java
@@ -1,6 +1,7 @@
package com.juick.components.configuration;
import com.juick.components.XMPPBot;
+import com.juick.server.protocol.JuickProtocol;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@@ -21,4 +22,8 @@ public class BotAppConfiguration {
public XMPPBot xmpp() {
return new XMPPBot(env);
}
+ @Bean
+ public JuickProtocol juickProtocol() {
+ return new JuickProtocol("http://juick.com");
+ }
}