Changeset 31e2b09
- Timestamp:
- 2015-06-23T00:15:19Z (10 years ago)
- Children:
- 9076a1c
- Parents:
- 15c3a6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/wa.py
r15c3a6b r31e2b09 199 199 if isinstance(entity, ResultSyncIqProtocolEntity): 200 200 return self.onSyncResult(entity) 201 elif isinstance(entity, ListParticipantsResultIqProtocolEntity):202 return self.b.chat_join_participants(entity)203 201 elif isinstance(entity, ListGroupsResultIqProtocolEntity): 204 202 return self.onListGroupsResult(entity) 205 elif "ping" in self.todo: # Pong has no type, sigh. 206 if "contacts" in self.todo: 207 # Shitty Whatsapp rejected the sync request, and 208 # annoying Yowsup doesn't inform on error responses. 209 # So instead, if we received no response to it but 210 # did get our ping back, declare failure. 211 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") 216 self.check_connected("ping") 203 elif type(entity) == IqProtocolEntity: # Pong has no type, sigh. 204 self.b.last_pong = time.time() 205 if self.todo: 206 return self.onLoginPong() 217 207 218 208 def onSyncResult(self, entity): … … 248 238 jid += "@g.us" 249 239 group = self.b.groups[jid] 240 try: 241 group["participants"] = g.getParticipants().keys() 242 except AttributeError: 243 # Depends on a change I made to yowsup that may 244 # or may not get merged.. 245 group["participants"] = [] 250 246 251 247 # Save it. We're going to mix ListGroups elements and … … 256 252 257 253 self.check_connected("groups") 254 255 def onLoginPong(self): 256 if "contacts" in self.todo: 257 # Shitty Whatsapp rejected the sync request, and 258 # annoying Yowsup doesn't inform on error responses. 259 # So instead, if we received no response to it but 260 # did get our ping back, declare failure. 261 self.onSyncResultFail() 262 if "groups" in self.todo: 263 # Well fuck this. Just reject ALL the things! 264 # Maybe I don't need this one then. 265 self.check_connected("groups") 266 self.check_connected("ping") 258 267 259 268 def getStatuses(self, contacts): … … 328 337 # TODO: HANDLE_DOMAIN in right place (add ... ... nick bug) 329 338 PING_INTERVAL = 299 # seconds 339 PING_TIMEOUT = 360 # seconds 330 340 331 341 def login(self, account): … … 340 350 341 351 self.next_ping = None 352 self.last_pong = time.time() 342 353 343 354 def keepalive(self): 355 if (time.time() - self.last_pong) > self.PING_TIMEOUT: 356 self.error("Ping timeout") 357 self.logout(True) 358 return 344 359 if self.next_ping and (time.time() < self.next_ping): 345 360 return … … 394 409 395 410 # So for now do without a participant list.. 396 #self.chat_join_participants(None)411 self.chat_join_participants(group) 397 412 self.chat_send_backlog(group) 398 413 399 def chat_join_participants(self, entity): 400 """ 401 group = self.groups[entity.getFrom()] 402 id = group["id"] 403 for p in entity.getParticipants(): 414 def chat_join_participants(self, group): 415 for p in group.get("participants", []): 404 416 if p != self.account["user"]: 405 self.bee.chat_add_buddy(id, p) 406 """ 417 self.bee.chat_add_buddy(group["id"], p) 407 418 408 419 def chat_send_backlog(self, group):
Note: See TracChangeset
for help on using the changeset viewer.