aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp/src/main/java')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/JuickBot.java25
1 files changed, 22 insertions, 3 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 15e1fe66b..937645d09 100644
--- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java
+++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java
@@ -551,7 +551,7 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
@UserCommand(pattern = "^(s|u)\\s+#(\\d+)$", help = "S #1234 - subscribe to comments",
patternFlags = Pattern.CASE_INSENSITIVE)
- public String commandSubscribeMessage(User user, String... args) {
+ public String commandSubscribeMessage(User user, Jid from, String... args) {
boolean subscribe = args[0].equalsIgnoreCase("s");
int mid = NumberUtils.toInt(args[1], 0);
if (messagesService.getMessage(mid) != null) {
@@ -570,7 +570,7 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
@UserCommand(pattern = "^(on|off)$", patternFlags = Pattern.CASE_INSENSITIVE,
help = "ON/OFF - Enable/disable subscriptions delivery")
- public String commandOnOff(User user, String[] input) {
+ public String commandOnOff(User user, Jid from, String[] input) {
UserService.ActiveStatus newStatus;
String retValUpdated;
if (input[0].toLowerCase().equals("on")) {
@@ -589,7 +589,7 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
@UserCommand(pattern = "^\\@([^\\s\\n\\+]+)(\\+?)$",
help = "@username+ - Show user's info and last 10 messages (@username++ - second page, ..)")
- public String commandUser(User user, String... arguments) {
+ public String commandUser(User user, Jid from, String... arguments) {
User blogUser = userService.getUserByName(arguments[0]);
int page = arguments[1].length();
if (blogUser.getUid() > 0) {
@@ -601,6 +601,25 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
return "User not found";
}
+ @UserCommand(pattern = "^#(\\d+)(\\+?)$", help = "#1234 - Show message (#1234+ - message with replies)")
+ public String commandShow(User user, Jid from, String... arguments) {
+ boolean showReplies = arguments[1].length() > 0;
+ int mid = NumberUtils.toInt(arguments[0], 0);
+ if (mid == 0) {
+ return "Error";
+ }
+ com.juick.Message msg = messagesService.getMessage(mid);
+ if (msg != null) {
+ if (showReplies) {
+ List<com.juick.Message> replies = messagesService.getReplies(mid);
+ replies.add(0, msg);
+ return String.join("\n",
+ replies.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList()));
+ }
+ return PlainTextFormatter.formatPost(msg);
+ }
+ return "Message not found";
+ }
void sendReply(Jid jidTo, String txt) {
Message reply = new Message();