schloter/client/daily_client.py

28 lines
861 B
Python

import requests
API_URL = "https://schloter.api.ping-mee.de/quotes/random" # Adjust if your API runs elsewhere
TEAMS_WEBHOOK_URL = "https://outlook.office.com/webhook/REPLACE_WITH_YOUR_WEBHOOK" # Replace with your Teams webhook URL
# Set your static token here
API_TOKEN = "mysecrettoken1" # Replace with your actual token
def get_quote():
headers = {"Authorization": f"Bearer {API_TOKEN}"}
resp = requests.get(API_URL, headers=headers)
resp.raise_for_status()
data = resp.json()
return data.get("quote", "No quote found.")
def post_to_teams(quote):
payload = {
"text": quote
}
resp = requests.post(TEAMS_WEBHOOK_URL, json=payload)
resp.raise_for_status()
print("Posted to Teams!")
if __name__ == "__main__":
quote = get_quote()
post_to_teams(quote)
# ...existing code from schloters_dailys.py...