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")
|
logging.warning("TENOR_API_KEY not set")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
lmt = 8
|
lmt = 24
|
||||||
ckey = "thc-time"
|
ckey = "thc-time"
|
||||||
|
|
||||||
url = f"https://tenor.googleapis.com/v2/search?q={search_term}&key={api_key}&client_key={ckey}&limit={lmt}"
|
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:
|
try:
|
||||||
response = requests.get(url, timeout=10)
|
response = requests.get(url, timeout=10)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
@@ -90,12 +90,8 @@ def get_message(type: str) -> dict[str, int]:
|
|||||||
msg = messages["unknown"]
|
msg = messages["unknown"]
|
||||||
if type in messages:
|
if type in messages:
|
||||||
msg = messages[type]
|
msg = messages[type]
|
||||||
if type == "notification":
|
if type in ["halftime", "notification"]:
|
||||||
img = get_tenor_img()
|
msg["image"] = {"url": get_tenor_img()}
|
||||||
else:
|
|
||||||
img = get_tenor_img(search_term=type)
|
|
||||||
if img:
|
|
||||||
msg["image"] = {"url": img}
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user