From b529c007dec2b611adf8bf7e66d3f90bdfcda60d Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Thu, 15 Aug 2019 12:33:42 +0200 Subject: [PATCH] Add post deletion --- jan-pona-mute.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jan-pona-mute.py b/jan-pona-mute.py index 0289747..81236f1 100755 --- a/jan-pona-mute.py +++ b/jan-pona-mute.py @@ -471,6 +471,20 @@ Use the 'edit' command to edit notes.""" """Delete a comment.""" words = line.strip().split() if words: + if words[0] == "post": + if len(words) > 1: + print("Deleting a post takes no argument. It always deletes the selected post.") + return + if not self.post: + print("Use the 'show' command to select a post.") + return + if self.home and self.post in self.home: + self.home._stream.remove(self.post) + if self.post.id in self.post_cache: + self.post_cache.pop(self.post.id) + self.post.delete() + print("Post deleted.") + return if words[0] == "comment": if len(words) == 4: post = self.post_cache[words[3]] @@ -524,7 +538,7 @@ Use the 'edit' command to edit notes.""" else: print("There are no notes to delete.") else: - print("Things to delete: comment, note.") + print("Things to delete: post, comment, note.") return else: print("Delete what?") -- 2.25.1