Show link flair text as tag

This commit is contained in:
Victor 2023-06-11 14:21:00 +03:00
parent 8b3b20210d
commit ce9fda2b0e

View File

@ -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(
"<a href=\"%s\">%s</a>\n" +