From f23fe5f409ba3e6bcbc34819a438968d954a4982 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Tue, 2 Feb 2016 16:14:57 +0100 Subject: [PATCH] Links werden nun mitgesendet --- plugins/reddit.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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