我希望能够通过ruby脚本为我的Google Talk设置我的状态(即状态和可用性)。我似乎无法使用xmpp4r使其工作。我认为可能是google talk不再通过这个xml协议设置存在(即存在标记),和/或我需要使用xmpp4r附带的pubsub库。很多帮助非常感谢!到目前为止我的代码:
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')
答案 0 :(得分:0)
如果您使用的是常规xmpp4r库:
您的客户必须发送“状态”节:
@cl.send(Jabber::Presence.new.set_type(':available'))