# The MIT License # # Copyright (c) 2008 Jared Kuolt # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # Version: 0.1, Feb 5 2008 require 'rubygems' require 'tinder' require 'xmpp4r-simple' require 'daemons' deliver_to = 'me@example.com' rooms = [ { :jabber => {:user => 'myoffice@example.com',:pass => 'mypassword'}, :campfire => {:user => 'user@example.com', :pass => 'anotherpassword', :room => "Chat Room", :domain => 'example', :ssl => true} }, ] rooms.each do |room| Daemons.run_proc(room[:campfire][:room]) do im = Jabber::Simple.new(room[:jabber][:user], room[:jabber][:pass]) campfire = Tinder::Campfire.new room[:campfire][:domain], :ssl => room[:campfire][:ssl] campfire.login room[:campfire][:user], room[:campfire][:pass] chat = campfire.find_room_by_name room[:campfire][:room] while true chat.listen.each do |msg| text = "#{msg[:person]}: #{msg[:message]}".gsub(/(\\n)+/, "\n").gsub(/\\u003C(.+?)\\u003E/, '') im.deliver(deliver_to, text) if msg[:person].to_s != '' end im.received_messages { |msg| chat.speak msg.body if msg.type == :chat } sleep 2 end end end