diff options
Diffstat (limited to 'juick-xmpp/src/main/java/com')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/XMPPServer.java | 2 | ||||
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java index b5518e33..68f043e5 100644 --- a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java +++ b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java @@ -62,6 +62,8 @@ public class XMPPServer implements AutoCloseable { public PMQueriesService pmQueriesService; @Inject public SubscriptionService subscriptionService; + @Inject + public ShowQueriesService showQueriesService; private Jid jid; diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java index 6e89355a..e6efd500 100644 --- a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java @@ -297,6 +297,8 @@ public class JuickBot implements StanzaListener, AutoCloseable { return true; } else if (commandlen == 2 && command.equalsIgnoreCase("#+")) { return commandLast(msg.getFrom()); + } else if (command.equalsIgnoreCase("@")) { + return commandUsers(msg.getFrom()); } else if (xmpp.messagesService.isReadonly()) { return commandMaintenance(msg.getFrom()); } @@ -424,6 +426,31 @@ public class JuickBot implements StanzaListener, AutoCloseable { return true; } + boolean commandUsers(Jid jidFrom) { + StringBuilder msg = new StringBuilder(); + msg.append("Recommended blogs"); + User currentUser = xmpp.userService.getUserByJID(jidFrom.asBareJid().toEscapedString()); + List<String> recommendedUsers = xmpp.showQueriesService.getRecommendedUsers(currentUser); + if (recommendedUsers.size() > 0) { + for (String user : recommendedUsers) { + msg.append("\n@").append(user); + } + } else { + msg.append("\nNo recommendations now. Subscribe to more blogs. ;)"); + } + msg.append("\n\nTop 10 personal blogs:"); + List<String> topUsers = xmpp.showQueriesService.getTopUsers(); + if (topUsers.size() > 0) { + for (String user : topUsers) { + msg.append("\n@").append(user); + } + } else { + msg.append("\nNo top users. Empty DB? ;)"); + } + sendReply(jidFrom, msg.toString()); + return true; + } + private boolean commandMaintenance(Jid jidFrom) { sendReply(jidFrom, "Комментирование временно недоступно"); return true; |