aboutsummaryrefslogtreecommitdiff
path: root/juick-commands/src/main/java
diff options
context:
space:
mode:
authorGravatar Anatoliy Sablin2017-11-06 17:08:05 +0300
committerGravatar Anatoliy Sablin2017-11-06 17:08:05 +0300
commitaec013888a71856b4ec5a3415c266cd07c0ba5c4 (patch)
tree54069155d0a2aa1bccb6ac59f94ff75403375275 /juick-commands/src/main/java
parentbb2a47ea3c17f92c1d55d8b0d26cd26a880373d9 (diff)
Use new command processor.
Diffstat (limited to 'juick-commands/src/main/java')
-rw-r--r--juick-commands/src/main/java/com/juick/command/MessageListener.java3
-rw-r--r--juick-commands/src/main/java/com/juick/command/Ping.java12
2 files changed, 15 insertions, 0 deletions
diff --git a/juick-commands/src/main/java/com/juick/command/MessageListener.java b/juick-commands/src/main/java/com/juick/command/MessageListener.java
index 54d2c7e7..a041ae04 100644
--- a/juick-commands/src/main/java/com/juick/command/MessageListener.java
+++ b/juick-commands/src/main/java/com/juick/command/MessageListener.java
@@ -2,6 +2,7 @@ package com.juick.command;
import com.juick.User;
import rocks.xmpp.core.stanza.model.Message;
+import rocks.xmpp.core.stanza.model.Presence;
/**
* @author ma1uta
@@ -12,6 +13,8 @@ public interface MessageListener {
void sendMessage(Message message);
+ void sendPresence(Presence presence);
+
void messagePosted(com.juick.Message msg);
void userSubscribed(User from, User to);
diff --git a/juick-commands/src/main/java/com/juick/command/Ping.java b/juick-commands/src/main/java/com/juick/command/Ping.java
index 6298abf5..5507ffce 100644
--- a/juick-commands/src/main/java/com/juick/command/Ping.java
+++ b/juick-commands/src/main/java/com/juick/command/Ping.java
@@ -1,7 +1,11 @@
package com.juick.command;
import com.juick.User;
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
+import rocks.xmpp.addr.Jid;
+import rocks.xmpp.core.stanza.model.Presence;
import java.util.regex.Pattern;
@@ -9,10 +13,14 @@ import java.util.regex.Pattern;
* @author ma1uta
*/
@Component
+@Getter
public class Ping implements Command {
private static final Pattern PATTERN = Pattern.compile("^ping$", Pattern.CASE_INSENSITIVE);
+ @Value("${xmppbot_jid}")
+ private Jid jid;
+
@Override
public Pattern pattern() {
return PATTERN;
@@ -25,6 +33,10 @@ public class Ping implements Command {
@Override
public String execute(User sender, MessageListener protocolListener, String command) {
+ Presence p = new Presence(Jid.of(sender.getJid()));
+ p.setFrom(getJid());
+ p.setPriority((byte) 10);
+ protocolListener.sendPresence(p);
return "PONG";
}
}