Exemplo n.º 1
0
    def __init__(self, credentials, messages, encryptionEnabled=False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (SendLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowAxolotlLayer, YowLoggerLayer,
                      YowCoderLayer, YowCryptLayer, YowStanzaRegulator,
                      YowNetworkLayer)
        else:
            layers = (SendLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)
Exemplo n.º 2
0
    def __init__(self, credentials, contacts, encryptionEnabled=False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (SyncLayer,
                      (YowAuthenticationProtocolLayer,
                       YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowAxolotlLayer, YowLoggerLayer,
                      YowCoderLayer, YowCryptLayer, YowStanzaRegulator,
                      YowNetworkLayer)
        else:
            layers = (SyncLayer,
                      (YowAuthenticationProtocolLayer,
                       YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                           env.CURRENT_ENV.getResource())
Exemplo n.º 3
0
class YowsupSyncStack(object):
    def __init__(self, credentials, contacts, encryptionEnabled=False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (SyncLayer,
                      (YowAuthenticationProtocolLayer,
                       YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowAxolotlLayer, YowLoggerLayer,
                      YowCoderLayer, YowCryptLayer, YowStanzaRegulator,
                      YowNetworkLayer)
        else:
            layers = (SyncLayer,
                      (YowAuthenticationProtocolLayer,
                       YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer), YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(
            YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 4
0
	def __init__(self):
		env.CURRENT_ENV = env.S40YowsupEnv()

		layers = (YowsupAppLayer,
				YowParallelLayer((YowAuthenticationProtocolLayer,
					YowMessagesProtocolLayer,
					YowReceiptProtocolLayer,
					YowAckProtocolLayer,
					YowMediaProtocolLayer,
					YowIbProtocolLayer,
					YowIqProtocolLayer,
					YowNotificationsProtocolLayer,
					YowContactsIqProtocolLayer,
					YowChatstateProtocolLayer,
					YowCallsProtocolLayer,
					YowPrivacyProtocolLayer,
					YowProfilesProtocolLayer,
					YowGroupsProtocolLayer,
					YowPresenceProtocolLayer)),
				YowAxolotlLayer,
				YowCoderLayer,
				YowCryptLayer,
				YowStanzaRegulator,
				YowNetworkLayer
		)
		self.logger = logging.getLogger(self.__class__.__name__)
		self.stack = YowStack(layers)
		self.stack.broadcastEvent(
			YowLayerEvent(YowsupAppLayer.EVENT_START, caller = self)
		)
Exemplo n.º 5
0
    def __init__(self, credentials, encryptionEnabled = False):
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
Exemplo n.º 6
0
    def __init__(self, credentials, queue, encryptionEnabled=False):

        ListenLayer.setqueue(queue)

        if encryptionEnabled:
            layers = (ListenLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer, YowMediaProtocolLayer),
                      YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (ListenLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer, YowMediaProtocolLayer),
                      YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                           env.CURRENT_ENV.getResource())
Exemplo n.º 7
0
def run(wttQueue, ttwQueue, config):
    logger.info("Starting Whatsapp Self-Bot")

    keypair = KeyPair.from_bytes(
        base64.b64decode(config["client_static_keypair"]))

    credentials = (config["phone"], keypair)

    layers = (
        WhatsappLayer(wttQueue, ttwQueue),
        YowParallelLayer([
            YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
            YowReceiptProtocolLayer, YowAckProtocolLayer, YowIqProtocolLayer,
            YowGroupsProtocolLayer, YowMediaProtocolLayer
        ]),
        AxolotlControlLayer,
        YowParallelLayer((AxolotlSendLayer, AxolotlReceivelayer)),
    ) + YOWSUP_CORE_LAYERS

    stack = YowStack(layers)
    stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                  credentials)  # setting credentials
    stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                  YowConstants.ENDPOINTS[0])  # whatsapp server address
    # stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
    # stack.setProp(YowCoderLayer.PROP_RESOURCE, YowsupEnv.getCurrent().getResource()) #info about us as WhatsApp client

    stack.broadcastEvent(YowLayerEvent(
        YowNetworkLayer.EVENT_STATE_CONNECT))  # sending the connect signal

    stack.loop()
Exemplo n.º 8
0
    def __init__(self, credentials, encryptionEnabled=False):
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (EchoLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer, YowMediaProtocolLayer,
                       YowIqProtocolLayer, YowCallsProtocolLayer),
                      YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (EchoLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer, YowMediaProtocolLayer,
                       YowIqProtocolLayer, YowCallsProtocolLayer),
                      YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                           env.CURRENT_ENV.getResource())
Exemplo n.º 9
0
    def __init__(self, credentials, contacts, encryptionEnabled=False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (SyncLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer
                      ]), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (SyncLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer
                      ]), YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)
Exemplo n.º 10
0
    def __init__(self, smarthome, account, password, trusted=None, logic='Whatsapp', cli_mode='False'):
# Set Plugin Attributes
        self._sh = smarthome
        self._credentials = (account, password.encode('utf-8'))
        self._trusted = trusted
        self._logic = logic
        self._run = False
        if cli_mode == 'True':
            self._cli_mode = True
            return
        else:
            self._cli_mode = False
# Yowsup Layers
        self._layers = (
            SmarthomeLayer,
            YowParallelLayer((YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowIbProtocolLayer, YowIqProtocolLayer, YowNotificationsProtocolLayer, YowPresenceProtocolLayer)),
            YowCoderLayer,
#            YowLoggerLayer,
            YowCryptLayer,
            YowStanzaRegulator,
            YowNetworkLayer)

# Yowsup Properties
        self._stack = YowStack(self._layers)
        self._stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, self._credentials)
        self._stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self._stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self._stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())

