下面是我的irc bot中的一段代碼。它所做的就是檢查特定帳戶的新推文,然後在頻道中回覆它。 現在,有沒有更好的方法來檢查新的推文?我在1..999999999感覺有點不理想,而且ddos'y。檢查新鳴叫的最佳方法
tweetzsr = {}
xzsr = {}
zsr = {}
on :message, ".start zsr" do |m|
if zsr[m.channel] == true
m.reply "already doing it.."
else
m.reply "ok."
zsr[m.channel] = true
for i in 1..99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
sleep 60
puts "#{xzsr[m.channel]} = x, tweetzsr = #{tweetzsr[m.channel]}"
tweetzsr[m.channel] = Twitter.user_timeline("twiitterracount").first.text
if xzsr[m.channel] == tweetzsr[m.channel]
nil
else
m.reply "#{tweetzsr[m.channel]} - via twitter feed"
xzsr[m.channel] = tweetzsr[m.channel]
end
end
end
end
習語紅寶石應該使用而'環do'然後'而TRUE'。 –
<3更新了相應的答案 – shime