我希望能够通过 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')