diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-03-08 04:16:55 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-03-08 04:16:55 +0530 |
commit | a856463136664eb1dd1b5f219277bd3e0d90de1e (patch) | |
tree | 7df08f3966c2c4df13150b81614447b697c99795 | |
parent | ed4925c9e7d616ed0612114a97ac83acff419cea (diff) | |
download | crypto-alert-a856463136664eb1dd1b5f219277bd3e0d90de1e.tar.gz crypto-alert-a856463136664eb1dd1b5f219277bd3e0d90de1e.tar.bz2 crypto-alert-a856463136664eb1dd1b5f219277bd3e0d90de1e.zip |
added multiple crypto coins
-rw-r--r-- | main.py | 88 |
1 files changed, 46 insertions, 42 deletions
@@ -24,53 +24,57 @@ def price(coin_ids): coin_id = coin['id'] if coin_id in coin_ids: btc_price[coin_id] = coin['current_price'] - return btc_price -selected_coins = ['bitcoin', 'ethereum'] +# for multiple input +# user_input = input("Enter the coin IDs (comma-separated) you want to get prices for: ") +# selected_coins = [coin.strip().lower() for coin in user_input.split(',')] + +selected_coins = input("enter the coin you want to view: ").lower() btc_price = price(selected_coins) for coin, price in btc_price.items(): - print(f"{coin.capitalize()}: ${price}") - -#def email(btc): -# # change the email address or create a email.txt file and put your email there -# with open('email.txt', 'r') as file: -# lines = [line.strip() for line in file] -# -# for line in lines: -# sender_email = line -# -# # change the email address or create a pass.txt file and put your email password there -# with open('pass.txt', 'r') as file: -# lines = [line.strip() for line in file] -# -# for line in lines: -# sender_password = line -# -# # change your email to something else the alert will be send to there -# receiver_email = "biswa@dmc.chat" -# -# subject = "BTC Price Alert" -# body = f"The current price of BTC is {btc} USD. Time to make a move!" -# -# message = f"Subject: {subject}\n\n{body}" -# -# # change the mail.pissmail.com to the email provider you use -# with smtplib.SMTP("mail.pissmail.com", 587) as server: -# server.starttls() -# server.login(sender_email, sender_password) -# server.sendmail(sender_email, receiver_email, message) -# -#def check(): -# btc_price = price() -# alert = int(input("enter the alert number you want: ")) -# -# if btc_price > alert: -# email(btc_price) -# print(f"Alert! BTC price is {btc_price} USD. Email sent.") -# -#check() + print(f"{price}") + +def email(btc): + # change the email address or create a email.txt file and put your email there + with open('email.txt', 'r') as file: + lines = [line.strip() for line in file] + + for line in lines: + sender_email = line + + # change the email address or create a pass.txt file and put your email password there + with open('pass.txt', 'r') as file: + lines = [line.strip() for line in file] + + for line in lines: + sender_password = line + + # change your email to something else the alert will be send to there + receiver_email = "biswa@dmc.chat" + + subject = "Crypto Price Alert" + body = f"The current price of {coin.capitalize()} is {btc} USD. Time to make a move!" + + message = f"Subject: {subject}\n\n{body}" + + # change the mail.pissmail.com to the email provider you use + with smtplib.SMTP("mail.pissmail.com", 587) as server: + server.starttls() + server.login(sender_email, sender_password) + server.sendmail(sender_email, receiver_email, message) + +def check(): + btc_price = price + alert = int(input("enter the alert number you want: ")) + + if btc_price > alert: + email(btc_price) + print(f"Alert! BTC price is {btc_price} USD. Email sent.") + + +check() # schedule.every().hour.do(check) # while True: |