increase GIF limit in search_tenor and optimize image retrieval in get_message
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 3m12s
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 3m12s
This commit is contained in:
12
main.py
12
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user