tags:

views:

198

answers:

1

I'm writing a XMPP bot in Python (using xmpppy). I want (after user's request) check his PubSub status (mood, tune) and do something with it. How do I do that?

I know how to parse a stanza send by user when he changes status but I don't know how to force him to send me such stanza.

+3  A: 

Read XEP-163. Essentially, you need to implement the send-side of entity caps (XEP-115), so that you send your presence like this:

<presence from='[email protected]/home'>
  <c xmlns='http://jabber.org/protocol/caps' 
     hash='sha-1'
     node='http://example.com/MYBOT'
     ver='/FpawanrJ31ymsv4ApCMGcyJmUk='/>
</presence>

When you get get a disco#info request like this:

<iq to='[email protected]/home'
    id='disco1'
    from='example.net' 
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'
         node='http://example.com/MYBOT#/FpawanrJ31ymsv4ApCMGcyJmUk='/&gt;
</iq>

You respond with the list of features you implement:

<iq from='[email protected]/home'
    id='disco1'
    to='example.net' 
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'
         node='http://example.com/MYBOT#/FpawanrJ31ymsv4ApCMGcyJmUk='&gt;
    <identity category='client' type='bot' name='MYBOT'/>
    <feature var='http://jabber.org/protocol/mood+notify'/&gt;
    <feature var='http://jabber.org/protocol/tune+notify'/&gt;
  </query>
</iq>

Add a +notify to each node name that you want to implicitly subscribe to, and add the resulting string as a feature, as above. Ensuring that the SHA-1 hash in your outbound presence is correct is the only hard part.

Joe Hildebrand
Not exactly what I meant, but your answer pointed me, that what I wanted can't be done ;) and I developed the bot the other way. Thank you.
minder