From 043dd05304a24ea2b7d7a4d395ab94f808a94a1d Mon Sep 17 00:00:00 2001 From: zwitschi Date: Tue, 23 Sep 2025 15:26:51 +0200 Subject: [PATCH] increase GIF limit in search_tenor and optimize image retrieval in get_message --- main.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 0cecc80..38983b6 100644 --- a/main.py +++ b/main.py @@ -65,12 +65,12 @@ def search_tenor(search_term: str = "420") -> list: logging.warning("TENOR_API_KEY not set") return [] - lmt = 8 + lmt = 24 ckey = "thc-time" url = f"https://tenor.googleapis.com/v2/search?q={search_term}&key={api_key}&client_key={ckey}&limit={lmt}" - # get the top 8 GIFs for the search term + # get the top n GIFs for the search term try: response = requests.get(url, timeout=10) response.raise_for_status() @@ -90,12 +90,8 @@ def get_message(type: str) -> dict[str, int]: msg = messages["unknown"] if type in messages: msg = messages[type] - if type == "notification": - img = get_tenor_img() - else: - img = get_tenor_img(search_term=type) - if img: - msg["image"] = {"url": img} + if type in ["halftime", "notification"]: + msg["image"] = {"url": get_tenor_img()} return msg