-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother.py
22 lines (19 loc) · 884 Bytes
/
other.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from pyowm import OWM
from datetime import datetime
from pyowm.utils.config import get_default_config
import db
import os
config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = OWM(os.getenv('API_WEATHER'), config_dict)
mgr = owm.weather_manager()
def pogodka(chat_id):
date = db.get_from_db(chat_id, "date").split('.')
locale = db.get_from_db(str(chat_id),"locale").strip()
observation = mgr.forecast_at_coords(float(locale.split()[0]),float(locale.split()[1]),'3h').forecast
need_d = datetime(2021,int(date[1]),int(date[0]),12).strftime("%m/%d/%Y %H:%M")
for i in observation:
if need_d == i.reference_time('date').strftime("%m/%d/%Y %H:%M"):
temp = i.temperature("celsius")
status = i.detailed_status
return f"На тусовочке будет {status} - {temp['temp']} градусов."