EzDevInfo.com

yowsup

The python WhatsApp library

Yowsup version on python

The version shown in below script is for what and from where can I get new vcersion

from .env import YowsupEnv import base64 import hashlib class S40YowsupEnv(YowsupEnv): #_VERSION = "2.12.68" _VERSION = "2.12.82" _OS_NAME= "S40" _OS_VERSION = "14.26" _DEVICE_NAME = "Nokia302"


Source: (StackOverflow)

How to read whatsapp receiving message via yowsup-cli?

I am newbie in yowsup.I am a php programmer i have read receiving whatsapp messages via yowsup-cli.

Is it possible?

Thanks in advance


Source: (StackOverflow)

Advertisements

Obtaining the status of message in Yowsup 2

I am sending message like this:

from yowsup.demos import sendclient
credentials = ['0123456789', 'abc']
try:
    stack = sendclient.YowsupSendStack(
        credentials,
        [(['1234567890', 'test message'])]
    )
    stack.start()
except KeyboardInterrupt:
    print('\nYowsdown')

Can I get status of message (received / not received) after sending using Yowsup 2?


Source: (StackOverflow)

installing yowsup on windows

I installed Python using the executable(https://www.python.org/ftp/python/3.5.0/python-3.5.0a3-amd64.exe)

Then created the distutils.cfg file(no content in it) in the C:\Program Files\Python 3.5\Lib\distutils)

I downloaded the yowsup-master.zip(https://github.com/tgalal/yowsup) file but I don't know what to do from here on


Source: (StackOverflow)

unorderable type error in module python-axolotl-curve25519.py

I wanted to install the module python-axolotl-curve25519.py but I keep getting an unorderable type error .TypeError: unorderable types: NoneType() >= str(). I have tried it on python 3.4 and python 2.7. but I keep getting the same error from both pip and easy_install. I want to install yowsup library.

This was the traceback

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\kenny\AppData\Local\Temp\pip-build-wzoc4cv_\python-axolotl-
curve25519\setup.py", line 27, in <module>
        platforms='any'
      File "C:\Python34\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 6
1, in run
        return orig.install.run(self)
      File "C:\Python34\lib\distutils\command\install.py", line 554, in run
        self.run_command('build')
      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\distutils\command\build.py", line 126, in run
        self.run_command(cmd_name)
      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line
 50, in run
        _build_ext.run(self)
      File "C:\Python34\lib\distutils\command\build_ext.py", line 317, in run
        force=self.force)
      File "C:\Python34\lib\distutils\ccompiler.py", line 1031, in new_compiler
        return klass(None, dry_run, force)
      File "C:\Python34\lib\distutils\cygwinccompiler.py", line 282, in __init__

        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "C:\Python34\lib\distutils\cygwinccompiler.py", line 126, in __init__

        if self.ld_version >= "2.10.90":
    TypeError: unorderable types: NoneType() >= str()
    Complete output from command C:\Python34\python.exe -c "import setuptools, t
okenize;__file__='C:\\Users\\kenny\\AppData\\Local\\Temp\\pip-build-wzoc4cv_\\py
thon-axolotl-curve25519\\setup.py';exec(compile(getattr(tokenize, 'open', open)(
__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\
Users\kenny\AppData\Local\Temp\pip-c9d9a1jq-record\install-record.txt --single-v
ersion-externally-managed --compile:
    running install

    running build

    running build_ext

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "C:\Users\kenny\AppData\Local\Temp\pip-build-wzoc4cv_\python-axolotl-
curve25519\setup.py", line 27, in <module>

        platforms='any'

      File "C:\Python34\lib\distutils\core.py", line 148, in setup

        dist.run_commands()

      File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands

        self.run_command(cmd)

      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command

        cmd_obj.run()

      File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 6
1, in run

        return orig.install.run(self)

      File "C:\Python34\lib\distutils\command\install.py", line 554, in run

        self.run_command('build')

      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command

        self.distribution.run_command(command)

      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command

        cmd_obj.run()

      File "C:\Python34\lib\distutils\command\build.py", line 126, in run

        self.run_command(cmd_name)

      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command

        self.distribution.run_command(command)

      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command

        cmd_obj.run()

      File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line
 50, in run

        _build_ext.run(self)

      File "C:\Python34\lib\distutils\command\build_ext.py", line 317, in run

        force=self.force)

      File "C:\Python34\lib\distutils\ccompiler.py", line 1031, in new_compiler

        return klass(None, dry_run, force)

      File "C:\Python34\lib\distutils\cygwinccompiler.py", line 282, in __init__


        CygwinCCompiler.__init__ (self, verbose, dry_run, force)

      File "C:\Python34\lib\distutils\cygwinccompiler.py", line 126, in __init__


        if self.ld_version >= "2.10.90":

    TypeError: unorderable types: NoneType() >= str()

    ----------------------------------------

Source: (StackOverflow)

building a whatsapp client for android

Is it possible to build a whatsapp client for android? I came across the Yowsup project for building a whatsapp client for pc and I wonder if there is something like that for android too. Thanks ahead

