From a3a662c6a2a33b2cca920df229663022c5072c98 Mon Sep 17 00:00:00 2001 From: Sterling Dreyer Date: Wed, 25 Sep 2024 16:18:36 -0700 Subject: [PATCH] Fixed error when missing phrase or keyword (#70) --- toolkits/x/arcade_x/tools/tweets.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toolkits/x/arcade_x/tools/tweets.py b/toolkits/x/arcade_x/tools/tweets.py index 914dc91e..a139de49 100644 --- a/toolkits/x/arcade_x/tools/tweets.py +++ b/toolkits/x/arcade_x/tools/tweets.py @@ -113,7 +113,10 @@ def search_recent_tweets_by_keywords( "Authorization": f"Bearer {context.authorization.token}", "Content-Type": "application/json", } - query = " ".join([f'"{phrase}"' for phrase in phrases]) + " ".join(keywords) + query = " ".join([f'"{phrase}"' for phrase in (phrases or [])]) + " " + " " + if keywords: + query += " ".join(keywords or []) + params = { "query": query, "max_results": max(max_results, 10), # X API does not allow 'max_results' less than 10