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/otouto/plugins/pasteee.lua
Andreas Bielawski 2118a844d9 - Restrukturierung: "require" wird nun nicht mehr in jedem Plugin benötigt
- Echo: Korrekte Ausgabe in Supergruppen
2016-07-31 21:29:44 +02:00

42 lines
1.0 KiB
Lua

local pasteee = {}
function pasteee:init(config)
if not cred_data.pasteee_key then
print('Missing config value: pasteee_key.')
print('pasteee.lua will not be enabled, listquotes won\'t be available.')
return
end
pasteee.triggers = {
"^/pasteee (.*)$"
}
pasteee.doc = [[*
]]..config.cmd_pat..[[pasteee* _<Text>_: Postet Text auf Paste.ee]]
end
pasteee.command = 'pasteee <Text>'
local key = cred_data.pasteee_key
function upload(text, noraw)
local url = "https://paste.ee/api"
local pet = post_petition(url, 'key='..key..'&paste='..text..'&format=json')
if pet.status ~= 'success' then return 'Ein Fehler ist aufgetreten: '..pet.error, true end
if noraw then
return pet.paste.link
else
return pet.paste.raw
end
end
function pasteee:action(msg, config, matches)
local text = matches[1]
local link, iserror = upload(text)
if iserror then
utilities.send_reply(self, msg, link)
return
end
utilities.send_reply(self, msg, '[Text auf Paste.ee ansehen]('..link..')', true)
end
return pasteee