-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (40 loc) · 1.36 KB
/
main.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
55
56
57
import requests
import json
import smtplib
import ssl
import time
class Work:
def __init__(self):
self.port = 465
self.smtp_server_domain_name = "smtp.gmail.com"
self.sender_mail = "[email protected]"
self.password = "&MN,xHVPbm6J1VL("
def send(self, email, content):
ssl_context = ssl.create_default_context()
service = smtplib.SMTP_SSL(
self.smtp_server_domain_name, self.port, context=ssl_context)
service.login(self.sender_mail, self.password)
result = service.sendmail(
self.sender_mail, email, f"Subject: {content}")
service.quit()
def apiCall():
response = requests.get(
'https://api.coingecko.com/api/v3/coins/markets?vs_currency=USD&order=market_cap_desc&per_page=100&page=1&sparkline=false')
print(response)
x = response.json()
return x[0]['current_price']
#return y['current_price']
def main():
time_interval = 60
work = Work()
#work.send('[email protected]', x)
while True:
price = apiCall()
# if the price falls below threshold, send an immediate msg
if price < 50000:
print(price)
# work.send('[email protected]', f"PriceDrop!! {price}")
# fetch the price for every dash minutes
time.sleep(time_interval)
if __name__ == '__main__':
main()