Edit: Is there any way to build the client with the Yowsup library in python and then port it somehow to the android? will it work well?


Source: (StackOverflow)

yowsup - Integrating sending and receiving

Background:

I would like to integrate yowsup to my home automation project. I have seen a simple sample on how to receive messages and after some minor changes it is working fine.

Issue:

My problem starts when it comes to integrate the send message feature. Those are the two files I am using:

run.py

from layer import EchoLayer

from yowsup.layers.auth import YowAuthenticationProtocolLayer
from yowsup.layers.protocol_messages import YowMessagesProtocolLayer
from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer
from yowsup.layers.protocol_acks import YowAckProtocolLayer
from yowsup.layers.protocol_presence import YowPresenceProtocolLayer
from yowsup.layers.network import YowNetworkLayer
from yowsup.layers.coder import YowCoderLayer
from yowsup.common import YowConstants
from yowsup.layers import YowLayerEvent
from yowsup.stacks import YowStack, YOWSUP_CORE_LAYERS
from yowsup import env


CREDENTIALS = ("phone", "pwd")

if __name__ == "__main__":

    layers = (
        EchoLayer,
        (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowPresenceProtocolLayer)
    ) + YOWSUP_CORE_LAYERS

    stack = YowStack(layers)
    # Setting credentials
    stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)

    # WhatsApp server address
    stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])
    stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)              
    stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())

    # Sending connecting signal
    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))

    # Program main loop
    stack.loop()

layer.py

from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
from yowsup.layers.protocol_receipts.protocolentities import OutgoingReceiptProtocolEntity
from yowsup.layers.protocol_acks.protocolentities import OutgoingAckProtocolEntity
from yowsup.layers.protocol_presence.protocolentities import PresenceProtocolEntity
import threading
import logging

logger = logging.getLogger(__name__)

class EchoLayer(YowInterfaceLayer):

    @ProtocolEntityCallback("message")
    def onMessage(self, messageProtocolEntity):
        #send receipt otherwise we keep receiving the same message over and over
        print str(messageProtocolEntity.getFrom()) + ' - ' + str(messageProtocolEntity.getBody())
        receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom())
        self.toLower(receipt)

    @ProtocolEntityCallback("send_message")
    def sendMessage(self, destination, message, messageProtocolEntity):
        outgoingMessageProtocolEntity = TextMessageProtocolEntity(
        message,
        to = destination + "@s.whatsapp.net")
        self.toLower(outgoingMessageProtocolEntity)


    @ProtocolEntityCallback("receipt")
    def onReceipt(self, entity):
        ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", "delivery")
        self.toLower(ack)

    # List of (jid, message) tuples
    PROP_MESSAGES = "org.openwhatsapp.yowsup.prop.sendclient.queue"

    def __init__(self):
        super(EchoLayer, self).__init__()
        self.ackQueue = []
        self.lock = threading.Condition()

    @ProtocolEntityCallback("success")
    def onSuccess(self, successProtocolEntity):
        self.lock.acquire()
        for target in self.getProp(self.__class__.PROP_MESSAGES, []):
            phone, message = target
            if '@' in phone:
                messageEntity = TextMessageProtocolEntity(message, to = phone)
            elif '-' in phone:
                messageEntity = TextMessageProtocolEntity(message, to = "%s@g.us" % phone)
            else:
                messageEntity = TextMessageProtocolEntity(message, to = "%s@s.whatsapp.net" % phone)
            self.ackQueue.append(messageEntity.getId())
            self.toLower(messageEntity)
        self.lock.release()

    @ProtocolEntityCallback("ack")
    def onAck(self, entity):
        self.lock.acquire()

        if entity.getId() in self.ackQueue:
            self.ackQueue.pop(self.ackQueue.index(entity.getId()))

        if not len(self.ackQueue):
            logger.info("Message sent")
            #raise KeyboardInterrupt()

        self.lock.release()

Questions:

  • Where am I supposed to call the send_message method, so I can send messages wherever I need it?
  • Is there a regular event (triggering every second or something) which I could use to send my messages?

Source: (StackOverflow)

Integrating WhatsAPI/Yowsup into Android

I am new to Android and aim to build a group chat, and peer to peer chat feature in my app. I have researched and read about WhatsAPI and Yowsup, as they seem to be promising, but do not see any implementation to Android.

Is anyone familiar with adding WhatsApp or Yowsup to their Android applications to enable chat and group chats successfully?


Source: (StackOverflow)

Yowsup auth fail whatsapp

i am working on an api for whatsapp, i am using Yowsup. when i use Yowsup Cli client i manage to login to the whatsapp account and send and receive messages from it. when i try to use the following script, it return "Auth Failed!".

import sys
import os
import logging
import time
import shutil
import Queue
from collections import defaultdict

from Yowsup.Common.debugger import Debugger
from Yowsup.connectionmanager import YowsupConnectionManager

from py_utils import logutils
from py_utils import executable_utils
from py_utils import exception_utils

from py_utils.cli_utils import actions_handler


