diff options
Diffstat (limited to 'juick-commands/src/main/java/com/juick/command')
-rw-r--r-- | juick-commands/src/main/java/com/juick/command/MessageListener.java | 3 | ||||
-rw-r--r-- | juick-commands/src/main/java/com/juick/command/Ping.java | 12 |
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 54d2c7e7e..a041ae04c 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 6298abf57..5507ffce3 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"; } } |