1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00
Lumi/wrappers/inspirobot.py

21 lines
512 B
Python
Raw Permalink Normal View History

2024-09-22 15:35:13 +00:00
import httpx
class InspiroBot:
def __init__(self):
self.base_url = "https://inspirobot.me/api?generate=true"
async def get_image(self) -> str:
"""
Get a random motivational image from Inspirobot.
Returns
-------
str
The URL of the image.
"""
2024-09-22 15:45:48 +00:00
async with httpx.AsyncClient(timeout=10.0) as client:
2024-09-22 15:35:13 +00:00
response = await client.get(self.base_url)
response.raise_for_status()
return response.text