push date checker pour pas spam

master
greg 2 years ago
parent fcfe78c2c1
commit 33379827bc
  1. BIN
      __pycache__/env.cpython-39.pyc
  2. 8
      env.py
  3. 49
      python-alert.py
  4. 11
      url.csv

Binary file not shown.

@ -1,5 +1,5 @@
serveurSmtp = ""
serveurSmtp = "mail.gandi.net"
serveurPort = 465
serveurAdrresseMail= ""
serveurMailPassword = ""
mailReception= ""
serveurAdrresseMail= "contact@gregandev.fr"
serveurMailPassword = "JuliettePuce21%"
mailReception= "greg.lebreton@hotmail.com"

@ -7,8 +7,11 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
is_in_alert = False
time_limit = 100 # POUR LE TEMPS ENTRE CHAQUES MAILS UNE FOIS L'ALERTE DÉCLENCHÉE UNE PREMIÈRE FOIS
# FONCTION IMPORT URL FROM CSV + TEST REQUEST
def import_url():
def test_url():
print(time.ctime())
urls_hs = []
@ -25,13 +28,11 @@ def import_url():
else:
print(url + ' / ' + str(response.status_code))
except Exception as e:
urls_hs.append(url)
print(str(e))
#except:
#print('l\'url: ' + url + ' est invalide')
return urls_hs
# FONCTION SEND MAIL
def send_mail(urls_hs):
@ -46,7 +47,7 @@ def send_mail(urls_hs):
if urls_hs:
for url in urls_hs:
mail = " ".join(urls_hs)
contenu = '<h4>Bonjour, voici la liste des sites HS: {mail} <br></h4>\n'.format(mail=mail)
contenu = '<h4>Bonjour, voici la liste du ou des sites HS: {mail} <br></h4>\n'.format(mail=mail)
body = MIMEText(contenu, 'html')
message.attach(body)
@ -62,16 +63,48 @@ def send_mail(urls_hs):
mailReception,
mail_str)
server.quit()
# ALERTE = TRUE
is_in_alert = True
time_stamp = time.ctime()
else:
print('Tout est OK ;)')
is_in_alert = False
print(is_in_alert)
# MAIN (A)
urls = import_url()
# CHECK TIMER FONCTIONS
def check_timer(time_stamp, current_time):
if current_time - time_stamp > time_limit:
print(current_time - time_stamp)
resend = True
else:
resend = False
print(current_time - time_stamp)
return resend
# FONCTION CHECK IF MAIL ALREADY SEND
def check_alert():
if is_in_alert:
# CHECK si timer > 1 heure
resend = check_timer(time_stamp, time.ctime())
if resend:
urls = test_url()
send_mail(urls)
else:
urls = test_url()
send_mail(urls)
# MAIN (A)
check_alert()
# PYTHON TIME (B)
# while True:
# urls = import_url()
# urls = test_url()
# send_mail(urls)
# time.sleep(300)

@ -1,9 +1,2 @@
https://www.gregandev.fr
https://www.wordpress.gregandev.fr
https://medias.gregandev.fr
https://grego.gregandev.fr
https://retroarch.gregandev.fr
https://hugo.gregandev.fr
https://gregstation.gregandev.fr
https://psychologue-ecouen.fr
https://www.terminal-cv.gregandev.fr
https://www.google.com
https://bidon.tld

1 https://www.gregandev.fr https://www.google.com
2 https://www.wordpress.gregandev.fr https://bidon.tld
https://medias.gregandev.fr
https://grego.gregandev.fr
https://retroarch.gregandev.fr
https://hugo.gregandev.fr
https://gregstation.gregandev.fr
https://psychologue-ecouen.fr
https://www.terminal-cv.gregandev.fr
Loading…
Cancel
Save