aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick/components
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components')
-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) {