Skip to content

Instantly share code, notes, and snippets.

@gbrls
Created June 3, 2021 02:44
Show Gist options
  • Save gbrls/72b4ec73c9936b6ae3008d4fd21b9d50 to your computer and use it in GitHub Desktop.
Save gbrls/72b4ec73c9936b6ae3008d4fd21b9d50 to your computer and use it in GitHub Desktop.
bot zipzop
import os, time, datetime, random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
img_src = 'blob:https://web.whatsapp.com/4227946a-7a10-47e5-8128-96bead7c0b87'
msg_opt = ['opa', 'chega mais', 'Opa', 'lansa a braba', 'pode mandar', 'manda','opa']
random.seed(datetime.datetime.now())
rescan_delay = 5
def notify(summary, body):
cmd = '''notify-send "{}" "{}"'''.format(summary, body)
os.system(cmd)
def parse_html(html):
soup = BeautifulSoup(html, 'html.parser')
imgs = soup.find_all('img')
f=False
for img in imgs:
#print('Image src: {}'.format(img.get('src')))
if img.get('src') == img_src:
#print('Imagem! {}', soup.find_all('data-pre-plain-text'))
f=True
return f
#print(soup.prettify())
def send_message(msg):
els = driver.find_elements_by_class_name(text_box_id)
els[1].send_keys(msg)
time.sleep(1)
btn = driver.find_element_by_class_name('_3M-N-')
btn.click()
def time_now():
now = datetime.datetime.now()
current_time = now.strftime("%H:%M")
return current_time
def log(txt):
print('({}) {}'.format(time_now(),txt))
driver = webdriver.Firefox()
driver.get('https://web.whatsapp.com/')
notify('python', 'Digite o link da figurinha')
img_src = input('coloque o id da figutinha por favor: ')
notify('python', 'rodando')
# Selecionar o grupo certo
msg_id = 'FTBzM'
text_box_id = '_3u328'
messages = driver.find_elements_by_class_name(msg_id)
respondidas = set()
while 1:
time.sleep(rescan_delay)
messages = driver.find_elements_by_class_name(msg_id)
for m in messages:
log('{} mensagens'.format(len(messages)))
try:
if parse_html(m.get_attribute('innerHTML')):
log('Imagem achada!!! uhu')
dates = m.find_elements_by_class_name('_3fnHB')
for date in dates:
log('DATE: ({})'.format(date.text))
if not date.text in respondidas:
strg = date.text + ' ' + time_now()
#send_message(strg)
idx = random.randrange(0, len(msg_opt)-2)
log('sending {}'.format(msg_opt[idx]))
send_message(msg_opt[idx])
notify('Aluno', 'Dúvida')
respondidas.add(date.text)
except:
log('ero ou sla')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment