From 28070bd32dbd8d5f1c126836ce130b5d1a79323a Mon Sep 17 00:00:00 2001 From: bytedream Date: Thu, 23 Jun 2022 16:44:34 +0200 Subject: [PATCH] Add function to check if a comment is marked as spoiler --- comment.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/comment.go b/comment.go index 4dba10d..47005cf 100644 --- a/comment.go +++ b/comment.go @@ -71,6 +71,16 @@ func (c *Comment) Delete() error { return nil } +// IsSpoiler returns if the comment is marked as spoiler or not. +func (c *Comment) IsSpoiler() bool { + for _, flag := range c.Flags { + if flag == "spoiler" { + return true + } + } + return false +} + // MarkAsSpoiler marks the current comment as spoiler. Works only if the user has written the comment, // and it isn't already marked as spoiler. func (c *Comment) MarkAsSpoiler() error {