Skip to content

Commit

Permalink
Merge pull request Ankit404butfound#299 from Vashesh08/master
Browse files Browse the repository at this point in the history
Adding Support For Emoji -- Issue Ankit404butfound#274
  • Loading branch information
Ankit404butfound authored Aug 30, 2023
2 parents 3a582c4 + af2cc7d commit 8875b3b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
22 changes: 19 additions & 3 deletions pywhatkit/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
click(WIDTH / 2, HEIGHT / 2 + 15)
time.sleep(wait_time - 7)
if not check_number(number=receiver):
for char in message:
if char == "\n":
index = 0
length = len(message)
while index < length:
letter = message[index]
if letter == ":":
typewrite(letter)
index += 1
while index < length:
letter = message[index]
if letter == ":":
press("enter")
break
typewrite(letter)
index += 1
elif letter == "\n":
hotkey("shift", "enter")
else:
typewrite(char)
typewrite(letter)
index += 1
press("enter")

findtextbox()
press("enter")

Expand Down
22 changes: 17 additions & 5 deletions pywhatkit/whats.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ def sendwhatmsg_instantly(
if not fullmatch(r"^\+?[0-9]{2,4}\s?[0-9]{9,15}", phone_no):
raise exceptions.InvalidPhoneNumber("Invalid Phone Number.")

web.open(f"https://web.whatsapp.com/send?phone={phone_no}&text={quote(message)}")
time.sleep(4)
pg.click(core.WIDTH / 2, core.HEIGHT / 2 + 15)
time.sleep(wait_time - 4)
core.findtextbox()
web.open(f"https://web.whatsapp.com/send?phone={phone_no}")
time.sleep(wait_time)
index = 0
length = len(message)
while index < length:
letter = message[index]
pg.write(letter)
if letter == ":":
index += 1
while index < length:
letter = message[index]
if letter == ":":
pg.press("enter")
break
pg.write(letter)
index += 1
index += 1
pg.press("enter")
log.log_message(_time=time.localtime(), receiver=phone_no, message=message)
if tab_close:
Expand Down

0 comments on commit 8875b3b

Please sign in to comment.