aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-30 13:30:20 +0300
committerGravatar Vitaly Takmazov2018-01-30 13:30:20 +0300
commit59e0c016bcb3e5f5260bf35bed63994fc9df3016 (patch)
tree9d870ee328696bf6c5bcb8cc93164346f03f7104 /juick-xmpp/src/main/java
parent9c22987d6309b91fbe41bd47e410b1f809144c41 (diff)
xmpp: S @username
Diffstat (limited to 'juick-xmpp/src/main/java')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/JuickBot.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java
index 7a25f5d5..2884fdd4 100644
--- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java
+++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java
@@ -528,6 +528,24 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
return "No favorite messages, try to \"like\" something ;)";
}
+ // TODO: target notification
+ @UserCommand(pattern = "^(s|u)\\s+\\@(\\S+)$", help = "S @username - subscribe to user" +
+ "\nU @username - unsubscribe from user", patternFlags = Pattern.CASE_INSENSITIVE)
+ public String commandSubscribeUser(User user, Jid from, String... args) {
+ boolean subscribe = args[0].equalsIgnoreCase("s");
+ User toUser = userService.getUserByName(args[1]);
+ if (subscribe) {
+ if (subscriptionService.subscribeUser(user, toUser)) {
+ return "Subscribed to @" + toUser.getName();
+ }
+ } else {
+ if (subscriptionService.unSubscribeUser(user, toUser)) {
+ return "Unsubscribed from @" + toUser.getName();
+ }
+ return "You was not subscribed to @" + toUser.getName();
+ }
+ return "Error";
+ }
@UserCommand(pattern = "^(s|u)\\s+\\*(\\S+)$", help = "S *tag - subscribe to tag" +
"\nU *tag - unsubscribe from tag", patternFlags = Pattern.CASE_INSENSITIVE)
public String commandSubscribeTag(User user, Jid from, String... args) {