我想用如下改性LUA脚本在电报-CLI来发送自动回复消息:在电报-CLI发送多个响应消息(LUA脚本)
function ok_cb(extra, success, result)
end
function wait(seconds)
local start = os.time()
repeat until os.time() > start + seconds
end
function on_msg_receive (msg)
if msg.out then
return
end
if (string.find(msg.text, 'Hi there!')) then
wait(1)
send_msg (msg.from.print_name, 'Hello', ok_cb, false)
else
--do nothing
end
end
当我跑上面的脚本,如果我一条消息“Hi there!”,脚本将等待1秒钟,然后它会发送带有“Hello”消息的回复。
当我仅设置一条回复消息时,该脚本正常工作。但是,当我修改脚本以添加下面的其他回复消息时,结果不符合我的预期。
function ok_cb(extra, success, result)
end
function wait(seconds)
local start = os.time()
repeat until os.time() > start + seconds
end
function on_msg_receive (msg)
if msg.out then
return
end
if (string.find(msg.text, 'Hi there!')) then
wait(1)
send_msg (msg.from.print_name, 'Hello', ok_cb, false)
wait(3) --new command
send_msg (msg.from.print_name, 'World!', ok_cb, false) --new command
else
--do nothing
end
end
当我收到“Hi there!”时,我期望修改后的脚本是:消息,脚本会等待1秒,然后发送“Hello”消息,再等3秒钟,最后发送“World!”。信息。
实际发生的事情是剧本将等待3秒,然后发送“你好”和“世界!”与此同时。
有没有人有任何线索?在此先感谢