jctissier / whatsapp-assistant-bot Goto Github PK
View Code? Open in Web Editor NEWA personal WhatsApp assistant bot that will help you search anything on the web (Google, Images, Google Maps)
License: MIT License
A personal WhatsApp assistant bot that will help you search anything on the web (Google, Images, Google Maps)
License: MIT License
I want to get new messages after connection and respond accordingly is it possible any guide.
When i run commands nothing happen. They just show up in the console log.
also
thsi happens when i google something
('/google yes', '18-56-58')
Command args: ['google', 'yes']
Traceback (most recent call last):
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 339, in <module>
Bot()
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 48, in __init__
self.init_bot()
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 52, in init_bot
self.poll_chat()
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 69, in poll_chat
self.bot_options(action=last_msg)
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 91, in bot_options
g_search.search(qry=query)
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 187, in search
send_message("Searching Google for: '{qry}'".format(qry=qry))
File "c:\Users\Gerrid\Documents\whatsapp-assistant-bot\whatsapp_assistant_bot.py", line 325, in send_message
whatsapp_msg = driver.find_element_by_class_name(MESSAGE_BUBBLE_CLASS_NAME)
File "C:\Users\Gerrid\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 564, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "C:\Users\Gerrid\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\Gerrid\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Gerrid\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"._13mgZ"}
(Session info: chrome=89.0.4389.114)
Hi, thanks for sharing such interesting bot
I've tried to follow all the instruction but it is just not working.
after I scan the barcode and select the chat it shows this in the console:
➜ whatsapp-assistant-bot git:(master) python3 whatsapp_assistant_bot.py
Bot is active, scan your QR code from your phone's WhatsApp
('/help', '13-46-21')
Command args: ['help']
Asking for help
Traceback (most recent call last):
File "whatsapp_assistant_bot.py", line 337, in
Bot()
File "whatsapp_assistant_bot.py", line 44, in init
self.init_bot()
File "whatsapp_assistant_bot.py", line 48, in init_bot
self.poll_chat()
File "whatsapp_assistant_bot.py", line 65, in poll_chat
self.bot_options(action=last_msg)
File "whatsapp_assistant_bot.py", line 80, in bot_options
send_message(simple_menucommand_args[0])
File "whatsapp_assistant_bot.py", line 323, in send_message
whatsapp_msg = driver.find_element_by_class_name('_2S1VP')
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
'value': value})['value']
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"class name","selector":"_2S1VP"}
(Session info: chrome=74.0.3729.169)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.13.6
any thoughts?
hello I would like to help me with a question I have, I would like to find the contact id in whatsapp to which you are receiving the message or how to automate the message so as not to click on the contact
Thank you!. :)
Here is the modified one
attach_xpath = '//*[@id="main"]/header/div[3]/div/div[2]/div'
send_file_xpath = '/html/body/div[1]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
attach_type_xpath = '/html/body/div[1]/div/div/div[4]/div/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button/input'
Hello, jctissier,
I recently tested your code and found a interesting thing.
After I used some commands (including /help) and at last I tried /all_commands. I got a entire content of "/help" while using the command /all_commands.
I modified the code a little bit to support two-way inputs (sender+receiver), but... I tried the original code as well and the same things happens.
Here's a screenshot of it (but unfortunately I don't have the "logs" from the terminal)
Hope for the best.
QT0̸
Aparently the Bubble Tag is not called bubble anymore, therefore
`def chat_history():
text_bubbles = driver.find_elements_by_class_name("message-out") # message-in = receiver, message-out = sender
tmp_queue = []
try:
for bubble in text_bubbles:
msg_texts = bubble.find_elements_by_class_name("copyable-text")
for msg in msg_texts:
#raw_msg_text = msg.find_element_by_class_name("selectable-text.invisible-space.copyable-text").text.lower()
# raw_msg_time = msg.find_element_by_class_name("bubble-text-meta").text # time message sent
tmp_queue.append(msg.text.lower())
if len(tmp_queue) > 0:
return tmp_queue[-1] # Send last message in list
except StaleElementReferenceException as e:
print(str(e))
# Something went wrong, either keep polling until it comes back or figure out alternative
return False`
Anyway, this is just the beginning as am getting "selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"class name","selector":"pluggable-input-body"}" so i guess classes have to be updated.
Hey I'm getting this error while running the script .Could ya help me out ??
('/google bots', '14-05-28')
Command args: ['google', 'bots']
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/input"}
(Session info: chrome=73.0.3683.86)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.17134 x86_64)
('bot failed to retrieve search content, try again...', '14-05-42')
Hi @jctissier,
I just found your project and it looks promising.
I once used https://github.com/tgalal/yowsup only for receiving Whatsapp messages. Until yowsup started to become too much of a struggle to keep it running and I abandoned it. I now think yowsup has too many problems and is dead.
I have been experimenting with WhatsappWeb, Selenium and Ruby for receiving Whatsapp messages, but found it not stable and quick enough.
Do you think, it would be possible to use/extent your project for receiving messages (with attachments) from multiple unknown contacts and simply passing them on to a webservice for processing?
Thanks
Christian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.