# Connect Yowsup
        self._stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))

# Get SmarthomeLayer and set this Plugin
        self._SmarthomeLayer = self._stack.getLayer(len(self._stack._YowStack__stack) - 1)
        self._SmarthomeLayer.setPlugin(self)
Exemplo n.º 11
0
 def __init__(self, credentials):
     self.stack = YowStack((YowsupCliLayer, ) + YOWSUP_FULL_STACK)
     self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                        YowConstants.ENDPOINTS[0])
     self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
     self.stack.setProp(YowCoderLayer.PROP_RESOURCE, YowConstants.RESOURCE)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                        credentials)
Exemplo n.º 12
0
    def setUp(self):
        #YowAuthenticatorLayer.__init__(self)
        super(YowAuthenticationProtocolLayer, self).__init__()
        dummyStack = YowStack()
        self.setStack(dummyStack)

        self.credentials =  ("dummyusername", bytearray("password", "latin-1"))
        dummyStack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, self.credentials)
Exemplo n.º 13
0
    def setUp(self):
        # YowAuthenticatorLayer.__init__(self)
        super(YowAuthenticationProtocolLayer, self).__init__()
        dummyStack = YowStack()
        self.setStack(dummyStack)

        self.credentials = ("dummyusername", bytearray("password", "latin-1"))
        dummyStack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, self.credentials)
Exemplo n.º 14
0
    def __init__(self, credentials, messages):
        layers = (SendMedia,) + (YOWSUP_PROTOCOL_LAYERS_FULL,) + YOWSUP_CORE_LAYERS

        self.stack = YowStack(layers)
        self.stack.setProp(SendMedia.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 15
0
    def __init__(self,
                 imap_data,
                 smtp_data,
                 credentials,
                 encryptionEnabled=False):
        if encryptionEnabled:
            layers = (YowParallelLayer(
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
                 YowReceiptProtocolLayer, YowAckProtocolLayer,
                 YowMediaProtocolLayer, YowIqProtocolLayer,
                 YowCallsProtocolLayer), ), YowAxolotlLayer, YowLoggerLayer,
                      YowCoderLayer, YowCryptLayer, YowStanzaRegulator,
                      YowTwistedNetworkLayer)
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (YowParallelLayer(
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
                 YowReceiptProtocolLayer, YowAckProtocolLayer,
                 YowMediaProtocolLayer, YowIqProtocolLayer,
                 YowCallsProtocolLayer), ), YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator,
                      YowTwistedNetworkLayer)

        if smtp_data:
            layers = (YowTwistedSmtpLayer, ) + layers

        if imap_data:
            layers = (YowTwistedImapLayer, ) + layers

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                           env.CURRENT_ENV.getResource())

        if smtp_data:
            self.stack.setProp(YowTwistedSmtpLayer.PROP_USER, smtp_data[0])
            self.stack.setProp(YowTwistedSmtpLayer.PROP_PASS, smtp_data[1])
            self.stack.setProp(YowTwistedSmtpLayer.PROP_ENDPOINT, smtp_data[2])
            self.stack.setProp(YowTwistedSmtpLayer.PROP_DST_MAIL, smtp_data[3])
            self.stack.setProp(YowTwistedSmtpLayer.PROP_REPLY_MAIL,
                               smtp_data[4])

        if imap_data:
            self.stack.setProp(YowTwistedImapLayer.PROP_USER, imap_data[0])
            self.stack.setProp(YowTwistedImapLayer.PROP_PASS, imap_data[1])
            self.stack.setProp(YowTwistedImapLayer.PROP_ENDPOINT, imap_data[2])
            self.stack.setProp(YowTwistedImapLayer.PROP_DST_PHONE,
                               imap_data[3])
