Skip to content

Commit 1e8ba62

Browse files
refactored
1 parent e614f24 commit 1e8ba62

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/tasks/schedulers.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self):
8282
self._tweet_queue = Queue()
8383
self._article_count: int = 15
8484
self._error_delay: int = FIVE_MINUTE
85-
self._max_status_length: int = 280
85+
self._max_status_length: int = 250
8686
self._count: int = 0
8787
self._logger = init_logger(self.__class__.__name__)
8888

@@ -127,10 +127,19 @@ async def do_create_tweet(self, article: ArticleData) -> dict[str, str]:
127127
internal_link: str = f"https://eod-stock-api.site/blog/financial-news/tweets/{article.uuid}"
128128
business_api_link: str = "https://bit.ly/financial-business-news-api"
129129
# Create the tweet text with hashtags
130+
_title: str = "Financial & Business News API"
131+
_crop_len: int = self._max_status_length - len(_title) - 6
132+
130133
if self._count % 2 == 0:
131-
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\n - FOR API Integration: {business_api_link}"
134+
if article.sentiment and article.sentiment.article_tldr:
135+
tweet_text = f"{_title}\n{article.sentiment.article_tldr[0: _crop_len]}"
136+
else:
137+
tweet_text: str = f"{_title}\n-{article.title}\n - FOR API Integration: {business_api_link}"
132138
else:
133-
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\n{internal_link}"
139+
if article.sentiment and article.sentiment.article_tldr:
140+
tweet_text = f"{_title}\n{article.sentiment.article_tldr[0: _crop_len]}"
141+
else:
142+
tweet_text: str = f"Financial & Business News API\n{hashtags}\n- {article.title}\n{internal_link}"
134143

135144
self._count += 1
136145

0 commit comments

Comments
 (0)