def __init__(self, credentials, encryptionEnabled=False): if encryptionEnabled: layers = (EchoLayer, (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer), YowAxolotlLayer, YowLoggerLayer, YowCoderLayer, YowCryptLayer, YowStanzaRegulator, YowNetworkLayer) else: env.CURRENT_ENV = env.S40YowsupEnv() 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, env.CURRENT_ENV.getResource())
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) )
def connect_whatsapp(phone, password, encryption, reply_url): layers = ( ServerLayer, (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer), ) if encryption: logging.info("Adding encryption layer") layers = layers + (YowAxolotlLayer, ) else: env.CURRENT_ENV = env.S40YowsupEnv() layers = layers + YOWSUP_CORE_LAYERS stack = YowStack(layers) stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, (phone, password)) #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.setProp(ServerLayer.PROP_REPLY_URL, reply_url) return stack
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])
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())
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())