Exemplo n.º 16
0
 def __init__(self, credentials):
     """Default Yowsup setup, with the Route Layer on top"""
     layers = (RouteLayer,
               YowParallelLayer([YowAuthenticationProtocolLayer,
                                 YowMessagesProtocolLayer,
                                 YowReceiptProtocolLayer,
                                 YowAckProtocolLayer,
                                 YowMediaProtocolLayer,
                                 YowIqProtocolLayer]),
               YowAxolotlLayer,
               ) + YOWSUP_CORE_LAYERS
     self.stack = YowStack(layers)
     self.stack.setCredentials(credentials)
Exemplo n.º 17
0
    def __init__(self, credentials):
        layers = (EchoLayer,
                  (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
                   YowReceiptProtocolLayer, YowAckProtocolLayer,
                   YowMediaProtocolLayer), YowLoggerLayer, YowCoderLayer,
                  YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, YowConstants.RESOURCE)
Exemplo n.º 18
0
    def _send_message(self, to, message, is_media=False):
        layers = (SendLayer,) + (YOWSUP_PROTOCOL_LAYERS_FULL,) + YOWSUP_CORE_LAYERS
        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, (self.login, self.password))
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.YowsupEnv.getCurrent().getResource())

        self.stack.setProp(SendLayer.PROP_MESSAGES, [([to, message, is_media])])
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except KeyboardInterrupt:
            pass
Exemplo n.º 19
0
    def __init__(self, credentials, entities):
        logger = logging.StreamHandler()
        logger.setLevel(logging.DEBUG)
        logging.getLogger("yowsup.stacks.yowstack").addHandler(logger)
        
        env.CURRENT_ENV = env.AndroidYowsupEnv()
        #env.CURRENT_ENV = env.S40YowsupEnv()
        
        layers = (
            EchoLayer, 
            
            YowParallelLayer([YowGroupsProtocolLayer, YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowPresenceProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer, YowNotificationsProtocolLayer, YowProfilesProtocolLayer, YowChatstateProtocolLayer, YowMyGroupsProtocolLayer]),
            #SniffLayer,
            YowAxolotlLayer,
            YowLoggerLayer,
            YowCoderLayer,
            YowCryptLayer,
            YowStanzaRegulator,
            YowNetworkLayer
        )

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(EchoLayer.PROP_SELFNUMBER, credentials[0])
        self.stack.setProp(EchoLayer.PROP_ENTITYCLASSES, entities)
        self.stack.setProp(EchoLayer.SELF_STACK, self.stack)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 20
0
    def __init__(self, encryption_enabled = True):
        if encryption_enabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(settings.CREDENTIALS)
Exemplo n.º 21
0
    def __init__(self, credentials, messages, encryptionEnabled = False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                SendLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                SendLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)
Exemplo n.º 22
0
    def __init__(self, credentials, contacts, encryptionEnabled = False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                SyncLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                SyncLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)
Exemplo n.º 23
0
    def __init__(self, credentials, encryptionEnabled = False,interactionProtocol=None,url=None,flaskApp=None):
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                RobotLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                RobotLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
        self.stack.setProp('url',url)
        self.stack.setProp('flaskApp',flaskApp)
Exemplo n.º 24
0
Arquivo: stack.py Projeto: b-e/flask
    def __init__(self, credentials, encryptionEnabled = False):
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                EchoLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer]),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                EchoLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer]),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
Exemplo n.º 25
0
    def __init__(self, credentials, encryptionEnabled = False):
        if encryptionEnabled:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 26
0
 def __init__(self, credentials):
     self.stack = YowStack(
         (YowsupCliLayer,) + YOWSUP_FULL_STACK
     )
     self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
     self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
     self.stack.setProp(YowCoderLayer.PROP_RESOURCE, YowConstants.RESOURCE)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
