Code Monkey home page Code Monkey logo

jabber-bot's Introduction

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 ([email protected])

Version

1.3.0 (2011-05-15)

Copyright

Copyright © 2011 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 => '[email protected]',
  :password  => 'secret',
  :master    => '[email protected]',
  :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       => [ :syntax => '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

jabber-bot's People

Contributors

brettstimmerman avatar lucaswilric avatar nstielau avatar phinze avatar vivien avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.