22 lines
762 B
Python
22 lines
762 B
Python
import requests
|
|
|
|
def get_quote():
|
|
try:
|
|
# Folosim API-ul Quotable pentru a primi și autorul
|
|
response = requests.get("https://api.quotable.io/random", timeout=10)
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
|
|
quote = data.get('content', 'No quote found')
|
|
author = data.get('author', 'Unknown')
|
|
|
|
# Salvăm formatat pentru Discord
|
|
with open("quote.txt", "w", encoding="utf-8") as f:
|
|
f.write(f"📜 *\"{quote}\"*\n\n✍️ **Autor:** {author}")
|
|
|
|
except Exception as e:
|
|
with open("quote.txt", "w", encoding="utf-8") as f:
|
|
f.write(f"⚠️ Nu am putut prelua citatul. Eroare: {str(e)}")
|
|
|
|
if __name__ == "__main__":
|
|
get_quote() |