Home

Awesome

xmpp4r-robot Build Status

by Lin Jen-Shin (godfat)

LINKS:

DESCRIPTION:

Simple XMPP client built upon xmpp4r. Intended for building simple robots.

WHY?

XMPP is such a beast and therefore xmpp4r is quite complex and hard to use for some simple scenario where we merely want to write some XMPP robots. This is an attempt to make it easy for such use cases.

REQUIREMENTS:

INSTALLATION:

gem install xmpp4r-robot

SYNOPSIS:

require 'xmpp4r/robot'

robot = Jabber::Robot.new('someone@gmail.com', 'awesome password',
                          :auto_accept_subscription => true).start

robot.notify_presence do |from, status|
  # status could be one of :available, :away, :unavailable
  puts "#{from} is #{status}"
end

robot.notify_message do |from, body|
  puts "#{from} said: #{body}"
  robot.message(from, "#{from} just told me: #{body}") # echo back

  robot.subscribe(from) if body == 'subscribe' # demonstrate how we subscribe
end

p robot.roster

rd, wr = IO.pipe
Signal.trap('INT'){ wr.puts }
rd.gets

robot.stop

NOTES:

CONTRIBUTORS:

LICENSE:

Apache License 2.0

Copyright (c) 2014-2017, Lin Jen-Shin (godfat)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.