Changeset 15c3a6b for python/wa.py


Ignore:
Timestamp:
2015-06-22T09:24:59Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
31e2b09
Parents:
ed83279
Message:

Stop trying to get group participants list because WA/YS broke it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/wa.py

    red83279 r15c3a6b  
    5050import implugin
    5151
    52 logger = logging.getLogger("yowsup.layers.network.layer")
     52logger = logging.getLogger("yowsup.layers.logger.layer")
    5353logger.setLevel(logging.DEBUG)
    5454ch = logging.StreamHandler()
     
    5959TODO/Things I'm unhappy about:
    6060
     61About the fact that WhatsApp is a rubbish protocol that happily rejects
     62every second stanza you send it if you're trying to implement a client that
     63doesn't keep local state. See how to cope with that.. It'd help if Yowsup
     64came with docs on what a normal login sequence looks like instead of just
     65throwing some stanzas over a wall but hey.
     66
    6167The randomness of where which bits/state live, in the implugin and the
    6268yowsup layer. Can't really merge this but at least state should live in
     
    7278And more. But let's first get this into a state where it even works..
    7379"""
    74 
    75 # Tried this but yowsup is not passing back the result, will have to update the library. :-(
    76 class GetStatusIqProtocolEntity(IqProtocolEntity):
    77         def __init__(self, jids=None):
    78                 super(GetStatusIqProtocolEntity, self).__init__("status", None, _type="get", to="s.whatsapp.net")
    79                 self.jids = jids or []
    80 
    81         def toProtocolTreeNode(self):
    82                 from yowsup.structs import ProtocolTreeNode
    83                
    84                 node = super(GetStatusIqProtocolEntity, self).toProtocolTreeNode()
    85                 sr = ProtocolTreeNode("status")
    86                 node.addChild(sr)
    87                 for jid in self.jids:
    88                         sr.addChild(ProtocolTreeNode("user", {"jid": jid}))
    89                 return node
    90 
    9180
    9281class BitlBeeLayer(YowInterfaceLayer):
     
    221210                                # did get our ping back, declare failure.
    222211                                self.onSyncResultFail()
     212                        if "groups" in self.todo:
     213                                # Well fuck this. Just reject ALL the things!
     214                                # Maybe I don't need this one then.
     215                                self.check_connected("groups")
    223216                        self.check_connected("ping")
    224217       
     
    397390                # basic info but not yet a member list) and ACK the join
    398391                # once that's done.
    399                 self.yow.Ship(ParticipantsGroupsIqProtocolEntity(name))
     392                # Well except that WA/YS killed this one. \o/
     393                #self.yow.Ship(ParticipantsGroupsIqProtocolEntity(name))
     394               
     395                # So for now do without a participant list..
     396                #self.chat_join_participants(None)
     397                self.chat_send_backlog(group)
    400398
    401399        def chat_join_participants(self, entity):
     400                """
    402401                group = self.groups[entity.getFrom()]
    403402                id = group["id"]
     
    405404                        if p != self.account["user"]:
    406405                                self.bee.chat_add_buddy(id, p)
    407 
     406                """
     407
     408        def chat_send_backlog(self, group):
    408409                # Add the user themselves last to avoid a visible join flood.
    409                 self.bee.chat_add_buddy(id, self.account["user"])
     410                self.bee.chat_add_buddy(group["id"], self.account["user"])
    410411                for msg in group.setdefault("queue", []):
    411412                        self.b.show_message(msg)
     
    465466                        group = self.groups[msg.getFrom()]
    466467                        if "id" in group:
     468                                self.bee.chat_add_buddy(group["id"], msg.getParticipant())
    467469                                self.bee.chat_msg(group["id"], msg.getParticipant(), text, 0, msg.getTimestamp())
    468470                        else:
Note: See TracChangeset for help on using the changeset viewer.