This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/pluginsold/tumblr_blog.lua

46 lines
1011 B
Lua

do
local api_key = cred_data.tumblr_api_key
local function get_blog_info(id)
local url = 'https://api.tumblr.com/v2/blog/'..id..'.tumblr.com/info?api_key='..api_key
local res,code = https.request(url)
local data = json:decode(res).response.blog
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local title = data.title
local desc = data.description
if data.posts == 1 then
posts = data.posts..' Post'
else
posts = data.posts..' Posts'
end
if data.likes then
likes = ', '..data.likes..' Likes'
else
likes = ''
end
local text = title..'\n'..desc..'\n'..posts..likes..'\n'
return text
end
local function run(msg, matches)
local id = matches[1]
local text = get_blog_info(id)
local receiver = get_receiver(msg)
return text
end
return {
description = "Sendet Infos zu einem tumblr-Blog",
usage = "Link zu tumblr Blog",
patterns = {
"^https?://(.*).tumblr.com/?$"
},
run = run
}
end