1

Ruby スクリプトから Google トークのプレゼンス (つまり、ステータスと空き状況) を設定できるようにしたいと考えています。xmpp4r を使用して動作させることができないようです。Google トークがこの 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')
4

1 に答える 1

0

通常の xmpp4r ライブラリを使用している場合:

クライアントは「プレゼンス」スタンザを送信する必要があります。

@cl.send(Jabber::Presence.new.set_type(':available'))
于 2013-05-09T15:19:11.693 に答える