Skip to content

Commit dad3a9b

Browse files
code refactored
1 parent c9c9298 commit dad3a9b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/tasks/schedulers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self):
6666
self._tweet_queue = Queue()
6767
self._article_count: int = 50
6868
self._error_delay: int = FIVE_MINUTE
69+
self._max_status_length: int = 280
6970
self._logger = init_logger(self.__class__.__name__)
7071

7172
async def get_articles(self):
@@ -105,12 +106,18 @@ async def do_create_tweet(self, article: ArticleData) -> dict[str, str]:
105106

106107
# Create the tweet text with hashtags
107108
tweet_text: str = f"""
108-
EOD Stock API - Financial & Business News
109-
109+
Financial & Business News API
110110
{hashtags}
111111
- {article.title}
112112
{internal_link}
113113
"""
114+
if len(tweet_text) > self._max_status_length:
115+
tweet_text = f"""
116+
Financial & Business News API
117+
- {article.title}
118+
{internal_link}
119+
"""
120+
114121
if article.thumbnail.resolutions:
115122
_url: str = article.thumbnail.resolutions[0].url
116123
response = requests.get(_url)

0 commit comments

Comments
 (0)