伙计们,我为twitch写了一个聊天机器人。我想在聊天的时候发一个垃圾邮件,然后写“hello”,等待10秒,然后再写一遍。我这样做了,但在我的代码中,当任何人写聊天的时候,我的机器人都有这样的回答系统。当我在相同的系统中尝试,但不起作用
until @socket.eof? do
message = @socket.gets
puts message
if message.match(/PRIVMSG ##{@channel} :(.*)$/)
a = Time.now
b = Time.now + 5
while a < b do
write_to_chat("!prime")
a += 4
sleep(20)
end
end
if message.match(/PRIVMSG ##{@channel} :(.*)$/)
content = $~[1]
username = message.match(/@(.*).tmi.twitch.tv/)[1]
if content.include? 'theoSea'
write_to_chat(" theoAse theoAse theoAse")
end 发布于 2019-06-01 22:43:56
我用调度器解决了它,我想要一个每5分钟写一次的代码,我尝试了很多方法,但是睡眠命令,我发现这个链接"https://github.com/jmettraux/rufus-scheduler“都在链接中,你可以使用这个gem。伙计们,万事俱备。
https://stackoverflow.com/questions/56400417
复制相似问题