Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather #10

Merged
merged 12 commits into from
May 17, 2023
Merged

Weather #10

merged 12 commits into from
May 17, 2023

Conversation

customizedpudding
Copy link
Contributor

Added files bot/handlers/weather.py and bot/services/weather.py.
Weather token API variable added to config.py, same in .env.example

63phc and others added 2 commits December 6, 2022 13:55
…n API variable added to config.py, same in .env.example
@customizedpudding customizedpudding changed the base branch from master to develop April 14, 2023 13:44
@63phc
Copy link
Member

63phc commented Apr 22, 2023

requests as httpx

@63phc
Copy link
Member

63phc commented Apr 22, 2023

added new variables for weather tokens
added new attributes for weather tokens
added new weather URLs;
request changed to httpx;
try-except block changed
Copy link
Member

@63phc 63phc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install black
black .

bot/config.py Outdated Show resolved Hide resolved
bot/services/weather.py Outdated Show resolved Hide resolved
bot/handlers/weather.py Outdated Show resolved Hide resolved
bot/services/weather.py Outdated Show resolved Hide resolved
sunrise_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunrise"])
sunrise_out = sunrise_timestamp.strftime("%H:%M:%S")
sunset_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunset"])
sunset_out = sunset_timestamp.strftime("%H:%M:%S")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serialiser(a or b or c):
...

bot/services/weather.py Outdated Show resolved Hide resolved
('OpenMeteo', 'https://api.open-meteo.com/v1/forecast',
{'latitude': latitude, 'longitude': longitude, 'current_weather': 'true'})
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coro_list = []
for name, url, params in URLS:
async with httpx.AsyncClient() as client:
coro_list.append(client.get(url, params=params))

    responses = await asyncio.gather(**coro_list)
    data_res = [i.json() for i in responses if i.status_code==200]

@63phc
Copy link
Member

63phc commented Apr 29, 2023

test

@63phc 63phc merged commit 42af13d into develop May 17, 2023
@customizedpudding customizedpudding deleted the weather branch July 14, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants