Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Easily create simple regex powered Jabber bots.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 sample
Octocat-spinner-32 HISTORY
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 jabber-bot.gemspec
README.rdoc

Jabber::Bot

Easily create simple regex powered Jabber bots.

Jabber::Bot makes it simple to create and command your own Jabber bot. Bots are created by defining commands powered by regular expressions and Ruby.

Author

Brett Stimmerman (brettstimmerman@gmail.com)

Version

1.1.1

Copyright

Copyright © 2009 Brett Stimmerman. All rights reserved.

License

New BSD License (opensource.org/licenses/bsd-license.php)

Website

github.com/brettstimmerman/jabber-bot

Requires

  • RubyGems

  • Jabber::Simple 0.8.7+

Usage

require 'rubygems'
require 'jabber/bot'

# Create a public Jabber::Bot
config = {
  :name      => 'SampleBot',
  :jabber_id => 'bot@example.com',
  :password  => 'secret',
  :master    => 'master@example.com',
  :is_public => true
}

bot = Jabber::Bot.new(config)

# Give your bot a private command, 'rand'
bot.add_command(
  :syntax      => 'rand',
  :description => 'Produce a random number from 0 to 10',
  :regex       => /^rand$/
) { rand(10).to_s }

# Give your bot a public command, 'puts <string>' with an alias 'p <string>'
bot.add_command(
  :syntax      => 'puts <string>',
  :description => 'Write something to $stdout',
  :regex       => /^puts\s+.+$/,
  :alias       => [ :alias => 'p <string>', :regex => /^p\s+.+$/ ],
  :is_public   => true
) do |sender, message|
  puts "#{sender} says '#{message}'"
  "'#{message}' written to $stdout"
end

# Bring your new bot to life
bot.connect
Something went wrong with that request. Please try again.