Neues Plugin: reverse_video.lua

Spiele GIFs rückwärts ab
This commit is contained in:
Akamaru 2017-08-14 23:40:41 +02:00
parent 8c5d23a292
commit 3a8b7b8f48
1 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,57 @@
local reverse_video = {}
reverse_video.triggers = {
"^/reverse$"
}
function reverse_video:action(msg, config)
-- Check if there is really a video
if msg.reply_to_message then -- answer
if not msg.reply_to_message.document then
-- print('Kein Dokument in Antwort')
return
end
if msg.reply_to_message.document.mime_type ~= "video/mp4" then
-- print('Kein Video in Antwort')
return
end
file_size = msg.reply_to_message.document.file_size
file_id = msg.reply_to_message.document.file_id
else -- caption/command
if not msg.document then
-- print('Kein Dokument')
return
end
if msg.document.mime_type ~= "video/mp4" then
-- print('Kein Video')
return
end
file_size = msg.document.file_size
file_id = msg.document.file_id
end
if file_size > 19922944 then
print('Datei ist größer als 20 MB :(')
return msg
end
local request = bindings.request('getFile', {
file_id = file_id
} )
if not request then
print('getFile() fehlgeschlagen!')
return
end
local url = 'https://api.telegram.org/file/bot'..config.bot_api_key..'/'..request.result.file_path
local file_raw = download_to_file(url, 'video.mp4')
print('Konvertiere GIF...')
local cmd = run_command('ffmpeg -loglevel error -i '..file_raw..' -vf reverse /tmp/reversed.mp4 -y')
local file = '/tmp/reversed.mp4'
utilities.send_typing(msg.chat.id, 'upload_document')
utilities.send_video(msg.chat.id, file, nil, msg.message_id)
end
return reverse_video