Skip to content

Commit

Permalink
added get_my_number()
Browse files Browse the repository at this point in the history
fixed #54
  • Loading branch information
NavpreetDevpuri committed Dec 26, 2020
1 parent 75187f5 commit 609995e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 40 deletions.
95 changes: 57 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,104 @@
# tithiwa - Web WhatsApp bot

Automate Web WhatsApp with selenium.

# Check Headless tithiwa [challenge](https://github.com/Tithibots/tithiwa/issues/64)

Full explained Videos on that project are coming soon. Stay tune with our youtube channel [Noobie Techs](https://www.youtube.com/c/NoobieTechsTithi_mukherjee/)
Full explained Videos on that project are coming soon. Stay tune with our youtube
channel [Noobie Techs](https://www.youtube.com/c/NoobieTechsTithi_mukherjee/)

Table of contents
* [Contribution and creativity points](#contribution)
* [Automation ideas](#automation-ideas)
* [Installation](#installation)


* [Contribution and creativity points](#contribution)
* [Automation ideas](#automation-ideas)
* [Installation](#installation)

## Contribution and creativity points
Selenium automation creativity points
1. **Debugging** [Example](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710778130)<br> 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](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710779007)<br> 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](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710781167)<br> 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.<br>
NOTE: If you are running javascript code inside selenium chromedriver's console then it will **NOT** keep history.<br>
Selenium automation creativity points

1. **Debugging** [Example](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710778130)<br> 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](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710779007)<br> 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](https://github.com/Tithibots/tithiwa/issues/50#issuecomment-710781167)<br>
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.<br>
NOTE: If you are running javascript code inside selenium chromedriver console then it will **NOT** keep history.<br>
Good luck :)

## Automation ideas

- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/23): Clear chats of all groups
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/24): Clear chats of all contacts
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/25): Clear all chats both groups and contacts
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/26): Auto-reply given messages to some given messages
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/27): Scrap chat as text
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/28): Track online status of given number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/29): Send given message to given contacts at some given time i.e schedule messages
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/23): Clear chats of all groups
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/24): Clear chats of all contacts
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/25): Clear all chats both groups and contacts
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/26): Auto-reply given messages to some given messages
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/27): Scrap chat as text
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/28): Track online status of given number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/29): Send a given message to given contacts at some given time
i.e schedule messages
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/53): Join group by invite link
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/39): Change Web WhatsApp's settings
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/42): Scape all contacts and send message containing URL to their own chatroom
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/54): Get currently opened Web WhatsApp's mobile number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/55): Open chat to the same number as currently opened Web WhatsApp's number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/39): Change Web WhatsApp's settings
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/42): Scape all contacts and send a message containing URL to
their own chatroom
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/54): Get currently opened Web WhatsApp's mobile number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/55): Open chat to the same number as currently opened Web
WhatsApp's number
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/56): Join multiple groups by invite links
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/61): Delete chats of all exited groups
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/62): Delete chats of all contacts
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/60): Get number from contact name
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/66): Get number of views to my status
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/67): Get my name
- [ ] [Todo](https://github.com/Tithibots/tithiwa/issues/68): Get my about

```python
from tithiwa import Tithiwa

# Create bot
tithiwabot = Tithiwa()

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

## Open chatroom and send message ✔
## 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.open_chat_to_number_using_url("919592140593") # wa.me/919592140593
tithiwabot.send_message_to("919592140593", "Hello, from Tithiwa")

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

## Send a message to multiple chats
## 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
## 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
## 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"]
## Scrape members list from group
print(tithiwabot.scrape_members_from_group("GroupName")) # ["contact1", "contact2", "contact2"]

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

## Remove given contacts from given group
## 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
## 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 ✔
Expand All @@ -95,7 +113,8 @@ tithiwabot.exit_from_all_groups()
tithiwabot.exit_from_groups(["GroupName1", "GroupName2"])
```

## Installation
## Installation

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

`
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="tithiwa",
version="0.1.29",
version="0.1.30",
description="tithiwa - Web WhatsApp bot: Automate Web WhatsApp with selenium in python.",
py_modules=["chatroom", "constants", "flextithiwa", "group", "session", "messages", "tithiwa"],
packages=find_packages(),
Expand All @@ -22,7 +22,7 @@
'tithiwa = tithiwa.__main__:main',
],
},
url="https://github.com/Maskgirl/tithiwa",
url="https://github.com/Tithibots/tithiwa",
author="Navpreet Devpuri and Sulagna Mukherjee",
author_email="NavpreetDevpuri@gmail.com",
install_requires=[
Expand Down
3 changes: 3 additions & 0 deletions tithiwa/waobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,6 @@ def get_my_name(self):
self._wait_for_presence_of_all_elements(SELECTORS.NAME_AND_ABOUT)[0])
self._press_back_button()
return name

def get_my_number(self):
return self.browser.execute_script("return localStorage['last-wid'].slice(0, -6);")

0 comments on commit 609995e

Please sign in to comment.