diff --git a/miku/plugins/figuya.lua b/miku/plugins/figuya.lua new file mode 100644 index 0000000..33c80fc --- /dev/null +++ b/miku/plugins/figuya.lua @@ -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 diff --git a/miku/plugins/shell.lua b/miku/plugins/shell.lua index ecace9a..db415c9 100644 --- a/miku/plugins/shell.lua +++ b/miku/plugins/shell.lua @@ -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