diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-03-08 02:39:46 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-03-08 02:39:46 +0530 |
commit | ed53da2e6a982cef66c429ae1775cfdebb64f356 (patch) | |
tree | a5e4539b2834a298f7c4dde85238097f3ce6dff8 | |
parent | 7eb97cee178b196881d76291196ac1b054cf9f72 (diff) | |
download | crypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.tar.gz crypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.tar.bz2 crypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.zip |
Added input function to alert
-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) |