diff --git a/src/app/api/core/social.py b/src/app/api/core/social.py index 721ac0c..deca505 100644 --- a/src/app/api/core/social.py +++ b/src/app/api/core/social.py @@ -1,6 +1,9 @@ from pydantic import BaseModel + +MAX_COMMENTS = 5 + class SocialPost(BaseModel): """ Represents a social media post with time, title, description, and comments. diff --git a/src/app/api/social/reddit.py b/src/app/api/social/reddit.py index bda7687..c247cac 100644 --- a/src/app/api/social/reddit.py +++ b/src/app/api/social/reddit.py @@ -1,10 +1,9 @@ import os from praw import Reddit # type: ignore from praw.models import Submission # type: ignore -from app.api.core.social import SocialWrapper, SocialPost, SocialComment +from app.api.core.social import * -MAX_COMMENTS = 5 # metterne altri se necessario. # fonti: https://lkiconsulting.io/marketing/best-crypto-subreddits/ SUBREDDITS = [ diff --git a/src/app/api/social/x.py b/src/app/api/social/x.py index 5222092..a1b1bd4 100644 --- a/src/app/api/social/x.py +++ b/src/app/api/social/x.py @@ -5,6 +5,15 @@ from shutil import which from app.api.core.social import SocialWrapper, SocialPost +# This is the list of users that can be interesting +# To get the ID of a new user is necessary to search it on X, copy the url and insert it in a service like "https://get-id-x.foundtt.com/en/" +X_USERS = [ + 'watcherguru', + 'Cointelegraph', + 'BTC_Archive', + 'elonmusk' +] + class XWrapper(SocialWrapper): def __init__(self): ''' @@ -17,20 +26,11 @@ class XWrapper(SocialWrapper): assert self.api_key, "X_API_KEY environment variable not set" assert which('rettiwt') is not None, "Command `rettiwt` not installed" - # This is the list of users that can be interesting - # To get the ID of a new user is necessary to search it on X, copy the url and insert it in a service like "https://get-id-x.foundtt.com/en/" - self.users = [ - 'watcherguru', - 'Cointelegraph', - 'BTC_Archive', - 'elonmusk' - ] - def get_top_crypto_posts(self, limit:int = 5) -> list[SocialPost]: social_posts: list[SocialPost] = [] - for user in self.users: + for user in X_USERS: process = subprocess.run(f"rettiwt -k {self.api_key} tweet search -f {str(user)}", capture_output=True) results = process.stdout.decode() json_result = json.loads(results)