Skip to content
1 change: 1 addition & 0 deletions wplay/about_changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

async def about_changer():
page, _ = await browser_config.configure_browser_and_load_whatsapp()
browser_config.minimize_delay()
query: str = str(input("What's the news theme? : "))

await page.waitForSelector(whatsapp_selectors_dict['profile_photo_element'], visible=True)
Expand Down
1 change: 1 addition & 0 deletions wplay/broadcast_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class InvalidNumber(Exception):

def ProcessNumbers():
__logger.info("Processing numbers.")
browser_config.minimize_delay()
print("Choose a text file containing full numbers with country code, one number per line.")
Tk().withdraw()
filename = askopenfile(
Expand Down
2 changes: 1 addition & 1 deletion wplay/download_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def download_media(target):
)
else:
await target_select.manual_select_target(page)

browser_config.minimize()
count = int(input("Count of media you want to download: "))

# Click on the photo element of the target
Expand Down
1 change: 1 addition & 0 deletions wplay/get_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

async def get_profile_photos():
page, _ = await browser_config.configure_browser_and_load_whatsapp()
browser_config.minimize_delay()
total_contacts = int(input("Please provide total whatsapp contacts: "))
loop = round(total_contacts/7)
images_list = []
Expand Down
1 change: 1 addition & 0 deletions wplay/get_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def fetch_news(country_code):
else:
await target_select.manual_select_target(page)

browser_config.minimize()
country = input("Enter your country code (ex: us or in): ")
while True:
try:
Expand Down
2 changes: 2 additions & 0 deletions wplay/message_blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ async def message_blast(target: str):
await target_search.search_and_select_target_all_ways(page, target)
else:
await target_select.manual_select_target(page)

browser_config.minimize()
message: List[str] = io.ask_user_for_message_breakline_mode()
number_of_messages: int = int(input("Enter the number of messages to blast: "))
__logger.debug("Blasting messages")
Expand Down
3 changes: 2 additions & 1 deletion wplay/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@

async def message_service():
page, _ = await browser_config.configure_browser_and_load_whatsapp()
browser_config.minimize()
__logger.info("Message Service On.")
print("Message Service is ON, press CTRL+C to stop.")
print("Listening for messages in file 'messages.json' inside user/wplay/messagesJSON folder.")
# Initialize a instance of MessageStack

message_stack = MessageStack()
# Move all messages from open_messages.json to messages.json when the program starts
message_stack.move_all_messages(helpers.open_messages_json_path, helpers.messages_json_path)
Expand Down Expand Up @@ -79,6 +81,5 @@ async def message_service():
else:
__logger.debug('Internet is not available, trying again after 15 seconds.')
time.sleep(15)

# Move messages from open_messages.json to messages.json that wasn't sended.
message_stack.move_all_messages(helpers.open_messages_json_path, helpers.messages_json_path)
2 changes: 2 additions & 0 deletions wplay/message_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def message_timer(target):
await target_search.search_and_select_target_without_new_chat_button(page, target)
else:
await target_select.manual_select_target(page)

browser_config.minimize()
# Region INPUTS
__logger.info("Input message information for message timer")
message_type_numbers: int = int(input("How many types of messages will you send? "))
Expand Down
1 change: 1 addition & 0 deletions wplay/online_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async def tracker(target):
else: # if target is none then it allow user to select target manually from browser
target_name = await target_select.manual_select_target(page, hide_groups=True)

browser_config.minimize()
# opens status file of the target person
status_file: str = open(tracking_folder_path / f'status_{target_name}.txt', 'w').close()
status_file: str = open(tracking_folder_path / f'status_{target_name}.txt', 'a')
Expand Down
2 changes: 2 additions & 0 deletions wplay/schedule_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ async def schedule_message(target):
await target_search.search_and_select_target(page, target)
else:
await target_select.manual_select_target(page)

browser_config.minimize()
time_ = input("Enter the schedule time in HH:MM:SS format-> ")
hour, minute, second = time_.split(':')
current_time = datetime.now()
Expand Down
2 changes: 2 additions & 0 deletions wplay/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async def target_info(target):
await target_search.search_and_select_target_without_new_chat_button(page, target)
else:
await target_select.manual_select_target(page)

browser_config.minimize()
"""
# to find location by ip address
print('Get you ipinfo token from https://ipinfo.io/account')
Expand Down
11 changes: 8 additions & 3 deletions wplay/terminal_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


async def chat(target):
initial_minimize = True
__logger.info("Chatting with target")
page, _ = await browser_config.configure_browser_and_load_whatsapp()

Expand All @@ -34,6 +35,10 @@ async def chat(target):
print("\033[91m {}\033[00m".format("\nType '...' in a new line or alone in the message to change target person.\nType '#_FILE' to send Image/Video/Documentd etc.\n"))

while True:
if (initial_minimize):
browser_config.minimize()
initial_minimize = False

await getMessages(page, target)
message: list[str] = io.ask_user_for_message_breakline_mode()

Expand Down Expand Up @@ -73,15 +78,15 @@ async def getMessages(pg, tg):
print(e)
lastMessage = ""
lastOutgoingMessage = ''
if tg.lower() in last_message_sender.lower() and lastOutgoingMessage!=lastMessage:
if tg.lower() in last_message_sender.lower() and lastOutgoingMessage != lastMessage:
print(Fore.GREEN + f"{tg}-", end="")
print(lastMessage, end="")
if '/image' in lastMessage:
bot_msg=await chatbot.Bot(last_Message = lastMessage)
bot_msg = await chatbot.Bot(last_Message = lastMessage)
await io.send_message(pg, bot_msg)
await io.send_file(pg)
elif lastMessage[0] == '/':
bot_msg=await chatbot.Bot(last_Message = lastMessage)
bot_msg = await chatbot.Bot(last_Message = lastMessage)
await io.send_message(pg, bot_msg)
print(Style.RESET_ALL)
lastOutgoingMessage = lastMessage
17 changes: 17 additions & 0 deletions wplay/utils/browser_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def my_script(target):
# region IMPORTS
from typing import Any, List
from pathlib import Path
import win32gui, win32con
import time

import websockets.client
from pyppeteer import launch, connection, launcher
Expand Down Expand Up @@ -137,6 +139,21 @@ async def __set_view_port(page: Page):
await page.setViewport({'width': 1280, 'height': 800})
# endregion

def minimize_delay():
#Waiting time for Login
time.sleep(8)
#Minimizing the Window after Target Select
print("Browser Minimized")
Minimize = win32gui.GetForegroundWindow()
win32gui.ShowWindow(Minimize, win32con.SW_MINIMIZE)
#endregion

def minimize():
#Minimizing the Window after Target Select
print("Browser Minimized")
Minimize = win32gui.GetForegroundWindow()
win32gui.ShowWindow(Minimize, win32con.SW_MINIMIZE)
#endregion

# region CODE THAT MIGHT BE USEFUL SOMEDAY
'''
Expand Down