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-2/miku/plugins/figuya.lua

34 lines
983 B
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local figuya = {}
function figuya:init(config)
figuya.triggers = {'figuya.com/de/produkte/(.+)$'}
end
function figuya:get_figuya(figu)
local api_key = cred_data.iframely_api_key
local url = 'http://iframe.ly/api/oembed?url=https%3A%2F%2Ffiguya.com%2Fde%2Fprodukte%2F'..figu..'&api_key='..api_key
local b,c = https.request(url)
if c ~= 200 then return nil end
local data = json.decode(b)
local title = data.title
local desc = string.sub(unescape(data.description:gsub("%b<>", "")), 1, 500)..'...'
local pic = 'https://brawlbot.tk/img.php?url='..data.thumbnail_url
local text = '<b>'..title..'</b>\n<i>'..desc..'</i>'..'<a href="'..pic..'"> </a>'
return text
end
function figuya:action(msg, config, matches)
local figu = matches[1]
local text = figuya:get_figuya(figu)
if not text then
utilities.send_reply(msg, config.errors.results)
return
end
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
end
return figuya