-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
83 lines (61 loc) · 3.05 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import requests
import pywhatkit
import time
apikey = '162d6356ccd1d556cffa732d068d6fb4'
City = 'Varanasi'
weather_data = requests.get(
f"https://api.openweathermap.org/data/2.5/weather?q={City}&units=metric&APPID={apikey}")
weather = (weather_data.json()['weather'][0]['main'])
temp = round(weather_data.json()['main']['temp'])
print(weather,temp)
if temp < 20:
temp = str(temp)
text = temp+"°C"+"--> Low temperature! Get a sweater..."
elif temp > 30:
temp = str(temp)
text = temp+"°C" +"--> High Temperature! Don't get affected by the https://open.spotify.com/track/3USxtqRwSYz57Ewm6wWRMp?si=c449d08d97ab490a"
else:
temp = str(temp)
text = temp+"°C" +"--> Just the right temperature, Enjoy!"
def check_n_send():
if weather == 'Clear':
pywhatkit.sendwhats_image ('+910123456789','images\\clear.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif (weather == "Clouds"):
pywhatkit.sendwhats_image ('+910123456789','images\\cloudy.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Rain"):
pywhatkit.sendwhats_image ('+910123456789','images\\rainy.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Snow"):
pywhatkit.sendwhats_image ('+910123456789','images\\snowy.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Thunderstorm"):
pywhatkit.sendwhats_image ('+910123456789','images\\thunderstorm.gif',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Drizzle"):
pywhatkit.sendwhats_image ('+910123456789','images\\drizzle.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Mist"):
pywhatkit.sendwhats_image ('+910123456789','images\\mist.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Haze"):
pywhatkit.sendwhats_image ('+910123456789','images\\hazy.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
elif(weather == "Fog"):
pywhatkit.sendwhats_image ('+910123456789','images\\fog.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
else:
pywhatkit.sendwhats_image ('+910123456789','images\\unknown.png',text,15,True,3)
time.sleep(2)
pywhatkit.sendwhats_image ('+910123456789','images\\❤️.png','',15,True,3)
check_n_send()