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_download.lua

42 lines
991 B
Lua
Raw Normal View History

2015-04-14 20:21:23 +02:00
2015-04-12 20:14:21 +02:00
local function callback(extra, success, result)
if success then
print('Datei gespeichert in:', result)
2015-04-12 20:14:21 +02:00
else
print('Fehler beim downloaden von "'..extra..'"')
2015-04-12 20:14:21 +02:00
end
end
local function run(msg, matches)
if msg.media then
2015-05-28 16:47:30 +02:00
if msg.media.type == 'document' then
2015-04-12 20:14:21 +02:00
load_document(msg.id, callback, msg.id)
end
if msg.media.type == 'photo' then
load_photo(msg.id, callback, msg.id)
end
if msg.media.type == 'video' then
load_video(msg.id, callback, msg.id)
end
if msg.media.type == 'audio' then
load_audio(msg.id, callback, msg.id)
end
end
end
local function pre_process(msg)
if not msg.text and msg.media then
msg.text = '['..msg.media.type..']'
end
return msg
end
return {
description = 'Wenn eine Datei gesendet wird, läd Mikubot sie runter.',
usage = {'Irgendeine Datei'},
2015-04-12 20:14:21 +02:00
run = run,
patterns = {'%[(document)%]','%[(photo)%]','%[(video)%]','%[(audio)%]'},
2015-11-12 17:42:03 +01:00
pre_process = pre_process,
notyping = true
2015-04-14 20:21:23 +02:00
}