Marvin is a plugin/gem to easily host your own Jabber Chat bot. It uses XMPP4R library internally.
Download the latest code from github. gem build marvin.gemspec gem install marvin
To create a keyword for the bot, generate a new class, and just include Marvin::Handler. Add the command regex, syntax and the description ( these will be used by help command to generate a list of all keywords ). Add the handle method, which will be called if the incoming body matches the regex. Example -
require ‘rubygems’ require ‘marvin’ class SomeKeyword include Marvin::Handler
command :regex => /keyword/, :syntax => “keyword”, :description => “Does nothing”
def handle(from, body, bot) # from - is the Jabbed User_Id from where the message came # body - is the body of the message # bot - is the object, which can be used to reply to the user.
# do something here puts “I m doing nothing” bot.reply( from, “I have done nothing”) end end
To start the bot,
bot = Marvin::Android.new(“[email protected]”, “password”) bot.listen
This will start listening for the incoming messages and handle them.
Check basic.rb in examples folder to see the usage.
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2011 Vinkesh. See LICENSE.txt for further details.