Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple demo script for creating an XMPP bot wiht Ruby
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bot
.gitignore
im.rb
readme.md

readme.md

Gtalk Bot

This is a simple script demonstrating how to create a basic XMPP bot in Ruby.

The bot will authenticate to Gtalk, automatically accept any incoming “add contact” requests, and echo received messages back to the user — totally useless, but functional.

I've also included a little script to daemonize the bot using the Ruby Daemons gem.

Setup

Open ./bot/gtalk-bot.rb and set your username and password - this could easily be abstracted out into a config file if desired.

If you wish to enable logging, open ./im.rb and change :log_output to true.

Usage

Running the bot as a daemon is pretty straightforward:

ruby im.rb start     # starts the bot
ruby im.rb restart   # restarts the bot
ruby im.rb stop      # stop the bot

To run the bot as a background process using Screen:

screen -dmS myGtalkBot ruby ./bot/gtalk-bot.rb

Or simply run the script from the command line (good for testing):

ruby ./bot/gtalk-bot.rb

or

ruby ./bot/gtalk-bot.rb &    # start the bot in the background
Something went wrong with that request. Please try again.