forked from mhezarei/ai-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_weather_from_city_date.py
33 lines (30 loc) · 1.17 KB
/
find_weather_from_city_date.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
from datetime import datetime
from weather import Weather
def find_weather_from_city_date(Question, city, greg_date):
current_dt = int(datetime.timestamp(datetime.now()))
cond = ""
max_list = ["حداکثر", "بیشترین", "گرمترین", "گرمترین", "گرم ترین"]
min_list = ["حداقل", "کمترین", "کمینه"]
mid_list = ["میانگین"]
logic = ""
for elem in min_list:
if elem in Question:
w = Weather(city, greg_date, current_dt, True)
out = w.send_request()
temp = out[0]
return float(temp), cond, w.url, elem
for elem in max_list:
if elem in Question:
w = Weather(city, greg_date, current_dt, True)
out = w.send_request()
temp = out[1]
return float(temp), cond, w.url, elem
for elem in mid_list:
if elem in Question:
w = Weather(city, greg_date, current_dt, True)
out = w.send_request()
temp = out[2]
return float(temp), cond, w.url, elem
w = Weather(city, greg_date, current_dt)
temp, cond = w.send_request()
return float(temp), cond, w.url, ""