Adding a route dynamically to xmpp-agent

Here's how to add a new message route to allow the xmpp bot to respond with the message 'hello you' when it receives the message 'hi'.

require 'xmpp-agent'

xa = XMPPAgent.new
xa.add_route ('hi') {|params, messenger, msg| messenger.deliver(msg.from, "hello you")}
xa.run('switchboard@rorbuilder.info', 'secretpassword')

Note: The routes (similar to Sinatra routes) can accept a regular expression or a string.

Tags:
Source:
2159hrs.txt
Published:
22-05-2012 21:59