Jabber::Bot

Easily create powerful Jabber bots to do your bidding.

Jabber::Bot makes it simple to create and command your own Jabber bot with little fuss. By adding custom commands powered by regular expressions to your bot’s repertoire, you and your new bot will be able to accomplish nearly anything.

Author

Brett Stimmerman ([email protected])

Version

1.0.1

Copyright

Copyright © 2007 Brett Stimmerman. All rights reserved.

License

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

Website

socket7.net/software/jabber-bot

Dependencies

Basic Usage

# Create a public Jabber::Bot to do your bidding
bot_config = {
  :jabber_id => '[email protected]',
  :password  => 'password',
  :master    => '[email protected]',
  :is_public => true
}
bot = Jabber::Bot.new(bot_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+.+$/,
  :aliases     => [ :alias => 'p <string>', :regex => /^p\s+.+$/ ],
  :is_public   => true
) do |message|
  puts message
  "'#{message}' written to $stdout"
end

# Bring your new bot to life
bot.connect