choose size of picture in webshot

This commit is contained in:
Akamaru 2015-06-25 22:07:45 +02:00
parent c1e5b4df15
commit 5937e58687

View File

@ -3,7 +3,7 @@ local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/' local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php' local url = base .. 'processor.php'
local function get_webshot_url(param) local function get_webshot_url(param, size)
local response_body = {} local response_body = {}
local request_constructor = { local request_constructor = {
url = url, url = url,
@ -20,7 +20,7 @@ local function get_webshot_url(param)
local arguments = { local arguments = {
urlparam = param, urlparam = param,
size = "X", size = size,
cacheLimit = "0" cacheLimit = "0"
} }
@ -36,7 +36,14 @@ local function get_webshot_url(param)
end end
local function run(msg, matches) local function run(msg, matches)
local find = get_webshot_url(matches[1]) if matches[2] == nil then
webshot_url = matches[1]
size = "X"
else
webshot_url = matches[2]
size = string.upper(matches[1])
end
local find = get_webshot_url(webshot_url, size)
if find then if find then
local imgurl = base .. find local imgurl = base .. find
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
@ -46,11 +53,16 @@ end
return { return {
description = "Sendet einen Screenshot einer Webseite.", description = "Sendet einen Screenshot einer Website.",
usage = "/webshot [URL]//scrot [URL]", usage = {
patterns = { "/scrot [URL]: Fertigt Bild mit Größe 1024x768 (X) an",
"^/webshot ([%w-_%.%?%.:,/%+=&#!]+)$", "/scrot [T|S|E|N|M|L|X|F] [URL]: Fertigt Bild mit bestimmter Größe an (T = tiny, F = full)"
"^/scrot ([%w-_%.%?%.:,/%+=&#!]+)$" },
}, patterns = {
run = run "^/webshot ([T|t|S|s|E|e|N|n|M|m|L|l|X|x|F|f]) (https?://[%w-_%.%?%.:,/%+=&#!]+)$",
"^/scrot ([T|t|S|s|E|e|N|n|M|m|L|l|X|x|F|f]) (https?://[%w-_%.%?%.:,/%+=&#!]+)$",
"^/webshot (https?://[%w-_%.%?%.:,/%+=&#!]+)$",
"^/scrot (https?://[%w-_%.%?%.:,/%+=&#!]+)$"
},
run = run
} }