blob: e07eab39ff3f534bf0e69657d9734f4acd310601 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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)
|