aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-02-25 08:46:01 +0300
committerGravatar Vitaly Takmazov2018-02-25 08:46:01 +0300
commit81f82943e8c37f47bd02d7490935121ff16f6d71 (patch)
tree3adca7ed87c40a6582d8d52f01c4278705a071b4
parentbd89e1b84f195edcc68c1e9325f412f67b099504 (diff)
xmpp: show reply command
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPBot.java12
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java2
2 files changed, 12 insertions, 2 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 1c17a0aa..a07dbe86 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPBot.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java
@@ -617,10 +617,20 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
return String.join("\n",
replies.stream().map(PlainTextFormatter::formatPostSummary).collect(Collectors.toList()));
}
- return PlainTextFormatter.formatPostSummary(msg);
+ return PlainTextFormatter.formatPost(msg);
}
return "Message not found";
}
+ @UserCommand(pattern = "^#(\\d+)\\/(\\d+)$", help = "#1234/5 - Show reply")
+ public String commandShowReply(User user, Jid from, String... arguments) {
+ int mid = NumberUtils.toInt(arguments[0], 0);
+ int rid = NumberUtils.toInt(arguments[1], 0);
+ com.juick.Message reply = messagesService.getReply(mid, rid);
+ if (reply != null) {
+ return PlainTextFormatter.formatPost(reply);
+ }
+ return "Reply not found";
+ }
@UserCommand(pattern = "^D #(\\d+)$", help = "D #1234 - Delete post", patternFlags = Pattern.CASE_INSENSITIVE)
public String commandDeletePost(User user, Jid from, String... args) {
int mid = Integer.valueOf(args[0]);
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index c9c47a39..4496f68c 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -379,7 +379,7 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
public void botCommandsTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "PING").get(), is("PONG"));
// subscription commands have two lines, others have 1
- assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(23));
+ assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(24));
}
@Test