aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick/components
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-03-02 17:01:00 +0300
committerGravatar Vitaly Takmazov2017-03-02 17:01:00 +0300
commit434ea38eeb489f5c095ce55a16ef6dcca9489335 (patch)
tree4b74e2211b1835e1640ab5c6dcf9cc38964d345c /juick-xmpp/src/main/java/com/juick/components
parentdf77161eb015125f61e37a6bf744ff6f0aa93a14 (diff)
juick-xmpp: command users duplicated from protocol
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPServer.java2
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java27
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;