Drivel
An alternative DSL utilizing the excellent XMPP library, Blather, for creating interactive XMPP bots.
Installation
Add this line to your application's Gemfile:
gem 'drivel'
And then execute:
$ bundle
Or install it yourself as:
$ gem install drivel
Usage
TBD.
Example
#!/usr/bin/env ruby
require 'drivel'
configure do
# Do basic setup/configuration.
set nickname: 'DrivelBot', jid: '[email protected]/resource', password: 'secretpassword'
# (Optional) conferences to discover and join.
set :conferences, 'main', 'offtopic'
end
helpers do
def (context)
context.chat? and .from == '[email protected]'
end
end
connected do
status :available, 'At your service.'
end
disconnected do
status :offline, 'Going away now.' and shutdown
end
subscription do ||
# Handle subscription messages like Blather would.
end
command 'ping' do ||
respond , 'pong'
end
command 'join :conference' do |, params|
respond , "I'm afraid I can't do that." and halt unless ()
join params[:conference]
end
command 'leave :conference' do |, params|
respond , "I'm afraid I can't do that." and halt unless ()
leave params[:conference]
end
recognize 'What is love?' do ||
respond , "Baby don't hurt me no more."
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request