Discussion:
subscribed? is false after adding
Daniel Aquino
2010-07-25 06:30:58 UTC
Permalink
I can't seem to get my self subscribed which I believe is causing my
messages to never make it across..

when i login to gmail I can see that indeed the user is not added to my
list.

my code is very basic at this moment and is shown bellow.

one of the first things I do is $im.add($master) which is my main account
that I will interface with the bot from.

Thanks for this excellent api ! :]


#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r-simple'
## settings
$master = ""
$login = ""
$passwd = ""
$status = ""
## init
Jabber::debug = true
begin
$im = Jabber::Simple.new $login, $passwd
rescue Jabber::ClientAuthenticationFailure
puts "authentication failed"
exit 1
end
$im.status :chat, $status
$im.accept_subscriptions = true
$im.add $master
$im.deliver $master, "I woke up at #{Time.now}"
## main loop
loop do
begin
$im.presence_updates {|friend, status, message|
puts "#{friend} is #{status}: #{message}"
}
$im.received_messages{|msg|
next unless msg.type == :chat
from = msg.from.strip.to_s
body = msg.body
puts "#{from} > #{body}"
puts "#{from} info subscribed? #{$im.subscribed_to?(from)}"
$im.deliver from, body
}
rescue Exception => e
error "error = #{e}"
end
sleep 1
end

Loading...