From ed53da2e6a982cef66c429ae1775cfdebb64f356 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Fri, 8 Mar 2024 02:39:46 +0530 Subject: Added input function to alert --- main.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 76211c4..bc321a6 100644 --- a/main.py +++ b/main.py @@ -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) -- cgit v1.2.3-59-g8ed1b