Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions nexus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
load_dotenv()

class Utils:
MAX_TWEETS = 3200 # Twitter API's maximum limit for user_timeline

def __init__(self):
api_key = os.getenv("API_KEY")
api_secret = os.getenv("API_SECRET")
Expand All @@ -32,6 +34,17 @@ def user_lookup_tweepy(self, user: str, quantity: int):
:param quantity: amount of tweets you want to retrieve

"""
# Cap quantity to the allowed bounds
if not isinstance(quantity, int):
try:
quantity = int(quantity)
except Exception:
quantity = 0
if quantity < 1:
quantity = 0
elif quantity > self.MAX_TWEETS:
quantity = self.MAX_TWEETS

query: List[Dict] = []

tweets = tweepy.Cursor(
Expand Down Expand Up @@ -133,6 +146,4 @@ def create_topics(self, documents: List[Dict], id_to_cluster_label: Dict, id_fie
bot = Utils()
lookup = bot.user_lookup_sns("JoeBiden", 5000)
print(len(lookup))
print(lookup[-1])


print(lookup[-1])