From ce9fda2b0e591136d0bdc1f520a7bb9ef8c160fe Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 11 Jun 2023 14:21:00 +0300 Subject: [PATCH] Show link flair text as tag --- redditimages.own | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/redditimages.own b/redditimages.own index 5cb361e..23c8172 100644 --- a/redditimages.own +++ b/redditimages.own @@ -22,7 +22,7 @@ media = stream(subreddits) }) .toArray() -debug(jsonencode(media)) +debug(media) if (length(media) > 0) { bot.sendMediaGroup(config.peer, media) @@ -34,7 +34,7 @@ conn.close() // Helpers def debug(r) { -// echo(r) +// echo(jsonencode(r)) } def strToHashtag(str) = @@ -47,8 +47,10 @@ def safe(str) = str.replace("&", "&") def getCaption(post) { tag = "" - if (length(post.flair_text) > 0) { + if (length(post.flair_text ?? "") > 0) { tag = " #" + strToHashtag(post.sub + "_" + post.flair_text) + } else if (length(post.link_flair_text ?? "") > 0) { + tag = " #" + strToHashtag(post.sub + "_" + post.link_flair_text) } return sprintf( "%s\n" +