Exemplo n.º 27
0
class YowsupSendStack(object):
    def __init__(self, credentials, messages, encryptionEnabled = False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                SendLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                SendLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        
        except KeyboardInterrupt as e:
            raise e

        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 28
0
class YowsupRobotStack(object):
    def __init__(self, credentials, encryptionEnabled = False,interactionProtocol=None,url=None,flaskApp=None):
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                RobotLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                RobotLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
        self.stack.setProp('url',url)
        self.stack.setProp('flaskApp',flaskApp)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        def startThread():
            try:
                self.stack.loop(timeout = 0.5, discrete = 0.5)
            except AuthError as e:
                print("Auth Error, reason %s" % e)
            except KeyboardInterrupt:
                print("\nYowsdown KeyboardInterrupt")
                sys.exit(0)
            except Exception as e:
                print("\nYowsdown General Exception")
                print e
        t1=threading.Thread(target=startThread)
        t1.daemon=True
        t1.start()
Exemplo n.º 29
0
 def __init__(self, credentials, messages):
     env.CURRENT_ENV = env.S40YowsupEnv()
     layers = (SendLayer, (YowAuthenticationProtocolLayer,
                           YowMessagesProtocolLayer,
                           YowReceiptProtocolLayer, YowAckProtocolLayer),
               YowLoggerLayer, YowCoderLayer, YowCryptLayer,
               YowStanzaRegulator, YowNetworkLayer)
     self.stack = YowStack(layers)
     self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                        credentials)
     self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                        YowConstants.ENDPOINTS[0])
     self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
     self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                        env.CURRENT_ENV.getResource())
Exemplo n.º 30
0
class YowsupSyncStack(object):
    def __init__(self, credentials, contacts, encryptionEnabled=False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer

            layers = (
                SyncLayer,
                (YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                 YowAckProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                SyncLayer,
                (YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer,
                 YowAckProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: {0}".format(e))
Exemplo n.º 31
0
 def __init__(self, credentials, messages):
     layers=(SendMediaLayer,)+(YOWSUP_PROTOCOL_LAYERS_FULL,)+YOWSUP_CORE_LAYERS
     self.stack=YowStack(layers)
     self.stack.setProp(SendMediaLayer.PROP_MESSAGES,messages)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE,True)
     self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,credentials)
     self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,YowConstants.ENDPOINTS[0])
     self.stack.setProp(YowCoderLayer.PROP_DOMAIN,YowConstants.DOMAIN)
     self.stack.setProp(YowCoderLayer.PROP_RESOURCE,env.CURRENT_ENV.getResource())
Exemplo n.º 32
0
class YowsupSendStack(object):
    def __init__(self, credentials, messages, encryptionEnabled = False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                SendLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                SendLayer,
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 33
0
class YowsupMiddleManStack(object):
    def __init__(self, credentials, groups, encryptionEnabled=False):
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer

            layers = (
                MiddleManLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                    YowMediaProtocolLayer,
                    YowIqProtocolLayer,
                    YowCallsProtocolLayer,
                ),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )
        else:
            layers = (
                MiddleManLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                    YowMediaProtocolLayer,
                    YowIqProtocolLayer,
                    YowCallsProtocolLayer,
                ),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )

        self.stack = YowStack(layers)
        self.stack.setProp(MiddleManLayer.PROP_GROUPS, groups[0])
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 34
0
    def __init__(self, credentials, encryptionEnabled = False):
	GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
	GPIO.setup(21, GPIO.OUT)	#Led 1
	GPIO.setup(20, GPIO.OUT)	#Led 2
	GPIO.setup(16, GPIO.OUT)        #Led 3
	GPIO.setup(12, GPIO.OUT)        #Led 4
	GPIO.setup(25, GPIO.OUT)        #Led 5
	GPIO.setup(24, GPIO.OUT)        #Led 6
	GPIO.setup(23, GPIO.OUT)        #Led 7
	GPIO.setup(18, GPIO.OUT)        #Led 8
        GPIO.setup(19, GPIO.OUT)
        GPIO.setup(26, GPIO.OUT)
        entrada = GPIO.PWM(19,50)
        entrada.start(12)
        garaje = GPIO.PWM(26,50)
        garaje.start(3.5)

	GPIO.output(21, GPIO.LOW)
	GPIO.output(20, GPIO.LOW)
	GPIO.output(16, GPIO.LOW)
        GPIO.output(12, GPIO.LOW)
	GPIO.output(25, GPIO.LOW)
        GPIO.output(24, GPIO.LOW)
	GPIO.output(23, GPIO.LOW)
        GPIO.output(18, GPIO.LOW)

        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        logging.basicConfig()
        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
