mirror of
https://github.com/andwati/unsplash-bot.git
synced 2026-11-08 12:05:13 +00:00
feature
This commit is contained in:
+2
-2
@@ -12,12 +12,12 @@ def send_welcome(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=["random"])
|
@bot.message_handler(commands=["random"])
|
||||||
def get_random_photo(message):
|
def get_random_photo(message):
|
||||||
url = "https://api.unsplash.com/photos/random"
|
url = f"{BASE_URL}/photos/random"
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
url, timeout=10, headers={"Authorization": f"Client-ID {ACCESS_TOKEN}"}
|
url, timeout=10, headers={"Authorization": f"Client-ID {ACCESS_TOKEN}"}
|
||||||
)
|
)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
image_url = data["urls"]["regular"]
|
image_url = data["links"]["download"]
|
||||||
description = data["alt_description"]
|
description = data["alt_description"]
|
||||||
image_content = requests.get(image_url)
|
image_content = requests.get(image_url)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user