tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.02k stars 2.23k forks source link

Problem YowSup with pipeline #654

Closed sr2ds closed 9 years ago

sr2ds commented 9 years ago

Hello, I'm trying to use the cli with named pipe, however, I get the following error:

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 809, in bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(_self.args, *_self.__kwargs) File "build/bdist.linux-x86_64/egg/yowsup/demos/cli/cli.py", line 150, in startInputThread cmd = self._queuedCmds.pop(0) if len(self._queuedCmds) else input(self.getPrompt()).strip() EOFError: EOF when reading a line

Has anyone experienced this?

The error happens so I send any echo to the pipe.

aemitos commented 9 years ago

Hi, first I would like to congratulate you @tgalal, yowsup rocks!. I decided to comment this post cause I could open other about the same problem.

I'm trying to use the "/groups" commands in the "yowsup-cli -y" mode, and I already see that is possible to send one command like "/L" using a shell call like:

$ echo "/L" | yowsup-cli demos --yowsup --config something.conf 

I've got this:

Yowsup Cli client
==================
Type /help for available commands

[offline]:Auth: Logged in!

[connected]:

Notification: Notification
From: XXXXXXXXXXXXXX@s.whatsapp.net
Type: status

[connected]:
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.linux-x86_64/egg/yowsup/demos/cli/cli.py", line 150, in startInputThread
    cmd = self._queuedCmds.pop(0) if len(self._queuedCmds) else input(self.getPrompt()).strip()
EOFError: EOF when reading a line

Like @srdavidsilva said above, the first command is executed but then the pipe return the error presented above. My goal is to use yowsup-cli to automate the use of groups, sending invitations and messages cause I've been using to send the messages directly to the users but whatsapp think that kind of use to spam. My app sent to many messages in a short time period and they block my account. I already made tests for the use of groups and it works fine, but I would like to know if it's possible to use yowsup-cli to execute commands only available in the '--yowsup' mode directly in the system shell. Since it's more easy to integrate with other applications not coded in python. Is there a right way to do this since the argparse already treat simple use(demos)? Or I will have to code it? Thanks in advance Best regards André Toscano

sr2ds commented 9 years ago

Hello friend,

I am also Brazilian, good to see you here! I have the same need you, I'm using WhatsAPI because I can go get the user lastseen. My programming skills are somewhat limited, I had to pay a guy to do the job for me. The guy is good and you will leave a stable connection whatsapp for me to use it instead of always start a new all the time, this will prevent the numbers are blocked so often. But he will do so through WhatsApi, which is in PHP. Hugs

aemitos commented 9 years ago

Hey dude, good to know. I can implement the the group commands, but right now I'm very busy, thats why I decided to ask about the shell use option. Since it's argparsed I think there is a way to use but my tests can't allow me to figure out how use yowsup-cli to operate groups. Best regards. André Toscano

aemitos commented 9 years ago

Hey dude, I found a way to execute other commands. First: you have to create a file with all your commands. Example: cmds.txt

/L
/group invite 5519971249XXX-1567421047 55XXXX6177117
/message send 5519971249XXX-1567421047 'Ola grupo, este eh um teste de script' 
/disconnect

Then you have to call yowsup-cli like this:

$ yowsup-cli demos -y -c config.conf < cmds.txt > cmds.log

It will execute the commands but will show the error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.linux-x86_64/egg/yowsup/demos/cli/cli.py", line 150, in startInputThread
    cmd = self._queuedCmds.pop(0) if len(self._queuedCmds) else input(self.getPrompt()).strip()
EOFError: EOF when reading a line

You will have to wait some time and then you must kill the yowsup-cli. Once you killed its process you will have the cmds.log like this:

Yowsup Cli client
==================
Type /help for available commands

[offline]:Auth: Logged in!
[connected]:[connected]:[connected]:[connected]:general: Disconnected: Requested
[connected]:

Yowsdown

It's not the best way but it works. Regards

tgalal commented 9 years ago

The demos under "yowsup-cli demos" are just examples for simple yowsup-based projects. I think creating a new simple project would be easier than hacking around existing ones. Also feel free to submit it to me afterwards and I can add it to demos if I see it fit. Nevertheless the current demos work as supposed to, so I don't think it's really a yowsup problem. I'll close the issue but feel free to keep the discussion going here.

Gonzo2028 commented 7 years ago

well if you would provide some simple switches to yowsup-cli it would make peoples life a lot easir. Add a quit option, and make it work from the shell/shell_exec or shellscripts. Only coders think in this way, that tool is not userfriendly and could be so much more, even if its meant as a demo. Just use your brain for some cosmetics and user-friendlyness would be very appreciated.