-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendTextProto.py
More file actions
34 lines (31 loc) · 1.09 KB
/
sendTextProto.py
File metadata and controls
34 lines (31 loc) · 1.09 KB
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
def pushInStockAlert(body):
print(body)
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'GET FROM CONFIG', 'GET FROM CONFIG' )
from_mail = 'GET FROM CONFIG'
to = 'GET FROM CONFIG'
subject = "Stock Alert"
message = ("From: %s\r\n" % from_mail
+ "To: %s\r\n" % to
+ "Subject: %s\r\n" % subject
+ "\r\n"
+ body)
server.sendmail(from_mail, to, message)
print(inStockIndeces)
if len(inStockIndeces) > 0:
for index in inStockIndeces:
print(products[index].get("url"))
sendText("%s " % products[index].get("name")
+ "is in stock at %s:\r\n" % products[index].get("store")
+ "%s" % shortenUrl(products[index].get("url")))
def shortenUrl(url):
api_key= "GET FROM CONFIG"
api_url = f"https://cutt.ly/api/api.php?key={api_key}&short={url}"
data = requests.get(api_url).json()["url"]
if data["status"] == 7:
shortened_url = data["shortLink"]
return shortened_url
else:
print("[!] Error Shortening URL:", data)
return "Error Shortening URL"