yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

How to get a list of groups?

Open atans opened this issue 13 years ago • 3 comments

Is there has any method to get a list of groups. Thanks a lot.

atans avatar Mar 06 '13 08:03 atans

No, but I pulled this code from WhatsApiNet, I'm not home right now so I can't test it:

public void SendGetGroups(Action onSuccess, Action<int> onError)
    {
        string id = TicketCounter.MakeId("get_groups_");
        this.SendGetGroups(id, "participating");
    }

public void SendGetOwningGroups()
    {
        string id = TicketCounter.MakeId("get_owning_groups_");
        this.SendGetGroups(id, "owning");
    }

internal void SendGetGroups(string id, string type)
    {
        var child = new ProtocolTreeNode("list", new[] { new KeyValue("xmlns", "w:g"), new KeyValue("type", type) });
        var  node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "get"), new KeyValue("to", "g.us") }, child);
        this.whatsNetwork.SendData(this._binWriter.Write(node));
    }

resulting in these nodes: get groups:

<iq id="get_groups_[generated incremental ID]" type="get" to="g.us"> 
    <list xmlns="w:g" type="participating">
</iq>

get owning groups:

<iq id="get_owning_groups_[generated incremental ID]" type="get" to="g.us"> 
    <list xmlns="w:g" type="owning">
</iq>

shirioko avatar Mar 06 '13 09:03 shirioko

def sendGetGroups(self,gtype):
    self._d("getting groups %s"%(gtype))
    idx = self.makeId("get_groups_")
    self.readerThread.requests[idx] = self.readerThread.parseGroups;

    queryNode = ProtocolTreeNode("list",{"xmlns":"w:g","type":gtype})
    iqNode = ProtocolTreeNode("iq",{"id":idx,"type":"get","to":"g.us"},[queryNode])

    self._writeNode(iqNode)

https://github.com/tgalal/yowsup/blob/master/src/Yowsup/connectionmanager.py#L489

@shirioko Thanks

I find a method of yowsup, Is this right?

sendGetGroups('owning');

atans avatar Mar 06 '13 12:03 atans

Give it a try, it's not in the wiki :)

shirioko avatar Mar 06 '13 16:03 shirioko