summaryrefslogtreecommitdiff
path: root/example.rb
blob: cd09859c7a7b99a5908c8319367d49fd0398b85a (plain) (blame)
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
require_relative 'bocelli'

module Bocelli::Module::Foo
  extend Bocelli::Module::Base

  on 'test' do
    out 'this is a test!'
  end

  on /^foo/ do
    out 'foo' * (rand(5) + 1)
  end
end

module Bocelli::Module::Bar
  extend Bocelli::Module::Base

  on /^bar+$/ do
    out 'bar' * (rand(5) + 1)
  end

  on /^baz+$/i do
    out 'baz' * (rand(5) + 1)
  end
end

class TestBot < Bocelli::Base
  register Bocelli::Module::Foo
  register Bocelli::Module::Bar

  on 'rand' do
    out rand(100)
  end

  on 'current' do
    out '%s %s' % [@bocelli[:str].inspect, @bocelli[:route].inspect]
  end
end

TestBot.configure('chat.freenode.net', 6667, 'bocelli%03d' % rand(1000))
TestBot.connect do
  join '##omp'
end

TestBot.run