def interact_with_whats_app(): client_headless = WhatsApp(driver_config) client_headless.open_whats_app_web() print( client_headless.send_message('Veera Mani', 'Testing ignore', Constants.TEXT)) client_headless.close_whats_app()
def log_in(): driver_config_head = driver_config driver_config['driver_headless'] = False client_login = WhatsApp(driver_config=driver_config_head) client_login.open_whats_app_web() sleep(5) if client_login.is_logged_in(): print('Login Successful') client_login.close_whats_app() return True else: print('Login unsuccessful') client_login.close_whats_app() return False
sleep(5) if client_login.is_logged_in(): print('Login Successful') client_login.close_whats_app() return True else: print('Login unsuccessful') client_login.close_whats_app() return False def interact_with_whats_app(): client_headless = WhatsApp(driver_config) client_headless.open_whats_app_web() print(client_headless.send_message('ME', 'Testing', Constants.TEXT)) client_headless.close_whats_app() if __name__ == '__main__': client = WhatsApp(driver_config) is_logged_in = client.is_logged_in() client.close_whats_app() if is_logged_in: interact_with_whats_app() else: if log_in(): interact_with_whats_app() else: print('Please try again later')
def launch_whats_app(): global client logger.info("Auto whats app started!!!") client = WhatsApp(driver_config) client.open_whats_app_web() idle(1, 'main opened whats app')