From 2d6e1dc76e659b78b3103af2bcf1b7f13db62f0a Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 30 Jan 2018 14:23:50 +0300 Subject: xmpp: D #message --- .../main/java/com/juick/components/JuickBot.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'juick-xmpp/src/main/java/com/juick') 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 9855f958..42a5f8a6 100644 --- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java @@ -632,7 +632,30 @@ public class JuickBot implements StanzaListener, AutoCloseable { } return "Message 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]); + if (messagesService.deleteMessage(user.getUid(), mid)) { + return "Message deleted"; + } + return "This is not your message"; + } + @UserCommand(pattern = "^D #(\\d+)(\\.|\\-|\\/)(\\d+)$", help = "D #1234/5 - Delete comment", patternFlags = Pattern.CASE_INSENSITIVE) + public String commandDeleteReply(User user, Jid from, String... args) { + int mid = Integer.valueOf(args[0]); + int rid = Integer.valueOf(args[2]); + if (messagesService.deleteReply(user.getUid(), mid, rid)) { + return "Reply deleted"; + } else { + return "This is not your reply"; + } + } + /* + @UserCommand(pattern = "(^(D L|DL|D LAST)$", help = "D #1234/5 - Delete comment", patternFlags = Pattern.CASE_INSENSITIVE) + public String commandDeleteLast(User user, Jid from, String... args) { + } + */ void sendReply(Jid jidTo, String txt) { Message reply = new Message(); reply.setFrom(jid); -- cgit v1.2.3