Skip to content

Commit 65d667f

Browse files
authored
Merge pull request #1 from Ankit404butfound/master
updating fork
2 parents 1eab686 + 9c9121b commit 65d667f

File tree

9 files changed

+161
-49
lines changed

9 files changed

+161
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Links
1818

19-
- **Join our discord server - [Discord](https://discord.gg/yXYUS8R7)**
19+
- **Join our discord server - https://discord.gg/2GBF5VSPDj
2020
- **Documentation - [Wiki](https://github.com/Ankit404butfound/PyWhatKit/wiki)**
2121

2222
## Installation and Supported Versions

pywhatkit/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Version 5.2
1+
""" Version 5.2
22
# Status: Stable
33
# Documentation: https://github.com/Ankit404butfound/PyWhatKit/wiki
44
# Report Bugs and Feature Requests here: https://github.com/Ankit404butfound/PyWhatKit/issues
55
# For further Information, Join our Discord: https://discord.gg/62Yf5mushu
6-
6+
"""
77
__VERSION__ = "Version 5.3 (Stable)"
88

99
from platform import system
1010

1111
from pywhatkit.ascii_art import image_to_ascii_art
1212
from pywhatkit.handwriting import text_to_handwriting
1313
from pywhatkit.mail import send_hmail, send_mail
14-
from pywhatkit.misc import info, playonyt, search, show_history, take_screenshot
14+
from pywhatkit.misc import info, playonyt, search, show_history
1515
from pywhatkit.sc import cancel_shutdown, shutdown
1616
from pywhatkit.whats import (
1717
open_web,
@@ -20,6 +20,8 @@
2020
sendwhatmsg_to_group,
2121
sendwhatmsg_to_group_instantly,
2222
sendwhats_image,
23+
sendwhatdoc_immediately,
24+
sendimg_or_video_immediately
2325
)
2426

2527
_system = system().lower()

pywhatkit/core/core.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@ def findtextbox() -> None:
4646
click()
4747

4848

49+
def find_link():
50+
dir_path = os.path.dirname(os.path.realpath(__file__))
51+
location = locateOnScreen(f"{dir_path}\\data\\link.png")
52+
print(location)
53+
try:
54+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
55+
click()
56+
except Exception:
57+
location = locateOnScreen(f"{dir_path}\\data\\link2.png")
58+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
59+
print(location)
60+
click()
61+
def find_document():
62+
dir_path = os.path.dirname(os.path.realpath(__file__))
63+
location = locateOnScreen(f"{dir_path}\\data\\document.png")
64+
print(location)
65+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
66+
click()
67+
68+
def find_photo_or_video():
69+
dir_path = os.path.dirname(os.path.realpath(__file__))
70+
location = locateOnScreen(f"{dir_path}\\data\\photo_or_video.png")
71+
print(location)
72+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
73+
click()
74+
4975
def check_connection() -> None:
5076
"""Check the Internet connection of the Host Machine"""
5177

pywhatkit/core/data/document.png

317 Bytes
Loading

pywhatkit/core/data/link.png

610 Bytes
Loading

pywhatkit/core/data/link2.png

442 Bytes
Loading
434 Bytes
Loading

pywhatkit/whats.py

Lines changed: 119 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import os
12
import time
23
import webbrowser as web
34
from datetime import datetime
45
from re import fullmatch
56
from typing import List
67
from urllib.parse import quote
7-
8+
import paperclip
89
import pyautogui as pg
9-
10+
import pyperclip
11+
import keyboard
1012
from pywhatkit.core import core, exceptions, log
1113

1214
pg.FAILSAFE = False
@@ -15,11 +17,11 @@
1517

1618

1719
def sendwhatmsg_instantly(
18-
phone_no: str,
19-
message: str,
20-
wait_time: int = 15,
21-
tab_close: bool = False,
22-
close_time: int = 3,
20+
phone_no: str,
21+
message: str,
22+
wait_time: int = 15,
23+
tab_close: bool = False,
24+
close_time: int = 3,
2325
) -> None:
2426
"""Send WhatsApp Message Instantly"""
2527

@@ -41,14 +43,90 @@ def sendwhatmsg_instantly(
4143
core.close_tab(wait_time=close_time)
4244

4345

46+
def sendimg_or_video_immediately(
47+
phone_no: str,
48+
path: str,
49+
wait_time: int = 15,
50+
tab_close: bool = False,
51+
close_time: int = 3,
52+
) -> None:
53+
"""Send WhatsApp Message Instantly"""
54+
55+
if not core.check_number(number=phone_no):
56+
raise exceptions.CountryCodeException("Country Code Missing in Phone Number!")
57+
58+
phone_no = phone_no.replace(" ", "")
59+
if not fullmatch(r"^\+?[0-9]{2,4}\s?[0-9]{9,15}", phone_no):
60+
raise exceptions.InvalidPhoneNumber("Invalid Phone Number.")
61+
62+
web.open(f"https://web.whatsapp.com/send?phone={phone_no}")
63+
time.sleep(wait_time)
64+
core.find_link()
65+
time.sleep(1)
66+
core.find_photo_or_video()
67+
68+
pyperclip.copy(os.path.abspath(path))
69+
print("Copied")
70+
time.sleep(1)
71+
keyboard.press("ctrl")
72+
keyboard.press("v")
73+
keyboard.release("v")
74+
keyboard.release("ctrl")
75+
time.sleep(1)
76+
keyboard.press("enter")
77+
keyboard.release("enter")
78+
time.sleep(1)
79+
keyboard.press("enter")
80+
keyboard.release("enter")
81+
if tab_close:
82+
core.close_tab(wait_time=close_time)
83+
84+
def sendwhatdoc_immediately(
85+
phone_no: str,
86+
path: str,
87+
wait_time: int = 15,
88+
tab_close: bool = True,
89+
close_time: int = 3,
90+
) -> None:
91+
"""Send WhatsApp Message Instantly"""
92+
93+
if not core.check_number(number=phone_no):
94+
raise exceptions.CountryCodeException("Country Code Missing in Phone Number!")
95+
96+
phone_no = phone_no.replace(" ", "")
97+
if not fullmatch(r"^\+?[0-9]{2,4}\s?[0-9]{9,15}", phone_no):
98+
raise exceptions.InvalidPhoneNumber("Invalid Phone Number.")
99+
100+
web.open(f"https://web.whatsapp.com/send?phone={phone_no}")
101+
time.sleep(wait_time)
102+
core.find_link()
103+
time.sleep(1)
104+
core.find_document()
105+
pyperclip.copy(os.path.abspath(path))
106+
print("Copied")
107+
time.sleep(1)
108+
keyboard.press("ctrl")
109+
keyboard.press("v")
110+
keyboard.release("v")
111+
keyboard.release("ctrl")
112+
time.sleep(1)
113+
keyboard.press("enter")
114+
keyboard.release("enter")
115+
time.sleep(1)
116+
keyboard.press("enter")
117+
keyboard.release("enter")
118+
if tab_close:
119+
core.close_tab(wait_time=close_time)
120+
121+
44122
def sendwhatmsg(
45-
phone_no: str,
46-
message: str,
47-
time_hour: int,
48-
time_min: int,
49-
wait_time: int = 15,
50-
tab_close: bool = False,
51-
close_time: int = 3,
123+
phone_no: str,
124+
message: str,
125+
time_hour: int,
126+
time_min: int,
127+
wait_time: int = 15,
128+
tab_close: bool = False,
129+
close_time: int = 3,
52130
) -> None:
53131
"""Send a WhatsApp Message at a Certain Time"""
54132
if not core.check_number(number=phone_no):
@@ -86,13 +164,13 @@ def sendwhatmsg(
86164

87165

88166
def sendwhatmsg_to_group(
89-
group_id: str,
90-
message: str,
91-
time_hour: int,
92-
time_min: int,
93-
wait_time: int = 15,
94-
tab_close: bool = False,
95-
close_time: int = 3,
167+
group_id: str,
168+
message: str,
169+
time_hour: int,
170+
time_min: int,
171+
wait_time: int = 15,
172+
tab_close: bool = False,
173+
close_time: int = 3,
96174
) -> None:
97175
"""Send WhatsApp Message to a Group at a Certain Time"""
98176

@@ -124,11 +202,11 @@ def sendwhatmsg_to_group(
124202

125203

126204
def sendwhatmsg_to_group_instantly(
127-
group_id: str,
128-
message: str,
129-
wait_time: int = 15,
130-
tab_close: bool = False,
131-
close_time: int = 3,
205+
group_id: str,
206+
message: str,
207+
wait_time: int = 15,
208+
tab_close: bool = False,
209+
close_time: int = 3,
132210
) -> None:
133211
"""Send WhatsApp Message to a Group Instantly"""
134212

@@ -141,13 +219,13 @@ def sendwhatmsg_to_group_instantly(
141219

142220

143221
def sendwhatsmsg_to_all(
144-
phone_nos: List[str],
145-
message: str,
146-
time_hour: int,
147-
time_min: int,
148-
wait_time: int = 15,
149-
tab_close: bool = False,
150-
close_time: int = 3,
222+
phone_nos: List[str],
223+
message: str,
224+
time_hour: int,
225+
time_min: int,
226+
wait_time: int = 15,
227+
tab_close: bool = False,
228+
close_time: int = 3,
151229
):
152230
for phone_no in phone_nos:
153231
sendwhatmsg(
@@ -156,14 +234,14 @@ def sendwhatsmsg_to_all(
156234

157235

158236
def sendwhats_image(
159-
receiver: str,
160-
img_path: str,
161-
time_hour: int,
162-
time_min: int,
163-
caption: str = "",
164-
wait_time: int = 15,
165-
tab_close: bool = False,
166-
close_time: int = 3,
237+
receiver: str,
238+
img_path: str,
239+
time_hour: int,
240+
time_min: int,
241+
caption: str = "",
242+
wait_time: int = 15,
243+
tab_close: bool = False,
244+
close_time: int = 3,
167245
) -> None:
168246
"""Send Image to a WhatsApp Contact or Group at a Certain Time"""
169247

requirements.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Pillow
2-
pyautogui
3-
requests
4-
wikipedia
1+
Pillow~=9.3.0
2+
pyautogui~=0.9.53
3+
requests~=2.28.1
4+
wikipedia~=1.4.0
5+
paperclip~=2.6.1
6+
flask~=2.2.2
7+
8+
setuptools~=62.1.0
9+
pyperclip~=1.8.2
10+
keyboard~=0.13.5

0 commit comments

Comments
 (0)