Sha256: ff60ee0de1a4ed87172e03635ae7794df0cc941dea2981144a27ec4c74d3318d

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

h1. gtalk-bot

A very easy tool for creating Google Talk bots

h2. It's really easy!

h3. Installation

<code>sudo gem install gtalk-bot</code>

h3. Usage

h4. Getting online

<pre>require 'gtalk-bot'

bot = GTalk::Bot.new(:email => "bot@gmail.com", :password => 'getbot')
bot.get_online
</pre>

h4. On invitation

<pre>bot.on_invitation do |inviter|
  puts "I have been invited by #{inviter}. Yay!"

  # do something useful

  bot.accept_invitation(inviter)
  bot.message(inviter, "Hello there! Thanks for invitation!")
end
</pre>

h4. On message

<pre>bot.on_message do |from, text|
  puts "I got message from #{from}: '#{text}'"

  # do something useful

  bot.message from, "I heard that!"
end</pre>

h4. Going infinite

<pre># Don't be confused with the name of this method.
# We actually keep the current (main) thread alive while letting listener thread to do its job.
# So we have no need to set up an any infinite loop.
Thread.stop</pre>

h2. To-do

<code>bot.get_online :invisible => true </code>

<code>bot.set_status :away</code>

<code>GTalk::Account('john.smith@gmail.com').available?</code>

<code>bot.contact_list # => Array</code>

<code>bot.in_contact_list?('john.smith@gmail.com')</code>


Copyright © 2011 Brian Scott, released under the MIT license

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gtalk-bot-1.0.1 README.textile
gtalk-bot-1.0.0 README.textile