youtube_dl improved
This commit is contained in:
parent
c0c2ae7925
commit
c9258d2547
70
plugins/pluginsold/helpold.lua
Normal file
70
plugins/pluginsold/helpold.lua
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
do
|
||||||
|
|
||||||
|
-- Returns true if is not empty
|
||||||
|
local function has_usage_data(dict)
|
||||||
|
if (dict.usage == nil or dict.usage == '') then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get commands for that plugin
|
||||||
|
local function plugin_help(name)
|
||||||
|
local plugin = plugins[name]
|
||||||
|
if not plugin then return nil end
|
||||||
|
|
||||||
|
local text = ""
|
||||||
|
if (type(plugin.usage) == "table") then
|
||||||
|
for ku,usage in pairs(plugin.usage) do
|
||||||
|
text = text..usage..'\n'
|
||||||
|
end
|
||||||
|
text = text..'\n'
|
||||||
|
elseif has_usage_data(plugin) then -- Is not empty
|
||||||
|
text = text..plugin.usage..'\n\n'
|
||||||
|
end
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
-- !help command
|
||||||
|
local function telegram_help()
|
||||||
|
local text = "Plugin Liste: \n\n"
|
||||||
|
-- Plugins names
|
||||||
|
for name in pairs(plugins) do
|
||||||
|
text = text..name..'\n'
|
||||||
|
end
|
||||||
|
text = text..'\n'..'Benutze "/hilfe [Plugin Name]" für mehr Informationen'
|
||||||
|
text = text..'\n'..'Oder "/hilfe all" um alles zu sehen.'
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
-- !help all command
|
||||||
|
local function help_all()
|
||||||
|
local ret = ""
|
||||||
|
for name in pairs(plugins) do
|
||||||
|
ret = ret .. plugin_help(name)
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run(msg, matches)
|
||||||
|
if matches[1] == "/hilfe" then
|
||||||
|
return telegram_help()
|
||||||
|
elseif matches[1] == "/hilfe all" then
|
||||||
|
return help_all()
|
||||||
|
else
|
||||||
|
local text = plugin_help(matches[1])
|
||||||
|
if not text then
|
||||||
|
text = telegram_help()
|
||||||
|
end
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
description = "Zeigt die Plugins und Befehle",
|
||||||
|
usage = {"/hilfe","/hilfe all","/hilfe [Plugin]"},
|
||||||
|
patterns = {"^/hilfe$","^/hilfe all","^/hilfe (.+)"},
|
||||||
|
run = run
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
@ -5,17 +5,23 @@ function run(msg, matches)
|
|||||||
local receiver = get_receiver(msg)
|
local receiver = get_receiver(msg)
|
||||||
if string.match(msg.text, '"') then
|
if string.match(msg.text, '"') then
|
||||||
return 'Vergiss es'
|
return 'Vergiss es'
|
||||||
else
|
end
|
||||||
|
if string.match(msg.text, "/mp4") then
|
||||||
text = run_bash("youtube-dl -o tmp/video.mp4 --no-continue " .. URL)
|
text = run_bash("youtube-dl -o tmp/video.mp4 --no-continue " .. URL)
|
||||||
send_video(get_receiver(msg), "tmp/video.mp4", ok_cb, false)
|
send_video(get_receiver(msg), "tmp/video.mp4", ok_cb, false)
|
||||||
return URL .. ' wurde gedownloadet und wird jetzt gesendet! \nDas kann je nach Video sehr lang dauern! \nAlso habt Geduld!'
|
|
||||||
end
|
end
|
||||||
|
if string.match(msg.text, "/mp3") then
|
||||||
|
text = run_bash("youtube-dl -o tmp/sound.mp3 --audio-format mp3 --no-continue " .. URL)
|
||||||
|
send_audio(get_receiver(msg), "tmp/sound.mp3", ok_cb, false)
|
||||||
|
end
|
||||||
|
print(text)
|
||||||
|
return URL .. ' wurde gedownloadet und wird jetzt gesendet! \nDas kann je nach Video sehr lang dauern! \nAlso habt Geduld!'
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description = "Downloadet und sendet ein Video von verschiedenen Seiten mit youtube-dl",
|
description = "Downloadet und sendet ein Video von verschiedenen Seiten mit youtube-dl",
|
||||||
usage = {"/dl [Link]"},
|
usage = {"/mp4 [Link] (Um Video zu laden)","/mp3 [Link] (Um Audio zu laden)","Unterstützte Seiten: https://ponywave.de/a/youtubedl"},
|
||||||
patterns = {"^/dl (https?://[%w-_%.%?%.:/%+=&]+)$"},
|
patterns = {"^/mp4 (https?://[%w-_%.%?%.:/%+=&]+)$","^/mp3 (https?://[%w-_%.%?%.:/%+=&]+)$"},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
||||||
--by Akamaru [https://ponywave.de]
|
--by Akamaru [https://ponywave.de]
|
Reference in New Issue
Block a user