Send presence requests
This commit is contained in:
parent
8b6a12c798
commit
85c320e24c
14
session.py
14
session.py
|
@ -175,7 +175,7 @@ class Session():
|
|||
buddy = sender
|
||||
if message == "\\lastseen":
|
||||
self.presenceRequested.append(buddy)
|
||||
self.call("presence_request", (buddy + "@s.whatsapp.net",))
|
||||
self.call("presence_request", buddy = (buddy + "@s.whatsapp.net",))
|
||||
else:
|
||||
self.call("message_send", to=buddy + "@s.whatsapp.net", message=message)
|
||||
|
||||
|
@ -260,11 +260,6 @@ class Session():
|
|||
else:
|
||||
self.logger.warn("Room doesn't exist: %s", room)
|
||||
|
||||
def onDisconnected(self, reason):
|
||||
self.logger.info("Disconnected from whatsapp: %s (%s)", self.legacyName, reason)
|
||||
self.backend.handleDisconnected(self.user, 0, reason)
|
||||
|
||||
|
||||
def onMediaReceived(self, messageId, jid, preview, url, size, receiptRequested, isBroadcast):
|
||||
buddy = jid.split("@")[0]
|
||||
|
||||
|
@ -434,7 +429,7 @@ class SpectrumLayer(YowInterfaceLayer):
|
|||
elif layerEvent.getName() == YowNetworkLayer.EVENT_STATE_DISCONNECTED:
|
||||
reason = layerEvent.getArg("reason")
|
||||
self.logger.info("Disconnected: %s (%s)", self.user, reason)
|
||||
self.backend.handleDisconnected(sefl.user, 0, reason)
|
||||
self.backend.handleDisconnected(self.user, 0, reason)
|
||||
elif layerEvent.getName() == 'presence_sendAvailable':
|
||||
entity = AvailablePresenceProtocolEntity()
|
||||
self.toLower(entity)
|
||||
|
@ -467,10 +462,15 @@ class SpectrumLayer(YowInterfaceLayer):
|
|||
)
|
||||
self.toLower(state)
|
||||
retval = True
|
||||
elif layerEvent.getName() == 'presence_request':
|
||||
buddy = layerEvent.getArg('buddy')
|
||||
sub = SubscribePresenceProtocolEntity(buddy)
|
||||
self.toLower(sub)
|
||||
|
||||
self.logger.debug("EVENT %s", layerEvent.getName())
|
||||
return retval
|
||||
|
||||
|
||||
@ProtocolEntityCallback("success")
|
||||
def onAuthSuccess(self, entity):
|
||||
self.logger.info("Auth success: %s", self.user)
|
||||
|
|
Loading…
Reference in a new issue