aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-03-08 02:39:46 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-03-08 02:39:46 +0530
commited53da2e6a982cef66c429ae1775cfdebb64f356 (patch)
treea5e4539b2834a298f7c4dde85238097f3ce6dff8
parent7eb97cee178b196881d76291196ac1b054cf9f72 (diff)
downloadcrypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.tar.gz
crypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.tar.bz2
crypto-alert-ed53da2e6a982cef66c429ae1775cfdebb64f356.zip
Added input function to alert
-rw-r--r--main.py20
1 files 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)