yowsup
yowsup copied to clipboard
How to get a list of groups?
Is there has any method to get a list of groups. Thanks a lot.
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>
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');
Give it a try, it's not in the wiki :)