Fix status message
This commit is contained in:
parent
4c365e3f81
commit
d2efa0dd7b
52
session.py
52
session.py
|
@ -27,50 +27,6 @@ import logging
|
||||||
import urllib
|
import urllib
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from yowsup.stacks import YowStack
|
|
||||||
from yowsup.layers import YowLayerEvent, YowParallelLayer
|
|
||||||
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
|
|
||||||
from yowsup.layers.axolotl import YowAxolotlLayer
|
|
||||||
from yowsup.layers.auth import (YowCryptLayer, YowAuthenticationProtocolLayer,
|
|
||||||
AuthError)
|
|
||||||
from yowsup.layers.protocol_iq import YowIqProtocolLayer
|
|
||||||
from yowsup.layers.protocol_groups import YowGroupsProtocolLayer
|
|
||||||
from yowsup.layers.coder import YowCoderLayer
|
|
||||||
from yowsup.layers.network import YowNetworkLayer
|
|
||||||
from yowsup.layers.protocol_messages import YowMessagesProtocolLayer
|
|
||||||
from yowsup.layers.protocol_media import YowMediaProtocolLayer
|
|
||||||
from yowsup.layers.stanzaregulator import YowStanzaRegulator
|
|
||||||
from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer
|
|
||||||
from yowsup.layers.protocol_acks import YowAckProtocolLayer
|
|
||||||
from yowsup.layers.logger import YowLoggerLayer
|
|
||||||
from yowsup.common import YowConstants
|
|
||||||
from yowsup.layers.protocol_receipts.protocolentities import *
|
|
||||||
from yowsup import env
|
|
||||||
from yowsup.layers.protocol_presence import *
|
|
||||||
from yowsup.layers.protocol_presence.protocolentities import *
|
|
||||||
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
|
|
||||||
from yowsup.layers.protocol_chatstate.protocolentities import *
|
|
||||||
from yowsup.layers.protocol_acks.protocolentities import *
|
|
||||||
from yowsup.layers import YowLayer
|
|
||||||
from yowsup.layers.auth import YowCryptLayer, YowAuthenticationProtocolLayer
|
|
||||||
from yowsup.layers.coder import YowCoderLayer
|
|
||||||
from yowsup.layers.logger import YowLoggerLayer
|
|
||||||
from yowsup.layers.network import YowNetworkLayer
|
|
||||||
from yowsup.layers.protocol_messages import YowMessagesProtocolLayer
|
|
||||||
from yowsup.layers.stanzaregulator import YowStanzaRegulator
|
|
||||||
from yowsup.layers.protocol_media import YowMediaProtocolLayer
|
|
||||||
from yowsup.layers.protocol_acks import YowAckProtocolLayer
|
|
||||||
from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer
|
|
||||||
from yowsup.layers.protocol_groups import YowGroupsProtocolLayer
|
|
||||||
from yowsup.layers.protocol_presence import YowPresenceProtocolLayer
|
|
||||||
from yowsup.layers.protocol_ib import YowIbProtocolLayer
|
|
||||||
from yowsup.layers.protocol_notifications import YowNotificationsProtocolLayer
|
|
||||||
from yowsup.layers.protocol_iq import YowIqProtocolLayer
|
|
||||||
from yowsup.layers.protocol_contacts import YowContactsIqProtocolLayer
|
|
||||||
from yowsup.layers.protocol_chatstate import YowChatstateProtocolLayer
|
|
||||||
from yowsup.layers.protocol_privacy import YowPrivacyProtocolLayer
|
|
||||||
from yowsup.layers.protocol_profiles import YowProfilesProtocolLayer
|
|
||||||
from yowsup.layers.protocol_calls import YowCallsProtocolLayer
|
|
||||||
from Spectrum2 import protocol_pb2
|
from Spectrum2 import protocol_pb2
|
||||||
|
|
||||||
from buddy import BuddyList
|
from buddy import BuddyList
|
||||||
|
@ -436,13 +392,7 @@ class Session(YowsupApp):
|
||||||
else:
|
else:
|
||||||
self.logger.warn("Room doesn't exist: %s", room)
|
self.logger.warn("Room doesn't exist: %s", room)
|
||||||
|
|
||||||
def onMediaReceived(self, messageId, jid, preview, url, size, receiptRequested, isBroadcast):
|
# Not used
|
||||||
buddy = jid.split("@")[0]
|
|
||||||
|
|
||||||
self.logger.info("Media received from %s: %s", buddy, url)
|
|
||||||
self.sendMessageToXMPP(buddy, utils.shorten(url))
|
|
||||||
if receiptRequested: self.call("message_ack", (jid, messageId))
|
|
||||||
|
|
||||||
def onLocationReceived(self, messageId, jid, name, preview, latitude, longitude, receiptRequested, isBroadcast):
|
def onLocationReceived(self, messageId, jid, name, preview, latitude, longitude, receiptRequested, isBroadcast):
|
||||||
buddy = jid.split("@")[0]
|
buddy = jid.split("@")[0]
|
||||||
self.logger.info("Location received from %s: %s, %s", buddy, latitude, longitude)
|
self.logger.info("Location received from %s: %s, %s", buddy, latitude, longitude)
|
||||||
|
|
|
@ -35,6 +35,7 @@ from yowsup.layers.protocol_media.protocolentities import *
|
||||||
from yowsup.layers.protocol_chatstate.protocolentities import *
|
from yowsup.layers.protocol_chatstate.protocolentities import *
|
||||||
from yowsup.layers.protocol_acks.protocolentities import *
|
from yowsup.layers.protocol_acks.protocolentities import *
|
||||||
from yowsup.layers.protocol_receipts.protocolentities import *
|
from yowsup.layers.protocol_receipts.protocolentities import *
|
||||||
|
from yowsup.layers.protocol_profiles.protocolentities import *
|
||||||
|
|
||||||
class YowsupApp(object):
|
class YowsupApp(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -172,8 +173,8 @@ class YowsupApp(object):
|
||||||
Args:
|
Args:
|
||||||
- statusTest: (str) Your whatsapp status
|
- statusTest: (str) Your whatsapp status
|
||||||
"""
|
"""
|
||||||
entity = PresenceProtocolEntity(name = statusText if len(statusText) == 0 else 'this')
|
iq = SetStatusIqProtocolEntity(statusText)
|
||||||
self.sendEntity(entity)
|
self.sendIq(iq)
|
||||||
|
|
||||||
def sendTyping(self, phoneNumber, typing):
|
def sendTyping(self, phoneNumber, typing):
|
||||||
"""
|
"""
|
||||||
|
@ -205,13 +206,8 @@ class YowsupApp(object):
|
||||||
- failure: (func) called when request has failed
|
- failure: (func) called when request has failed
|
||||||
"""
|
"""
|
||||||
iq = LastseenIqProtocolEntity(phoneNumber + '@s.whatsapp.net')
|
iq = LastseenIqProtocolEntity(phoneNumber + '@s.whatsapp.net')
|
||||||
self.stack.broadcastEvent(
|
self.sendIq(iq, self._lastSeenSuccess(success), failure)
|
||||||
YowLayerEvent(YowsupAppLayer.SEND_IQ,
|
|
||||||
iq = iq,
|
|
||||||
success = self._lastSeenSuccess(success),
|
|
||||||
failure = failure,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
def _lastSeenSuccess(self, success):
|
def _lastSeenSuccess(self, success):
|
||||||
def func(response, request):
|
def func(response, request):
|
||||||
success(response._from.split('@')[0], response.seconds)
|
success(response._from.split('@')[0], response.seconds)
|
||||||
|
@ -372,6 +368,16 @@ class YowsupApp(object):
|
||||||
entity = entity
|
entity = entity
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def sendIq(self, iq, onSuccess = None, onError = None):
|
||||||
|
self.stack.broadcastEvent(
|
||||||
|
YowLayerEvent(
|
||||||
|
YowsupAppLayer.SEND_IQ,
|
||||||
|
iq = iq,
|
||||||
|
success = onSuccess,
|
||||||
|
failure = onError,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
|
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
|
||||||
|
|
||||||
class YowsupAppLayer(YowInterfaceLayer):
|
class YowsupAppLayer(YowInterfaceLayer):
|
||||||
|
|
Loading…
Reference in a new issue