require 'thread' require 'cinch' workers = 5 queue = Queue.new throttle = 0.1 # lower the faster but easier to hit IRCd sendq prev_item = nil @bots = Array.new(workers) do Thread.new do bot = Cinch::Bot.new do configure do |c| c.server = "irc.server.local" c.port = 7001 c.realname = 'robert' c.password = "password" c.channels = ["#test99"] c.nicks = ['zz1', 'zz2', 'zz3', 'zz4', 'zz5', 'zz6'] c.user = 'bot' c.ssl.use = true c.ssl.verify = false end on :message, /^!spam (\d+)/ do |m, count| if queue.empty? count.to_i.times do |i| queue << i end prev_item = queue.pop # This kicks off the chain reaction m.reply prev_item end end on :message do |m| debug "#{m.bot.nick}: '#{m.message}' =/= '#{prev_item}' and queue empty: #{queue.empty?}'" if m.message == prev_item.to_s if queue.empty? prev_item = nil else sleep(throttle) prev_item = queue.pop m.reply prev_item end end end end bot.start end end @bots.each(&:join)