57 lines
1.7 KiB
Lua
57 lines
1.7 KiB
Lua
|
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
|