diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/XMPPBot.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPBot.java b/juick-server/src/main/java/com/juick/server/XMPPBot.java index a07dbe869..6215576a2 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPBot.java +++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java @@ -517,6 +517,27 @@ public class XMPPBot implements StanzaListener, AutoCloseable { } return "No favorite messages, try to \"like\" something ;)"; } + @UserCommand(pattern = "^\\!\\s+#(\\d+)", help = "! #12345 - recommend message") + public String commandRecommend(User user, Jid from, String... arguments) { + int mid = NumberUtils.toInt(arguments[0], 0); + if (mid > 0) { + com.juick.Message msg = messagesService.getMessage(mid); + if (msg != null) { + if (msg.getUser() == user) { + return "You can't recommend your own messages."; + } + MessagesService.RecommendStatus status = messagesService.recommendMessage(mid, user.getUid()); + switch (status) { + case Added: + return "Message is added to your recommendations"; + case Deleted: + return "Message deleted from your recommendations."; + } + } + return "Message not found"; + } + return "Message not found"; + } // TODO: target notification @UserCommand(pattern = "^(s|u)\\s+\\@(\\S+)$", help = "S @username - subscribe to user" + "\nU @username - unsubscribe from user", patternFlags = Pattern.CASE_INSENSITIVE) |