-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifier.py
54 lines (46 loc) · 1.95 KB
/
notifier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import yagmail
from plyer import notification
import pyttsx3 # Importa la librería pyttsx3 para TTS
class Notifier:
def __init__(self, email_user, email_password, email_recipient):
self.email_user = email_user
self.email_password = email_password
self.email_recipient = email_recipient
self.yag = yagmail.SMTP(email_user, email_password)
self.tts_engine = pyttsx3.init() # Inicializa el motor TTS
def send_email(self, subject, body):
try:
self.yag.send(to=self.email_recipient, subject=subject, contents=body)
print(f"[+] Correo enviado a {self.email_recipient} con el asunto '{subject}'")
except Exception as e:
print(f"[?] Error al enviar el correo: {e}")
def send_desktop_notification(self, title, message):
try:
notification.notify(
title=title,
message=message,
app_name='Notifier',
timeout=10
)
print(f"[+] Notificación de escritorio enviada: {title}")
except Exception as e:
print(f"[!] Error al enviar la notificación: {e}")
def speak(self, text):
try:
self.tts_engine.say(text)
self.tts_engine.runAndWait()
print(f"[+] Notificación hablada: {text}")
except Exception as e:
print(f"[!] Error al hablar la notificación: {e}")
def notify(self, subject, body):
self.send_email(subject, body)
self.send_desktop_notification(subject, body)
self.speak(body)
# Ejemplo de uso
if __name__ == "__main__":
email_password = 'tu_contraseña'
notifier = Notifier(email_user, email_password, email_recipient)
# Cuando encuentres una vacante
notifier.notify("Vacante Encontrada", "¡Se ha encontrado una vacante! Revisa el sitio para más detalles.")