Exemplo n.º 35
0
class YowsupEchoStack(object):
    def __init__(self, credentials, encryptionEnabled=False):
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(
            YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            logging.info("Whatsapp IS STARTING : ReceiveStack")
            self.stack.loop(timeout=1, count=100)
            logging.info("Stopping ... ")
        except AuthError as e:
            logging.info("Authentication Error: %s" % e.message)
Exemplo n.º 36
0
class YowsupEchoStack(object):
    def __init__(self, encryption_enabled = True):
        if encryption_enabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(settings.CREDENTIALS)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 37
0
class YowsupEchoStack(object):
    def __init__(self, encryption_enabled=True):
        if encryption_enabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setCredentials(settings.CREDENTIALS)

    def start(self):
        self.stack.broadcastEvent(
            YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop(timeout=120)
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
        except Exception as e:
            print("Another Error: %s" % str(e))
Exemplo n.º 38
0
class YowsupBotStack(object):
    def __init__(self, credentials):
        """Default Yowsup setup, with the Route Layer on top"""
        layers = (RouteLayer,
                  YowParallelLayer([YowAuthenticationProtocolLayer,
                                    YowGroupsProtocolLayer,
                                    YowMessagesProtocolLayer,
                                    YowReceiptProtocolLayer,
                                    YowAckProtocolLayer,
                                    YowMediaProtocolLayer,
                                    YowIqProtocolLayer]),
                  YowAxolotlLayer,
                  ) + YOWSUP_CORE_LAYERS
        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
        self.credentials = credentials


    def start(self):
        "Starts the connection with Whatsapp servers,"
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            logging.info("#" * 50)
            logging.info("Server started. Phone number: %s" % self.credentials[0])
            logging.info("#" * 50)
            self.stack.loop()
        except AuthError as e:
            logging.exception("Authentication Error: %s" % e.message)
        except Exception as e:
            logging.exception("Unknown Error: %s" % e.message)
            raise e
Exemplo n.º 39
0
class YowsupCommandServerStack(object):
    def __init__(self, credentials, allowed_users, encryptionEnabled = False):
        if encryptionEnabled:
            from yowsup.layers.axolotl                     import YowAxolotlLayer
            layers = (
                CommandServerLayer(allowed_users),
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer]),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            layers = (
                CommandServerLayer(allowed_users),
                YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer]),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 40
0
class YowsupBotStack(object):
    def __init__(self, credentials):
        """Default Yowsup setup, with the Route Layer on top"""
        layers = (RouteLayer,
                  YowParallelLayer([YowAuthenticationProtocolLayer,
                                    YowGroupsProtocolLayer,
                                    YowMessagesProtocolLayer,
                                    YowReceiptProtocolLayer,
                                    YowAckProtocolLayer,
                                    YowMediaProtocolLayer,
                                    YowIqProtocolLayer]),
                  YowAxolotlLayer,
                  ) + YOWSUP_CORE_LAYERS
        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)
        self.credentials = credentials

    def start(self):
        "Starts the connection with Whatsapp servers,"
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            logging.info("#" * 50)
            logging.info("Server started. Phone number: %s" % self.credentials[0])
            logging.info("#" * 50)
            self.stack.loop()
        except AuthError as e:
            logging.exception("Authentication Error: %s" % e.message)
        except Exception as e:
            logging.exception("Unknown Error: %s" % e.message)
            raise e
