我正在尝试使用Telegram CLI来“控制”我的虚拟树莓派3。我正在用我的智能手机发送电报CLI,并设法通过以下方式在我的手机上发送"Ping“来接收"Pong”:https://pimylifeup.com/raspberry-pi-telegram-bot/
我创建了这个脚本:https://www.raspberrypi.org/forums/viewtopic.php?t=252300,这样我就可以在我的树莓派上播放视频(当直接从CMD调用时,它可以工作)
我的想法是向Raspberry PI发送一条消息,格式为PLAY- youtube -link.com,用LUA捕捉该消息并调用脚本来播放youtube视频。
用于播放youtube视频的脚本另存为"ytplayvlc":
#!bin/bash
youtube-dl - U -f $2 -o - "$1" | vlc -动作脚本保存在名为“actions.lua”的子文件夹/tg中:
function on_msg_receive (msg)
if msg.out then
return
end
if (msg.text == 'ping') then
send_msg (msg.from.print_name, 'pong', ok_cb, false)
end
local message = msg.text
if (message.match(message, "PLAY-")) then
send_msg (msg.from.print_name, 'Okay! This might take a second..', ok_c$, ok_cb, false)
local link = string.match(message, "-(.*)")
local command = [["../ytplayvlc " .. link .. " 18"]]
os.execute(command)
end
end
function on_our_id(id)
end
function on_secret_chat_update(user, what_changed)
end
function on_user_update(user_what_changed)
end
function on_chat_update(user, what_changed)
end
function on_get_difference_end()
end
function on_binlog_replay_end()
end我使用以下命令开始电报CLI:
bin/telegram-cli -k -N --enable-msg-id tg-server.pub -W -a actions.lua乒乓球运行得很好,但当我发送命令播放youtube视频时,我收到消息“好的!这可能需要一秒钟..”但之后什么都没发生。此外,当我使用乒乓球或youtube命令时,在收到上述消息后,立即收到CMD中的消息"lua::attempt to call a nil value“。
我不知道为什么,如果有人有什么想法,请让我知道。我在上面提到的技术中没有经验,如果我错过了一些信息,我道歉。谢谢。
发布于 2020-06-09 17:38:59
我解决了这个问题!我删除了命令周围的方括号。所以现在这行代码是: local command = " .. /ytplayvlc“..链接..“18”
https://stackoverflow.com/questions/62279227
复制相似问题