summaryrefslogtreecommitdiff
path: root/example.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-08-17 23:31:45 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-08-17 23:31:45 -0700
commite633d656e00fdac51f077eff827518848235e916 (patch)
tree0b40a60f95b219545d40fe709e11583ab9e3df6b /example.rb
downloadbocelli-e633d656e00fdac51f077eff827518848235e916.tar.gz
bocelli-e633d656e00fdac51f077eff827518848235e916.tar.xz
Initial commit.
Diffstat (limited to 'example.rb')
-rw-r--r--example.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/example.rb b/example.rb
new file mode 100644
index 0000000..cd09859
--- /dev/null
+++ b/example.rb
@@ -0,0 +1,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