COUNTRY_CODE = "COUNTRY_NUM"
PHONE_NUMBER = "MYNUMBER"
# IDENTITY = ""
PASSWORD = 'MY_PASS_WORD'
LOGIN = COUNTRY_CODE + PHONE_NUMBER

import argparse, sys, os, csv
from Yowsup.Common.utilities import Utilities
from Yowsup.Common.debugger import Debugger
from Yowsup.Common.constants import Constants
from Yowsup.Contacts.contacts import WAContactsSyncRequest
from Yowsup.connectionmanager import YowsupConnectionManager

import threading,time, base64

########## DO NOT COMMIT THIS FILE WITH YOUR CREDENTIALS ###########
#.....................WhatsApp Account Config.......................

nickname = "lamaaaaaaa"
username = LOGIN
password = PASSWORD

id = "" # Not required

#....................................................................

# Degug is False by default if you add -d you will set it to True
Debugger.enabled = True if '-d' in sys.argv else False
password = base64.b64decode(bytes(password.encode('utf-8')))

def login(username, password):
    print "[] Logging in as %s (%s)\n" % (nickname, username)
    methodsInterface.call("auth_login", (username, password))

def onAuthSuccess(username):
    print("Authed!!\n\n")
    methodsInterface.call("ready")
    methodsInterface.call("presence_sendAvailableForChat", (nickname,))

def onAuthFailed(username, err):
    print("Auth Failed!")

########################### BIND EVENTS #############################
connectionManager = YowsupConnectionManager()
signalsInterface = connectionManager.getSignalsInterface()
methodsInterface = connectionManager.getMethodsInterface()
connectionManager.setAutoPong(True)

signalsInterface.registerListener("auth_success", onAuthSuccess)
signalsInterface.registerListener("auth_fail", onAuthFailed)
#####################################################################

login(username, password)    

Source: (StackOverflow)

Error trying to install yowsup on windows

I followed instructions as given here I installed python 3.4.3, then installed zlib and finally executed python setup.py install after downloading extracting the yowsup from hereenter link description here and changed directory to yowsup-master.

But I get this error:

    c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: build\
temp.win-amd64-3.4\Release\curve25519module.o: bad reloc address 0x14 in section
 `.data'
    collect2.exe: error: ld returned 1 exit status
    error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

Then since above did not work, I tried using pip install yowsup2 but I get the same error. Could anyone get round this error? I am not into python, so not able to tell why is this error happening.

I am on windows 8.1 64 bit.


Source: (StackOverflow)

command to download profile image - yowsup 2.0 python whatsapp

I have a problem with yowsup 2.0 and python.

What is the command to download a profile image (of a friend) using yowsup 2.0 + python?

Should I use a layer?


Source: (StackOverflow)

Redirect output of Whatsapp bash script to file interactively for automation purpose

Yowsup-cli is a library that can allow you to send message to whatsapp users,once authenticated. By the coommand

yowsup-cli -a --interactive <PHONE_NUMBER_HERE> --wait --autoack --keepalive --config yowsup-master/src/yowsup-cli.config

I can interactively send or receive messages. Once executed the command you get a prompt like

MY_PHONE_NUMBER@s.whatsapp.net [27-12-2014 18:33]:THIS IS MY MESSAGE,TYPED ON MY PHONE. OPEN DOOR GARAGE Enter Message or command: (/available, /lastseen, /unavailable) I'm a totally beginner, but I would like to redirect this content that gets printed on terminal to a file,to further analyze it or to write a script that search into this file keyword as "OPEN GARAGE DOOR", so i could automate something. This file obviously has to sync with the program output,but I don't know how to do.

yowsup-cli -a --interactive <PHONE_NUMBER_HERE> --wait --autoack --keepalive --config yowsup-master/src/yowsup-cli.config > /path/to/my_file doesn't work

Running Ubuntu 12.04. I know yowsup is a python library, but i don't know this language. I'm beginning learniing C and I would like to do that in BASH, or if not possible in C. Thanks


Source: (StackOverflow)

Server listening to Whatsapp messages and replying

Since there is no official WhatsApp API available, is it possible to make a server listen to incoming whatsapp messages and then reply(preferably in Python)?


Source: (StackOverflow)

Is it legal to use yowsup?

Is it legal to use yowsup in creating my android application and publishing the app on google play?

I only need to use some of the whatsapp stuff. I'm not copying everything. I'll use different name for sure.

thank you ,,,


Source: (StackOverflow)

Yowsup connection to whatsapp raise Disconnected because close exception

I have installed the yowsub library (the latest version ) on my device ( Ubuntu 12.04 )

also I have obtained the request code by running this command

$ ./yowsup-cli --requestcode sms --config yowsup-cli.config

and then I registered it successfully using this command

$ ./yowsup-cli --register {MY-CODE} --config yowsup-cli.config

after that I entered the returned password in the configuration file.

but when I try to send messages by this command

$ ./yowsup-cli --send {Destination phone with it's country code} "Test message" --wait --config yowsup-cli.config

I have the following exception

Disconnected because close

I tried more than solution related to this issue but the result was the same exception.


Source: (StackOverflow)