- Timestamp:
- 2015-05-21T11:43:42Z (10 years ago)
- Children:
- cb1b973
- Parents:
- b09ce17
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/wa.py
rb09ce17 r433c90b 114 114 if not group: 115 115 self.cb.log("Warning: Activity in room %s" % msg.getFrom()) 116 self.b.groups.setdefault(msg.getFrom(), {}).setdefault("queue", []).append(msg) 116 117 return 117 118 self.cb.chat_msg(group["id"], msg.getParticipant(), msg.getBody(), 0, msg.getTimestamp()) … … 121 122 @ProtocolEntityCallback("receipt") 122 123 def onReceipt(self, entity): 123 print "ACK THE ACK!"124 124 ack = OutgoingAckProtocolEntity(entity.getId(), entity.getTag(), 125 125 entity.getType(), entity.getFrom()) … … 129 129 def onIq(self, entity): 130 130 if isinstance(entity, ResultSyncIqProtocolEntity): 131 print "XXX SYNC RESULT RECEIVED!" 131 132 return self.onSyncResult(entity) 133 elif isinstance(entity, ListParticipantsResultIqProtocolEntity): 134 return self.b.chat_join_participants(entity) 132 135 133 136 def onSyncResult(self, entity): 134 # TODO HERE AND ELSEWHERE: Threa tidiocy happens when going137 # TODO HERE AND ELSEWHERE: Thread idiocy happens when going 135 138 # from here to the IMPlugin. Check how bjsonrpc lets me solve that. 136 ok = set( num.lstrip("+") for num in entity.inNumbers)139 ok = set(jid.lower() for jid in entity.inNumbers.values()) 137 140 for handle in self.b.contacts: 138 if handle. split("@")[0]in ok:141 if handle.lower() in ok: 139 142 self.toLower(SubscribePresenceProtocolEntity(handle)) 140 143 self.cb.add_buddy(handle, "") 141 144 if entity.outNumbers: 142 self.cb.error("Not on WhatsApp: %s" % ", ".join(entity.outNumbers)) 145 self.cb.error("Not on WhatsApp: %s" % 146 ", ".join(entity.outNumbers.keys())) 143 147 if entity.invalidNumbers: 144 self.cb.error("Invalid numbers: %s" % ", ".join(entity.invalidNumbers)) 148 self.cb.error("Invalid numbers: %s" % 149 ", ".join(entity.invalidNumbers.keys())) 145 150 146 151 @ProtocolEntityCallback("notification") … … 258 263 def chat_join(self, id, name, _nick, _password, settings): 259 264 print "New chat created with id: %d" % id 260 self.groups [name] = {"id": id, "name": name}265 self.groups.setdefault(name, {}).update({"id": id, "name": name}) 261 266 self.groups_by_id[id] = self.groups[name] 267 self.yow.Ship(ParticipantsGroupsIqProtocolEntity(name)) 268 269 for msg in self.groups[name].get("queue", []): 270 self.cb.chat_msg(group["id"], msg.getParticipant(), msg.getBody(), 0, msg.getTimestamp()) 271 272 def chat_join_participants(self, entity): 273 group = self.groups[entity.getFrom()] 274 id = group["id"] 275 for p in entity.getParticipants(): 276 if p != self.account["user"]: 277 self.bee.chat_add_buddy(id, p) 278 # Add the user themselves last to avoid a visible join flood. 262 279 self.bee.chat_add_buddy(id, self.account["user"]) 263 280
Note: See TracChangeset
for help on using the changeset viewer.