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/clypit.lua
Andreas Bielawski fb9d3652f3 Upstream:
- self muss nicht mehr überall übergeben werden
- alle Plugins wurden angepasst

Eigene Updates:
- abort_inline_query() hinzugefügt
- Mehr Plugins zum Standard-Set hinzugefügt
- Eventuell noch etwas, was ich vergessen hab
2016-08-24 15:38:29 +02:00

29 lines
806 B
Lua

local clypit = {}
clypit.triggers = {
"clyp.it/([A-Za-z0-9-_-]+)"
}
function clypit:get_clypit_details(shortcode)
local BASE_URL = "http://api.clyp.it"
local url = BASE_URL..'/'..shortcode
local res,code = http.request(url)
if code ~= 200 then return nil end
local data = json.decode(res)
local title = data.Title
local duration = data.Duration
local audio = download_to_file(data.Mp3Url)
return audio, title, duration
end
function clypit:action(msg, config, matches)
utilities.send_typing(msg.chat.id, 'upload_audio')
local audio, title, duration = clypit:get_clypit_details(matches[1])
if not audio then return utilities.send_reply(msg, config.errors.connection) end
utilities.send_audio(msg.chat.id, audio, nil, msg.message_id, duration, nil, title)
end
return clypit