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/webshot.lua

23 lines
869 B
Lua

local webshot = {}
function webshot:init(config)
webshot.triggers = {
"^/webshot ([%w-_%.%?%.:,/%+=&#!]+)$",
"^/scrot ([%w-_%.%?%.:,/%+=&#!]+)$"
}
webshot.doc = [[*
]]..config.cmd_pat..[[scrot* _<URL>_: Fertigt ein Screenshot mit einer Größe von 1024x768px an.]]
end
function webshot:action(msg, config, matches)
local api_key = cred_data.webshot_key
local cache = '0' --cache=0 : never use cache, always download fresh screenshot || cache=1 : use image from cache only if is not older than 1 day etc...
local url = matches[1]
local img_url = 'http://api.screenshotmachine.com/?key='..api_key..'&dimension=1024x768&cacheLimit='..cache..'&url='..url
local file = download_to_file(img_url, 'scrot.jpg')
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end
return webshot