-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (30 loc) · 994 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import requests
from twilio.rest import Client
MY_LAT = 32.080898
MT_LONG = -81.091202
API_KEY = ".....5baca9a4d02d0159c62ae9....." # os.environ.get("API_KEY")
account_sid = "AC63f919d11afd.....fc6f27c3bf39e15"
auth_token = ".....5390da997ff37c04635842....." # os.environ.get("AUTH_TOKEN")
BASE_URL = "https://api.openweathermap.org/data/2.5/forecast"
parameters = {
"lat": MY_LAT,
"lon": MT_LONG,
"appid": API_KEY,
"cnt": 4
}
weather_data = requests.get(url=BASE_URL, params=parameters).json()
will_rain = False
for hour_data in weather_data["list"]:
condition_code = hour_data["weather"][0]["id"]
if int(condition_code) < 700:
will_rain = True
if will_rain:
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body="It might rain in sometime, bring your umbrella ☔",
from_="+16592772178",
to="+917277679361"
)
print(message.status)