reddit.lua: Stelle auf HTML um & Link zum Reddit hinzugefügt
Der Code ist wie ich: Dreckig ( ͡° ͜ʖ ͡°)
This commit is contained in:
parent
cf2a7ca85b
commit
ef96dd1969
@ -15,14 +15,14 @@ local format_results = function(posts)
|
||||
local title = post.title:gsub('%[', '('):gsub('%]', ')'):gsub('&', '&')
|
||||
if title:len() > 256 then
|
||||
title = title:sub(1, 253)
|
||||
title = utilities.trim(title) .. '...'
|
||||
title = utilities.trim(title)..'...'
|
||||
end
|
||||
local short_url = 'https://redd.it/' .. post.id
|
||||
local s = '[' .. unescape(title) .. '](' .. short_url .. ')'
|
||||
local short_url = 'https://redd.it/'..post.id
|
||||
local s = '<a href="'..short_url..'">'..unescape(title)..'</a>'
|
||||
if post.domain and not post.is_self and not post.over_18 then
|
||||
s = '`[`[' .. post.domain .. '](' .. post.url:gsub('%)', '\\)') .. ')`]` ' .. s
|
||||
s = '[<a href="'..post.url:gsub('%)', '\\)')..'">'..post.domain..'</a>] '..s
|
||||
end
|
||||
output = output .. '• ' .. s .. '\n'
|
||||
output = output..'• '..s..'\n'
|
||||
end
|
||||
return output
|
||||
end
|
||||
@ -47,17 +47,17 @@ function reddit:action(msg, config)
|
||||
if input then
|
||||
if input:match('^r/.') then
|
||||
input = utilities.get_word(input, 1)
|
||||
url = reddit.subreddit_url:format(input) .. limit
|
||||
source = '*/' .. utilities.md_escape(input) .. '*\n'
|
||||
url = reddit.subreddit_url:format(input)..limit
|
||||
source = '<b>/'..utilities.md_escape(input)..'</b>\n'
|
||||
else
|
||||
input = utilities.input(msg.text)
|
||||
source = '*Ergebnisse für* _' .. utilities.md_escape(input) .. '_ *:*\n'
|
||||
source = '<b>Ergebnisse für</b> <i>'..utilities.md_escape(input)..'</i> <b>:</b>\n'
|
||||
input = URL.escape(input)
|
||||
url = reddit.search_url:format(input) .. limit
|
||||
url = reddit.search_url:format(input)..limit
|
||||
end
|
||||
else
|
||||
url = reddit.rall_url .. limit
|
||||
source = '*/r/all*\n'
|
||||
url = reddit.rall_url..limit
|
||||
source = '<b>/r/all</b>\n'
|
||||
end
|
||||
local jstr, res = https.request(url)
|
||||
if res ~= 200 then
|
||||
@ -68,8 +68,9 @@ function reddit:action(msg, config)
|
||||
utilities.send_reply(msg, config.errors.results)
|
||||
else
|
||||
local output = format_results(jdat.data.children)
|
||||
output = source .. output
|
||||
utilities.send_message(msg.chat.id, output, true, nil, true)
|
||||
local redd_link = source:gsub('</?b>', '')
|
||||
output = source..output..'<a href="https://reddit.com'..redd_link..'">Mehr auf Reddit ansehen.</a>'
|
||||
utilities.send_reply(msg, output, 'HTML')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user