diff --git a/services/x.py b/services/x.py index 4b3c821..8b93f05 100644 --- a/services/x.py +++ b/services/x.py @@ -12,7 +12,7 @@ class X: """Interact and engage with the X API.""" - def GetUserID(username: str) -> int: + def GetUserID(username: str) -> int | None: """Fetch an X user by their username and return their unique identifier.""" userId: int | None = None @@ -43,13 +43,13 @@ def GetUserPosts( ) -> list[dict[str, int | str]]: """Fetch an array of the latest posts from the specified X username.""" - userId: int = X.GetUserID(username) - - if not userId: - return + posts: list[dict[str, int | str]] = [] + userId: int | None = X.GetUserID(username) entries: list[dict] = [] - posts: list[dict[str, int]] = [] + + if not userId: + return posts endpoint: str = "https://twitter.com/i/api/graphql/-gxtzCQbBPmOwxnY-SbiHQ/UserTweetsAndReplies" variables: dict[str, str | int | bool | None] = {