Exemplo n.º 41
0
class YowsupCommandServerStack(object):
    def __init__(self, credentials, allowed_users, encryptionEnabled=False):
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (CommandServerLayer(allowed_users),
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (CommandServerLayer(allowed_users),
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setCredentials(credentials)

    def start(self):
        self.stack.broadcastEvent(
            YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 42
0
    def __init__(self, encryption_enabled=True):
        if encryption_enabled:
            from yowsup.layers.axolotl import YowAxolotlLayer
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer,
                      YowCryptLayer, YowStanzaRegulator, YowNetworkLayer)
        else:
            layers = (EchoLayer,
                      YowParallelLayer([
                          YowAuthenticationProtocolLayer,
                          YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                          YowAckProtocolLayer, YowMediaProtocolLayer,
                          YowIqProtocolLayer, YowCallsProtocolLayer
                      ]), YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setCredentials(settings.CREDENTIALS)
Exemplo n.º 43
0
class YowsupTwistedEchoStack(object):
    def __init__(self, credentials, encryptionEnabled = False):
        if encryptionEnabled:
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowTwistedNetworkLayer
            )
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (
                EchoLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowTwistedNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())

    def start(self):
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            reactor.run()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 44
0
    def __init__(self, credentials, messages, encryptionEnabled = False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            layers = (
                SendLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (
                SendLayer,
                (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 45
0
class YowsupTwistedEchoStack(object):
    def __init__(self, credentials, encryptionEnabled=False):
        if encryptionEnabled:
            layers = (EchoLayer, (YowAuthenticationProtocolLayer,
                                  YowMessagesProtocolLayer,
                                  YowReceiptProtocolLayer, YowAckProtocolLayer,
                                  YowMediaProtocolLayer, YowIqProtocolLayer,
                                  YowCallsProtocolLayer), YowAxolotlLayer,
                      YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowTwistedNetworkLayer)
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (EchoLayer,
                      (YowAuthenticationProtocolLayer,
                       YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                       YowAckProtocolLayer, YowMediaProtocolLayer,
                       YowIqProtocolLayer, YowCallsProtocolLayer),
                      YowLoggerLayer, YowCoderLayer, YowCryptLayer,
                      YowStanzaRegulator, YowTwistedNetworkLayer)

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                           credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                           YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                           env.CURRENT_ENV.getResource())

    def start(self):
        self.stack.broadcastEvent(
            YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            reactor.run()
        except AuthError as e:
            print("Authentication Error: %s" % e.message)
Exemplo n.º 46
0
    def _send_message(self, to, message, is_media=False):
        layers = (SendLayer,) + (YOWSUP_PROTOCOL_LAYERS_FULL,) + YOWSUP_CORE_LAYERS
        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, (self.login, self.password))
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.YowsupEnv.getCurrent().getResource())

        self.stack.setProp(SendLayer.PROP_MESSAGES, [([to, message, is_media])])
        self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
        try:
            self.stack.loop()
        except KeyboardInterrupt:
            pass
Exemplo n.º 47
0
    def __init__(self, credentials, to):
        """
        :param credentials:
        :param to:
        :param encryptionEnabled:
        :return:
        """
        layers = (
            SendVCardLayer,
            (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer),
            YowLoggerLayer,
            YowCoderLayer,
            YowCryptLayer,
            YowStanzaRegulator,
            YowNetworkLayer
        )

        self.stack = YowStack(layers)
        self.stack.setProp(SendVCardLayer.PROP_TO, to)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 48
0
    def __init__(self, credentials):
        layers = (
            ReceiveLayer,
            (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer),
            YowCoderLayer,
            YowCryptLayer,
            YowStanzaRegulator,
            YowNetworkLayer
        )

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 49
0
    def __init__(self, credentials):
        layers = (
            EchoLayer,
            (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
            YowLoggerLayer,
            YowCoderLayer,
            YowCryptLayer,
            YowStanzaRegulator,
            YowNetworkLayer
        )

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, YowConstants.RESOURCE)
Exemplo n.º 50
0
    def __init__(self, credentials, messages, encryptionEnabled=False):
        """
        :param credentials:
        :param messages: list of (jid, message) tuples
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (
                SendLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                ),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )
        else:
            layers = (
                SendLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                ),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SendLayer.PROP_MESSAGES, messages)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
    def __init__(self, credentials):
        env.CURRENT_ENV = env.S40YowsupEnv()
        layers = (
            MailLayer,
            (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
                YowReceiptProtocolLayer, YowAckProtocolLayer,
                YowMediaProtocolLayer, YowIqProtocolLayer,
                YowPresenceProtocolLayer)
            ) + YOWSUP_CORE_LAYERS

        self.stack = YowStack(layers)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
                credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT,
                YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE,
                env.CURRENT_ENV.getResource())
Exemplo n.º 52
0
    def __init__(self, credentials, groups, encryptionEnabled=False):
        if encryptionEnabled:
            from yowsup.layers.axolotl import YowAxolotlLayer

            layers = (
                MiddleManLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                    YowMediaProtocolLayer,
                    YowIqProtocolLayer,
                    YowCallsProtocolLayer,
                ),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )
        else:
            layers = (
                MiddleManLayer,
                (
                    YowAuthenticationProtocolLayer,
                    YowMessagesProtocolLayer,
                    YowReceiptProtocolLayer,
                    YowAckProtocolLayer,
                    YowMediaProtocolLayer,
                    YowIqProtocolLayer,
                    YowCallsProtocolLayer,
                ),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer,
            )

        self.stack = YowStack(layers)
        self.stack.setProp(MiddleManLayer.PROP_GROUPS, groups[0])
        self.stack.setCredentials(credentials)
Exemplo n.º 53
0
class YowsupDaemon(Daemon):

    def run(self):
		credentials = settings.get('Yowsup')
        phone = credentials['phone']
        password = credentials['pwd']
        CREDENTIALS = (phone, password) # replace with your phone and password
        logging.basicConfig(level = logging.DEBUG)
        layers = (
        HomeLayer,
        YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),YowAxolotlLayer
        ) + YOWSUP_CORE_LAYERS

        stack = YowStack(layers)
        stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)         #setting credentials
        stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])    #whatsapp server address
        stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        stack.setProp(YowCoderLayer.PROP_RESOURCE, YowsupEnv.getCurrent().getResource())          #info about us as WhatsApp client

        stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))   #sending the connect signal
        stack.loop() #this is the program mainloop
Exemplo n.º 54
0
    def __init__(self, credentials, contacts, encryptionEnabled = False):
        """
        :param credentials:
        :param contacts: list of [jid ]
        :param encryptionEnabled:
        :return:
        """
        if encryptionEnabled:
            layers = (
                SyncLayer,
                (YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowAxolotlLayer,
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )
        else:
            env.CURRENT_ENV = env.S40YowsupEnv()
            layers = (
                SyncLayer,
                (YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),
                YowLoggerLayer,
                YowCoderLayer,
                YowCryptLayer,
                YowStanzaRegulator,
                YowNetworkLayer
            )

        self.stack = YowStack(layers)
        self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
        self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, credentials)
        self.stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
        self.stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
        self.stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())
Exemplo n.º 55
0
from yowsup.layers.logger import YowLoggerLayer
from yowsup.layers.protocol_iq import YowIqProtocolLayer
from yowsup.layers.protocol_calls import YowCallsProtocolLayer
from yowsup.layers.axolotl import YowAxolotlLayer
from yowsup.common import YowConstants
from yowsup import env

if os.environ['DEBUG'] == '1':
    logging.basicConfig(level=logging.DEBUG)

CREDENTIALS = (os.environ['PHONE'], os.environ['PASSWORD'])

if __name__ == "__main__":
    layers = (ReceiveLayer,
              (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer,
               YowReceiptProtocolLayer, YowAckProtocolLayer,
               YowMediaProtocolLayer, YowIqProtocolLayer,
               YowCallsProtocolLayer, YowProfilesProtocolLayer),
              YowAxolotlLayer, YowLoggerLayer, YowCoderLayer, YowCryptLayer,
              YowStanzaRegulator, YowNetworkLayer)

    stack = YowStack(layers)
    stack.setCredentials(CREDENTIALS)

    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))

    try:
        stack.loop(timeout=0.5, discrete=0.5)
    except AuthError as e:
        print("Authentication Error: %s" % e.message)
from yowsup.layers.protocol_messages           import YowMessagesProtocolLayer
from yowsup.layers.protocol_receipts           import YowReceiptProtocolLayer
from yowsup.layers.protocol_acks               import YowAckProtocolLayer
from yowsup.layers.network                     import YowNetworkLayer
from yowsup.layers.coder                       import YowCoderLayer
from yowsup.stacks import YowStack
from yowsup.common import YowConstants
from yowsup.layers import YowLayerEvent
from yowsup.stacks import YowStack, YOWSUP_CORE_LAYERS
from yowsup import env
import logging
logging.basicConfig(level=logging.DEBUG)

CREDENTIALS = ("919872736838", "yWcmikNwHmDPJ6xPeXOS0bk1X14=") # replace with your phone and password

if __name__==  "__main__":
    layers = (
        EchoLayer,
        (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer), YowAxolotlLayer
    ) + YOWSUP_CORE_LAYERS

    stack = YowStack(layers)
    stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)         #setting credentials
    stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])    #whatsapp server address
    stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
    stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())          #info about us as WhatsApp client

    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))   #sending the connect signal

    stack.loop() #this is the program mainloop