I want to be able to set my presence (ie status and availability) for my google talk from a ruby script. I can't seem to be able to make it work using xmpp4r. I think it might either be that google talk doesn't set the presence through this xml protocol anymore (that being the presence tag), and/or I need to use the pubsub library included with xmpp4r. Much help is highly appreciated! My code so far:
class Simplified
require 'xmpp4r'
include Jabber
def initialize(usr, pwd, host, rsrc='', port=5222)
@usr = usr
@pwd = pwd
@host = host
@rsrc = rsrc
@port = port
@cl = Client.new(JID.new("#{@usr}/#{@rsrc}"))
@cl.connect(host, port)
@cl.auth(pwd)
end
# :chat, nil, :dnd, :away, :xa, :unavailable, :error
def status(presence, msg)
@presence = presence
@stat_msg = msg
stat_msg = Presence.new.set_show(:chat)
# stat_msg = Presence.new(@presence, @status_message, 24)
send stat_msg
end
def send(msg)
@cl.send(msg)
end
end
usr = 'joeuser@gmail.com'
pwd = 'password'
host = 'talk.google.com'
rsrc = 'test'
me = Simplified.new(usr, pwd, host, rsrc)
me.status(:dnd,'new status')