Skip to content

Commit 434295f

Browse files
authored
Update: Successfully Corrected Linter Errors
1 parent 69a2bf0 commit 434295f

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

Auto Crypto Alert Mail/api_crypto_mail_alert.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import requests
66
import smtplib
77

8-
'''
8+
'''
99
<===== IMPORTANT =====>
1010
1. THIS WILL NOT WORK WHEN SENDING MAIL FROM GMAIL BECAUSE OF NEW GOOGLE SECURITY POLICIES.
1111
2. BUT YOU CAN SEND MAIL FROM OUTLOOK OR ANY OTHER MAIL SERVICES WITHOUT ANY PROBLEM.
@@ -14,24 +14,24 @@
1414
'''
1515

1616
# Add your Email ID & it's Password by which you are sending the email alert
17-
from_email="<SENDER'S_EMAIL_ID>"
18-
from_email_password="<SENDER'S_EMAIL_PASSWORD>"
19-
mail_port=587
20-
mail_server="smtp-mail.outlook.com"
17+
from_email = "<SENDER'S_EMAIL_ID>"
18+
from_email_password = "<SENDER'S_EMAIL_PASSWORD>"
19+
mail_port = 587
20+
mail_server = "smtp-mail.outlook.com"
2121

2222
# Add Email ID to whom you want to send the alert
23-
to_email="RECEIVER'S_EMAIL_ID"
23+
to_email = "RECEIVER'S_EMAIL_ID"
2424

2525

2626
def check_price():
27-
spot_name=input("Input the crypto currency to get alerts (eg. BTCUSDT): ")
27+
spot_name = input("Input the crypto currency to get alerts (eg. BTCUSDT): ")
2828
print("1.If Price hits Above\n2.If Price hits Below\n")
29-
cpolarity=int(input("Choose from 1 & 2: "))
30-
trig_point=1
31-
if cpolarity==1:
32-
trig_point=float(input("Input the trigger price(dollar) above at which you want to recieve mail alert: "))
29+
cpolarity = int(input("Choose from 1 & 2: "))
30+
trig_point = 1
31+
if cpolarity == 1:
32+
trig_point = float(input("Input the trigger price(dollar) above at which you want to recieve mail alert: "))
3333
else:
34-
trig_point=float(input("Input the trigger price(dollar) below at which you want to recieve mail alert: "))
34+
trig_point = float(input("Input the trigger price(dollar) below at which you want to recieve mail alert: "))
3535

3636
def send_mail():
3737
server = smtplib.SMTP(mail_server, mail_port)
@@ -41,40 +41,41 @@ def send_mail():
4141
server.login(from_email, from_email_password)
4242
subject = f"{spot_name.upper()} EXCHANGE RATE"
4343

44-
if cpolarity==1:
44+
if cpolarity == 1:
4545
body = f"{spot_name.upper()} Exchange is now above ${trig_point}: Current Exchange Rate: ${lprice}."
4646
else:
4747
body = f"{spot_name.upper()} Exchange is now below ${trig_point}: Current Exchange Rate: ${lprice}."
48-
48+
4949
msg = f'''Subject: {subject}\n
5050
To: {"".join(to_email)}\n
5151
{body}'''
52-
52+
5353
server.sendmail(from_email, to_email, msg.encode("utf8"))
54-
54+
5555
print("Alert! The E-mail has been sent!")
5656
server.quit()
5757

5858
while True:
5959
Url = "https://api.binance.com/api/v3/ticker/24hr"
6060
r = requests.get(Url)
6161
json_list = r.json()
62-
cryptoname={}
63-
lprice=0
62+
cryptoname = {}
63+
lprice = 0
6464
for i in range(len(json_list)):
65-
if json_list[i]["symbol"]==spot_name.upper():
66-
cryptoname=json_list[i]
65+
if json_list[i]["symbol"] == spot_name.upper():
66+
cryptoname = json_list[i]
6767
try:
68-
lprice=float(cryptoname["lastPrice"])
68+
lprice = float(cryptoname["lastPrice"])
6969
print(lprice)
7070
except:
7171
print("This Exchange is not available.")
7272

73-
if lprice>=trig_point and cpolarity==1:
73+
if lprice >= trig_point and cpolarity == 1:
7474
send_mail()
7575
exit()
76-
if lprice<=trig_point and cpolarity==2:
76+
if lprice <= trig_point and cpolarity == 2:
7777
send_mail()
7878
exit()
7979

80+
8081
check_price()

0 commit comments

Comments
 (0)