of course, as usual some bugfixes...

This commit is contained in:
Deadswitch
2022-06-17 16:45:19 -05:00
parent 2f299c96f0
commit 6223fac898
2 changed files with 9 additions and 10 deletions

19
api1.py
View File

@@ -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()

Binary file not shown.