From 6223fac89897f09b1d0a6cef95e11b9da3604c82 Mon Sep 17 00:00:00 2001 From: Deadswitch Date: Fri, 17 Jun 2022 16:45:19 -0500 Subject: [PATCH] of course, as usual some bugfixes... --- api1.py | 19 +++++++++---------- session.session | Bin 28672 -> 28672 bytes 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/api1.py b/api1.py index b58b4bd..82bf374 100644 --- a/api1.py +++ b/api1.py @@ -27,7 +27,7 @@ class Config(object): SCHEDULER_API_ENABLED = True -def sendSelfTelegram(message): +def sendSelfTelegram(message,toId): print(f"sending telegram message to myself") # get your api_id, api_hash, token # from telegram as described above @@ -53,8 +53,7 @@ def sendSelfTelegram(message): # signing in the client client.sign_in(phone, input('Enter the code: ')) try: - schlingelId=5070349790 - client.send_message(schlingelId, message, parse_mode='html') + client.send_message(toId, message, parse_mode='html') except Exception as e: # there may be many error coming in while like peer # error, wwrong access_hash, flood_error, etc @@ -64,11 +63,7 @@ def sendSelfTelegram(message): client.disconnect() -def sendMail(topic,toAddr): - if not "@" in toAddr: - print(f"not sending mail - {toAddr} not an email-address.") - return false - +def sendNotification(topic,toAddr): print(f"sending mail to {toAddr} for topic {topic}") port = 25 server=smtplib.SMTP("localhost", port) @@ -79,7 +74,11 @@ def sendMail(topic,toAddr): https://deadswitch.kawomi.com/api/v1?topic={topic} """ - sendSelfTelegram(message) + sendSelfTelegram(message, 5070349790) + + if not "@" in toAddr: + print(f"not sending mail - {toAddr} not an email-address.") + return False server.sendmail(sender_email, receiver_email, message) def expiryCheck(): @@ -90,7 +89,7 @@ def expiryCheck(): for theRow in cursor.execute("select expiry,topic,email from entries where active=True and isNotified=False and expiry < datetime()"): print(theRow) for theEmailAddr in theRow[2].split(','): - sendMail(theRow[1],theEmailAddr) + sendNotification(theRow[1],theEmailAddr) db.execute("update entries set isNotified=True where topic=?",[theRow[1]]) db.commit() db.close() diff --git a/session.session b/session.session index 5a3344b6b9c0fc900bb9fe5136aca1e5b118b5f8..9a090632a3056e8efeae58c5cf248fa494f12987 100644 GIT binary patch delta 19 acmZp8z}WDBae_3X!9*EnMuUwB3-SR+Xa?W_ delta 19 acmZp8z}WDBae_3X&O{k!MxBib3-SR+EC$#B