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/plugins/pluginsold/pili.lua
2015-06-16 21:40:12 +02:00

33 lines
600 B
Lua

local helpers = require "OAuth.helpers"
local url = "http://pili.la/api.php"
local function run(msg, matches)
local url_req = matches[1]
local request = {
url = url_req
}
local url = url .. "?" .. helpers.url_encode_arguments(request)
local res, code = http.request(url)
if code ~= 200 then
return "Sorry, can't connect"
end
return res
end
return {
description = "Shorten an URL with the awesome http://pili.la",
usage = {
"!pili [url]: Shorten the URL"
},
patterns = {
"^!pili (https?://[%w-_%.%?%.:/%+=&]+)$"
},
run = run
}