forked from cinchrb/cinch
/
partyline_test.rb
executable file
·81 lines (53 loc) · 1.66 KB
/
partyline_test.rb
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env ruby
$:.unshift File.expand_path('../../../lib', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'cinch'
class PartyLineTestA
include Cinch::Plugin
set :prefix, %r{\A(?:!|gertrude,\s*)}
set :suffix, %r{\??\Z}
match %r{what\s+is\s+(\S+)}, react_on: :message, method: :what
def what(m, x)
if ret = [true, false].sample
m.reply("#{self.class} has no idea what #{x} is")
end
ret
end
end
class PartyLineTestB
include Cinch::Plugin
set :prefix, %r{\A(?:!|gertrude,\s*)}
set :suffix, %r{\??\Z}
match %r{what\s+is\s+(\S+)}, react_on: :message, method: :what
def what(m, x)
if ret = [true, false].sample
m.reply("#{self.class} has no idea what #{x} is either")
end
ret
end
end
class PartyLineTestC
include Cinch::Plugin
set :prefix, %r{\A(?:!|gertrude,\s*)}
set :suffix, %r{\??\Z}
match %r{what\s+is\s+(\S+)}, react_on: :message, method: :what
def what(m, x)
if ret = [true, false].sample
m.reply("finally, #{self.class} has zero clue about #{x}")
end
ret
end
end
# Illustrates that PartyLineTest[ABC] are all proper plugin citizens, they can
# be executed directly as cinch plugins without using the PartyLine proxy.
if __FILE__ == $0
bot = Cinch::Bot.new do
configure do |c|
c.nicks = [ 'gertrude', 'gert', 'gertie', 'gerters', 'ermintrude']
c.server = "irc.z.je"
c.channels = ["#gertrude"]
c.plugins.plugins = [PartyLineTestA, PartyLineTestB, PartyLineTestC]
end
end
bot.start
end