Untitled
unknown
plain_text
a year ago
3.1 kB
5
Indexable
Never
from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from collections import deque import time import random import argparse CHANGELOG= "Version 0.3: ahora es mas facil hacer pruebas" TARGETLIST = ['"🛵 Bro’s"', '"AniHentaiKawaii (。・ω・。)ノ♡"', '"Chivahermanos ⚪🔴🔵"'] MESSAGES = ["Shi", "Perro eda", "Ando loco", "Alguien anda de malas", "Auauauauaua", "Yeeeehaaaaa", "Que loco dios", "Tons que", "Amos?", "Duraz0"] CHIVAHERMANOS = MESSAGES + ["Putas chivas", "Vete alv Lucho auauauaua", "Callate amargo"] def get_args(): parser = argparse.ArgumentParser() parser.add_argument( "-t", "--test", action='store_true', ) parser.add_argument( "-f", "--firstrun", action='store_true' ) return parser.parse_args() def get_target_list(args): if args.test: target_list = ['"Dorian Echeverria"'] else: target_list = TARGETLIST return target_list def find_target(target): contact_path='//span[contains(@title,'+ target +')]' contact=wait.until(EC.presence_of_element_located((By.XPATH,contact_path))) contact.click() message_box_path='//*[@id="main"]/footer/div[1]/div/span[2]/div/div[2]/div[1]/div/div[1]' message_box=wait.until(EC.presence_of_element_located((By.XPATH,message_box_path))) return message_box def chose_message(target): message_list = [] if '"Chivahermanos ⚪🔴🔵"' == target: message_list=CHIVAHERMANOS else: message_list=MESSAGES message_to_send=random.choice(message_list) while message_to_send in used: message_to_send=random.choice(message_list) return message_to_send if __name__ == '__main__': args = get_args() options = webdriver.ChromeOptions() options.add_argument("user-data-dir=/Users/dorian/Library/Application Support/Google/Chrome/") driver = webdriver.Chrome(options=options) driver.get("https://web.whatsapp.com/") wait = WebDriverWait(driver, 100) used = deque(["", "", ""]) target_list = get_target_list(args) if args.firstrun: message_box = find_target('"🛵 Bro’s"') message_box.send_keys(CHANGELOG + Keys.ENTER) while True: for target in target_list: message_box = find_target(target) message_to_send = chose_message(target) message_box.send_keys(message_to_send + Keys.ENTER) used.append(message_to_send) if len(used) > 3: used.popleft() if args.test: time_to_sleep=5 else: time_to_sleep=random.randrange(18000, 86400) message_box = find_target('"Dorian Echeverria"') sleep_message="Cayendome {} horas".format(time_to_sleep/60/60) message_box.send_keys(sleep_message + Keys.ENTER) time.sleep(time_to_sleep) driver.quit()