Skip to content

Commit 371c0b4

Browse files
code refactored
1 parent 9fdd424 commit 371c0b4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tasks/schedulers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def __init__(self):
8383
self._article_count: int = 46
8484
self._error_delay: int = FIVE_MINUTE
8585
self._max_status_length: int = 280
86+
self._count: int = 0
8687
self._logger = init_logger(self.__class__.__name__)
88+
8789
async def init(self):
8890
self._tweepy_api = tweepy.API(auth=auth)
89-
91+
9092
async def get_articles(self):
9193
"""
9294
**get_articles**
@@ -122,9 +124,13 @@ async def do_create_tweet(self, article: ArticleData) -> dict[str, str]:
122124
# Extract ticker symbols as hashtags
123125
hashtags = ' '.join(['#' + ticker for ticker in article.tickers])
124126
internal_link: str = f"https://eod-stock-api.site/blog/financial-news/tweets/{article.uuid}"
125-
127+
business_api_link: str = "https://bit.ly/financial-business-news-api"
126128
# Create the tweet text with hashtags
127-
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\n{internal_link}"
129+
if self._count % 2 == 0:
130+
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\nAPI Integration: {business_api_link}"
131+
else:
132+
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\n{internal_link}"
133+
128134
if len(tweet_text) > self._max_status_length:
129135
tweet_text = f"Financial & Business News API\n- {article.title}\n{internal_link}"
130136

0 commit comments

Comments
 (0)