aahnik / wappdriver

Wondering how to send WhatsApp messages using Python using only 3 lines of code? You have come to the right place!
https://aahnik.github.io/wappdriver/
MIT License
46 stars 3 forks source link

How to insert line break? #37

Closed bukanvalen closed 3 years ago

bukanvalen commented 3 years ago

I use it like this

with WhatsApp() as bot:
    for person in recipients:
        bot.send(person, f'Hello {person}\nNew line test')

But then the messages were split into 2 separate messages. I know that the Enter key is the send key in WhatsApp Web. That's why I ask here, how to insert a line break? Thank you

aahnik commented 3 years ago

Thank you for raising this issue.

Earlier this used to work. ( the code that you have written is perfectly correct and used to create a line break )

But today I checked, it is working no more. I don't know why.

In WhatsApp Web SHIFT + ENTER goes to new line. I know this and had implemented in my code.

(wappdriver presses SHIFT + ENTER whenever there is \n)

See this.

It is working while done manually, but inside the script, it seems not to work.

I am trying to solve the issue.

aahnik commented 3 years ago

Actually, I had made a small mistake. I am solving this now.

aahnik commented 3 years ago

@bukanvalen I fixed this issue just now.

Please update the package in your computer.

pip install --upgrade wappdriver

Now your same code would do the work. πŸ˜‡

You don't have to do anything to your code. πŸ˜Šβ˜ΊοΈπŸ™‚πŸ™ƒ. Just update the package, and everything will work fine.

Thanks a lot for reporting this. There was a small mistake in my code, which is now fixed.

aahnik commented 3 years ago

@bukanvalen Please update the package, test it once and say me if it is working as expected.

bukanvalen commented 3 years ago

Thank you so much! Now it works perfectly. Do you mind telling me what did you change and how it fixes the issue? I'm still learning Python, so if you could explain it, I would really appreciate it. Thanks in advance!

aahnik commented 3 years ago

you can understand simply by seeing my commit e9b44d921f9444fd1422fad51179433daf0c6ed6

i just removed a tab :smile: it was a silly mistake from my part

bukanvalen commented 3 years ago

One more thing, thank you so much for creating this. I was having trouble understanding Selenium and then I found your article on DEV. I was really in a pinch to message a bunch of people with custom messages that are tailored based on their name and gender. Now I can just open up Python and run your script, rather than messaging them one by one with some little editing in between.

aahnik commented 3 years ago

That was the main purpose of creating this package. To let people not worry about selenium, chrome driver, selectors, etc, and allow people to easily send messages.

In the future, I will build a command-line version, where you can easily send messages, without even writing any python code.

If you are interested in Python and automation, you may see my Telegram Channel, where I post interesting stuff.

telegram-channel

bukanvalen commented 3 years ago

I'll be waiting for it, thanks for the information!