diff --git a/pleroma-comments.lua b/pleroma-comments.lua index 01a40eb..26c470f 100644 --- a/pleroma-comments.lua +++ b/pleroma-comments.lua @@ -130,6 +130,34 @@ function write_comments(pleroma_posts, instance, show_avatars) return table.concat(media_list, "\n") end + function get_poll(poll) + if type(poll) ~= "table" then + return "" + end + local bar_chart = {"
$x$ people have cast $y$ votes
" + local foo = summary:gsub( + "%$(%w+)%$", + {x=math.floor(poll["voters_count"]), y=total_votes} + ) + table.insert(bar_chart, foo) + return table.concat(bar_chart,"\n") + end + if #pleroma_posts == 0 then return "" end @@ -157,9 +185,7 @@ function write_comments(pleroma_posts, instance, show_avatars) table.insert( attrs, get_media(post["media_attachments"]) ) - if type(post["poll"]) == "table" then - table.insert(attrs, "(poll attached)
") - end + table.insert(attrs, get_poll(post["poll"])) local interpolated = template:gsub("%$(%w+)%$", { i= #replies - i + 1,