Tithibots / tithiwa

Automate Web WhatsApp with selenium in python.
MIT License
24 stars 22 forks source link
automated automation hacktoberfest python python-automation python-bot python-selenium-automation selenium selenium-python web-whatsapp web-whatsapp-api whatsapp whatsapp-api whatsapp-bot whatsapp-web
logo

tithiwa - Web WhatsApp bot

Automate Web WhatsApp with selenium.

Check Headless tithiwa challenge

Full explained Videos on that project are coming soon. Stay tune with our youtube channel Noobie Techs

Table of contents

Contribution and creativity points

Selenium automation creativity points

  1. Debugging Example
    We can create breakpoints to pause execution at any time then we can try to run some python code in the console to find a way to do something. That helps to develop efficiently.
  2. CTRL + Left mouse click Example
    We can see the definitions or references or usages of any function or variable in our IDE like PyCharm. That helps to understand the existing code base efficiently.
  3. Inspect elements and console Example
    In chrome, we can inspect HTML elements and run javascript code inside console. That helps up to find better selectors and automations steps efficiently.

NOTE: By pressing UP key we can see the history about what codes we had run during Python debugging and inside Chrome's console.
NOTE: If you are running javascript code inside selenium chromedriver console then it will NOT keep history.
Good luck :)

Automation ideas

from tithiwa import Tithiwa

# Create bot 
tithiwabot = Tithiwa()

## Generate sessions and open sessions
tithiwabot.generate_session("filename")
tithiwabot.open_session("filename")

## Get currently opened Web-WhatsApp's details
print(tithiwabot.get_my_number())
print(tithiwabot.get_my_name())
print(tithiwabot.get_my_about())

## Open chatroom and send message
tithiwabot.open_chat_to("919592140593")
tithiwabot.open_chat_to_number_using_url("919592140593")  # wa.me/919592140593
tithiwabot.send_message_to("919592140593", "Hello, from Tithiwa")

## Get number from contact name
print(tithiwabot.get_mobile_number_of("Contact1"))

## Send a message to multiple chats
tithiwabot.send_message_to_multiple_chats("hello", ["contact1", "contact2", "Group1"])

## Send a message to multiple chats at given time
tithiwabot.send_message_at_time_to(["contact1", "contact2", "Group1"],
                                   "hi, from tithiwa at 9:36PM",
                                   "21:36:00")

## Create new WhatsApp group
tithiwabot.create_group("GroupName", ["contact1", "contact2", "contact2"])

## Scrape members list from group
print(tithiwabot.scrape_members_from_group("GroupName"))  # ["contact1", "contact2", "contact2"]

## Make given contacts as group admins of given group
tithiwabot.make_group_admins("GroupName", ["contact1", "contact2"])

## Remove given contacts from given group
tithiwabot.remove_members_from_group("GroupName", ["contact1", "contact2"])

## Send a message to a group with mentioning all group members
tithiwabot.send_message_with_mention_all_to_group("GroupName", "Hello All")

## Exit from group ✔
tithiwabot.exit_from_group("GroupName1")

## Exit from all groups ✔
tithiwabot.exit_from_all_groups()

## Exit from given groups ✔
tithiwabot.exit_from_groups(["GroupName1", "GroupName2"])

Installation

NOTE - pip contains older version i.e clone repo to use

pip install tithiwa