- AFK: Nutze globale Funktion makeHumanTime, um Sekunden umzurechnen
- Tagesschau: InlineQuery!
This commit is contained in:
parent
606007dd13
commit
f2d76958b4
@ -81,16 +81,7 @@ function afk:pre_process(msg, self)
|
||||
local current_timestamp = msg.date
|
||||
local afk_time = current_timestamp - timestamp
|
||||
local seconds = afk_time % 60
|
||||
local minutes = math.floor(afk_time / 60)
|
||||
local minutes = minutes % 60
|
||||
local hours = math.floor(afk_time / 3600)
|
||||
if minutes == 00 and hours == 00 then
|
||||
duration = seconds..' Sekunden'
|
||||
elseif hours == 00 and minutes ~= 00 then
|
||||
duration = string.format("%02d:%02d", minutes, seconds)..' Minuten'
|
||||
elseif hours ~= 00 then
|
||||
duration = string.format("%02d:%02d:%02d", hours, minutes, seconds)..' Stunden'
|
||||
end
|
||||
local duration = makeHumanTime(seconds)
|
||||
|
||||
redis:hset(hash, 'afk', false)
|
||||
if afk_text then
|
||||
|
@ -10,6 +10,8 @@ tagesschau.triggers = {
|
||||
"tagesschau.de/([A-Za-z0-9-_-_-/]+).html"
|
||||
}
|
||||
|
||||
tagesschau.inline_triggers = tagesschau.triggers
|
||||
|
||||
local BASE_URL = 'https://www.tagesschau.de/api'
|
||||
|
||||
local makeOurDate = function(dateString)
|
||||
@ -36,12 +38,33 @@ function tagesschau:get_tagesschau_article(article)
|
||||
|
||||
local text = '*'..title..'*\n_'..posted_at..'_\n'..news
|
||||
if data.banner[1] then
|
||||
return text, data.banner[1].variants[1].modPremium
|
||||
return text, data.banner[1].variants[1].modPremium, data.shortheadline, data.shorttext
|
||||
else
|
||||
return text
|
||||
return text, nil, data.shortheadline, data.shorttext
|
||||
end
|
||||
end
|
||||
|
||||
function tagesschau:inline_callback(inline_query, config, matches)
|
||||
local article = matches[1]
|
||||
local full_url = 'http://www.tagesschau.de/'..article..'.html'
|
||||
local text, img_url, headline, shorttext = tagesschau:get_tagesschau_article(article)
|
||||
if text == 'HTTP-Fehler' or text == 'Artikel nicht gefunden!' then return end
|
||||
|
||||
if text:match('"') then
|
||||
text = text:gsub('"', '\\"')
|
||||
end
|
||||
if shorttext:match('"') then
|
||||
shorttext = shorttext:gsub('"', '\\"')
|
||||
end
|
||||
if headline:match('"') then
|
||||
headline = headline:gsub('"', '\\"')
|
||||
end
|
||||
|
||||
local text = text:gsub('\n', '\\n')
|
||||
local results = '[{"type":"article","id":"'..math.random(100000000000000000)..'","title":"'..headline..'","description":"'..shorttext..'","url":"'..full_url..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/tagesschau/tagesschau.jpg","thumb_width":150,"thumb_height":150,"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Artikel aufrufen","url":"'..full_url..'"}]]},"input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]'
|
||||
utilities.answer_inline_query(self, inline_query, results, 7200)
|
||||
end
|
||||
|
||||
function tagesschau:action(msg, config, matches)
|
||||
local article = matches[1]
|
||||
local text, image_url = tagesschau:get_tagesschau_article(article)
|
||||
|
Reference in New Issue
Block a user