@@ -123,28 +123,20 @@ async def send_tweet(self, tweet: dict[str, str]):
123
123
async def do_create_tweet (self , article : ArticleData ) -> dict [str , str ]:
124
124
self ._logger .info ("Creating Tweets" )
125
125
# Extract ticker symbols as hashtags
126
- hashtags = ' ' .join (['#' + ticker for ticker in article .tickers ])
127
- internal_link : str = f"https://eod-stock-api.site/blog/financial-news/tweets/{ article .uuid } "
128
- business_api_link : str = "https://bit.ly/financial-business-news-api"
129
- # 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
-
133
- if self ._count % 2 == 0 :
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 } "
126
+ if article .tickers :
127
+ hashtags = '' .join (['#' + ticker for ticker in article .tickers ])
128
+ elif article .sentiment .stock_codes :
129
+ _codes = article .sentiment .stock_codes
130
+ hashtags = '' .join (['#' + ticker for ticker in _codes ])
138
131
else :
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 } "
132
+ hashtags = ""
143
133
144
- self ._count += 1
134
+ # Create the tweet text with hashtags
135
+ _title : str = "Financial & Business News API"
136
+ _crop_len : int = self ._max_status_length - len (_title ) - 6 - len (hashtags )
137
+ tweet_body = f"{ article .sentiment .article_tldr [: _crop_len ]} " if article .sentiment .article_tldr else article .title
145
138
146
- if len (tweet_text ) > self ._max_status_length :
147
- tweet_text = f"Financial & Business News API\n - { article .title } \n { internal_link } "
139
+ tweet_text = f"{ _title } \n -{ tweet_body } ...\n { hashtags } "
148
140
149
141
if article .thumbnail .resolutions :
150
142
_url : str = article .thumbnail .resolutions [0 ].url
0 commit comments