2015-03-04 23:51:36 +01:00
|
|
|
do
|
2014-11-20 23:30:41 +01:00
|
|
|
|
2015-04-26 21:19:31 +02:00
|
|
|
local function run(msg, matches)
|
2015-04-14 20:21:23 +02:00
|
|
|
local receiver = get_receiver(msg)
|
2015-04-26 21:19:31 +02:00
|
|
|
local url = matches[1]
|
|
|
|
local ext = matches[2]
|
|
|
|
|
|
|
|
local file = download_to_file(url)
|
|
|
|
local cb_extra = {file_path=file}
|
|
|
|
|
|
|
|
local mime_type = mimetype.get_content_type_no_sub(ext)
|
|
|
|
|
|
|
|
if ext == 'gif' then
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Datei')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_document(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
|
|
|
|
elseif mime_type == 'text' then
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Document')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_document(receiver, file, rmtmp_cb, cb_extra)
|
2015-05-21 19:04:12 +02:00
|
|
|
|
|
|
|
elseif mime_type == 'application' then
|
|
|
|
print('Sende Document')
|
|
|
|
send_document(receiver, file, rmtmp_cb, cb_extra)
|
2015-04-26 21:19:31 +02:00
|
|
|
|
|
|
|
elseif mime_type == 'image' then
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Foto')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_photo(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
|
|
|
|
elseif mime_type == 'audio' then
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Audio')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_audio(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
|
|
|
|
elseif mime_type == 'video' then
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Video')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_video(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
|
|
|
|
else
|
2015-05-12 20:15:15 +02:00
|
|
|
print('Sende Datei')
|
2015-04-26 21:19:31 +02:00
|
|
|
send_document(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
end
|
|
|
|
|
2014-11-20 23:30:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2015-04-26 21:19:31 +02:00
|
|
|
description = "Wenn ein User eine Medien-Datei sendet (gif, mp4, pdf, etc.), wird es gedownloadet und gesendet.",
|
2015-04-28 17:49:11 +02:00
|
|
|
usage = {"Irgendeine Datei"},
|
2015-04-26 21:19:31 +02:00
|
|
|
patterns = {
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(tar.gz))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(7z))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(wav))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(apk))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(webm))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogv))$",
|
|
|
|
"(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$"
|
|
|
|
},
|
|
|
|
run = run
|
2015-03-04 23:14:39 +01:00
|
|
|
}
|
2015-03-04 23:51:36 +01:00
|
|
|
|
2015-04-14 20:21:23 +02:00
|
|
|
end
|