diff options
-rw-r--r-- | main.py | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1,6 +1,8 @@ import requests import smtplib import json +import time +import schedule def price(): url = "https://api.coingecko.com/api/v3/coins/markets" @@ -34,9 +36,17 @@ def email(btc): server.login(sender_email, sender_password) server.sendmail(sender_email, receiver_email, message) -btc_price = price() -alert = 33000 +def check(): + btc_price = price() + alert = input("enter the alert number you want: ") + print(alert) -if btc_price == alert: - email(btc_price) - print(f"Alert! BTC price is {btc_price} USD. Email sent.") + if btc_price == alert: + email(btc_price) + print(f"Alert! BTC price is {btc_price} USD. Email sent.") + +schedule.every().hour.do(check) + +while True: + schedule.run_pending() + time.sleep(1) |