Neu: simples figuya Plugin
This commit is contained in:
parent
7da3e43181
commit
90eb1add06
40
miku/plugins/figuya.lua
Normal file
40
miku/plugins/figuya.lua
Normal file
@ -0,0 +1,40 @@
|
||||
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 = '\n'..unescape(data.description)
|
||||
local pic = data.thumbnail_url
|
||||
local text = title..desc
|
||||
|
||||
if string.len(text) > 200 then
|
||||
text = string.sub(unescape(text:gsub("%b<>", "")), 1, 197)..'...'
|
||||
else
|
||||
text = text
|
||||
end
|
||||
|
||||
return text, pic
|
||||
end
|
||||
|
||||
function figuya:action(msg, config, matches)
|
||||
local figu = matches[1]
|
||||
local text, pic = figuya:get_figuya(figu)
|
||||
if not text then
|
||||
utilities.send_reply(msg, config.errors.results)
|
||||
return
|
||||
end
|
||||
|
||||
utilities.send_typing(receiver, 'upload_photo')
|
||||
utilities.send_photo(msg.chat.id, pic, text)
|
||||
end
|
||||
|
||||
return figuya
|
@ -94,7 +94,7 @@ function shell:action(msg, config, matches)
|
||||
|
||||
-- Requires vnstat & vnstati (sudo apt-get install vnstat vnstati)
|
||||
if msg.text:match('^/[Tt][Rr][Aa][Ff][Ff][Ii][Cc]$') then
|
||||
local network = 'enp2s0' -- You can see your network with "ifconfig" in an terminal
|
||||
local network = 'wlan0' -- You can see your network with "ifconfig" in an terminal
|
||||
run_command("vnstati -m -vs -i "..network.." -o /tmp/vnstat.png")
|
||||
utilities.send_photo(msg.chat.id, '/tmp/vnstat.png', nil, msg.message_id)
|
||||
return
|
||||
|
Reference in New Issue
Block a user