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

43 lines
1.4 KiB
Lua

do
function run(msg, matches)
local receiver = get_receiver(msg)
local file = download_to_file(matches[1])
send_document(get_receiver(msg), file, ok_cb, false)
end
return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.gif)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.mp4)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.pdf)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.ogg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.ogv)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.oga)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.ogx)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.zip)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.mp3)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.rar)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wmv)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wma)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.doc)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.tar.gz)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.dlc)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.txt)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.deb)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.webm)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.avi)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wav)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.exe)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.rpm)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.dmg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.apk)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.ipa)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.webp)$"
},
run = run
}
end