diff --git a/plugins/reddit.lua b/plugins/reddit.lua index a3fd63a..7dceb2b 100644 --- a/plugins/reddit.lua +++ b/plugins/reddit.lua @@ -17,10 +17,19 @@ function send_reddit_data(data, receiver) local title = data[1].data.children[1].data.title local author = data[1].data.children[1].data.author local subreddit = data[1].data.children[1].data.subreddit - local selftext = string.sub(unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")), 1, 300) .. '...' + if string.len(data[1].data.children[1].data.selftext) > 300 then + selftext = string.sub(unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")), 1, 300) .. '...' + else + selftext = unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")) + end + if not data[1].data.children[1].data.is_self then + url = data[1].data.children[1].data.url + else + url = '' + end local score = comma_value(data[1].data.children[1].data.score) local comments = comma_value(data[1].data.children[1].data.num_comments) - local text = author..' in /r/'..subreddit..' ('..score..' Upvotes - '..comments..' Kommentare):\n'..title..'\n'..selftext + local text = author..' in /r/'..subreddit..' ('..score..' Upvotes - '..comments..' Kommentare):\n'..title..'\n'..selftext..url send_msg(receiver, text, ok_cb, false) end