Skip to content

Commit 158c69e

Browse files
Added script for personalizing WhatsApp messages (Logan1x#103)
1 parent af6c0b6 commit 158c69e

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# WhatsApp Personalized Message Sender
2+
3+
This uses selenium to open WhatsApp Web and send personalized messages on your behalf.
4+
5+
## Installation Instructions
6+
7+
- Install Selenium and pandas
8+
9+
```sh
10+
pip install selenium pandas
11+
```
12+
13+
- Download [ChromeDriver](https://chromedriver.chromium.org/) for your appropriate browser version and operating system. Update `PATH_TO_CHROMEDRIVER` in `send_greeting.py`
14+
15+
- Make sure to update the message you want to send.
16+
17+
- Export your contacts and place them in the root directory as `contacts.csv`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pandas as pd
2+
3+
4+
def filter_contacts(filename):
5+
all_contacts = pd.read_csv(filename)
6+
all_contacts = all_contacts[["Name", "Given Name"]]
7+
print("Type Given name if you wish to include them in your Spam list.")
8+
print("To break, Enter x")
9+
print("To keep it same as the given name(the one after -), press f")
10+
wishing_contacts = dict()
11+
for index, row in all_contacts.iterrows():
12+
print(str(row['Name'])+" - "+str(row['Given Name']))
13+
y = input()
14+
if y == 'x':
15+
break
16+
if y == 'f':
17+
wishing_contacts[str(row['Name'])] = str(row['Given Name'])
18+
elif y != '':
19+
wishing_contacts[str(row['Name'])] = y
20+
return wishing_contacts
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from selenium import webdriver
2+
from time import sleep
3+
import filter_contacts
4+
5+
PATH_TO_CHROMEDRIVER = ''
6+
7+
wishingContacts = filter_contacts.filter_contacts("contacts.csv")
8+
driver = webdriver.Chrome(PATH_TO_CHROMEDRIVER)
9+
driver.get('https://web.whatsapp.com')
10+
sleep(15)
11+
contacts = dict()
12+
13+
for key, value in wishingContacts.items():
14+
pre_msg = "SOME PRE SALUTATION MESSAGE"
15+
post_msg = """
16+
SOME POST SALUTATION MESSAGE
17+
"""
18+
input_box = None
19+
try:
20+
input_box = driver.find_element_by_css_selector("input[type='text']")
21+
input_box.click()
22+
input_box.send_keys(key)
23+
sleep(1)
24+
userbox = driver.find_element_by_css_selector("span[title='"+key+"']")
25+
userbox.click()
26+
inputbox = driver.find_element_by_css_selector("div[data-tab='1']")
27+
inputbox.click()
28+
inputbox.send_keys(pre_msg+value+post_msg)
29+
send_button = driver.find_element_by_css_selector(
30+
"span[data-icon='send']")
31+
send_button.click()
32+
sleep(1)
33+
except Exception:
34+
input_box.clear()
35+
continue

0 commit comments

Comments
 (0)