Skip to content

trojanski/jabber-mucbot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jabber::MUCBot

Easily create simple regex powered Jabber Multi Users Chat bots.

This bot has been forked from Brett Stimmerman’s Jabber::Bot. The purpose is to create an even simpler MUC bot. It will be able to join a room and execute public command.

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

Author

Brett Stimmerman (brettstimmerman@gmail.com)

Author

Vivien Didelot (vivien.didelot@gmail.com)

Version

0.0.1

Copyright

Copyright © 2009 Brett Stimmerman. All rights reserved.

License

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

Website

github.com/v0n/jabber-mucbot

Requires

  • rubygems

  • xmpp4r

Usage

require 'rubygems'
require 'jabber/mucbot'

# Create a public Jabber::MUCBot
config = {
  :nick      => 'bot',
  :password  => 'secret',
  :server    => 'example.org',
  :room       => 'room',
  :roompasswd => ''
}

bot = Jabber::MUCBot.new(config)

# Give your bot a command, 'rand'
bot.add_command(/^rand$/) { rand(10).to_s }

# Give your bot a command, 'puts <string>'
bot.add_command(/^puts\s+.+$/) do |sender, message|
  puts "#{sender} says '#{message}'"
  "'#{message}' written to $stdout"
end

# Add a custome welcome message
bot.welcome { |guy| "Hello #{guy}!" }

# Bring your new bot to life
bot.join

All that can be done faster with the class method start.

Jabber::MUCBot.start config do |bot|
  bot.on(/^rand$/) { rand(10).to_s }
  bot.on(/^puts\s+.+$/) do |sender, message|
    puts "#{sender} says '#{message}'"
    "'#{message}' written to $stdout"
  end
  bot.welcome { |guy| "Hello #{guy}!" }
end

About

Easily create simple regex powered Jabber MUC bots.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%