diff --git a/src/gorrion.py b/src/gorrion.py index 1259ce9..0457c2a 100644 --- a/src/gorrion.py +++ b/src/gorrion.py @@ -123,7 +123,10 @@ def build_status(self, album: Album, config: TweetConfig): return tweet_status def is_valid_tweet_status(self, status: str) -> bool: - return len(status) <= self._twitter.max_tweet_length + # Tracks command injects clock emoji ⏳ which counts as two characters for Twitter. We need to add one more + # character for each ⏳. + extra_chars = ' ' * status.count('⏳') + return len(status + extra_chars) <= self._twitter.max_tweet_length def lyrics_to_tweets(self, lyrics: list) -> list: lyric_tweets = [] diff --git a/tests/test_telegram_bot.py b/tests/test_telegram_bot.py index 2eb33d0..e6348f5 100644 --- a/tests/test_telegram_bot.py +++ b/tests/test_telegram_bot.py @@ -188,7 +188,6 @@ def test_process_playing_album_command_with_error(self, gorrion_mock, bot_mock, @patch('src.telegram_bot.Bot') @patch('src.telegram_bot.Gorrion') def test_process_playing_album_with_tracks_command(self, gorrion_mock, bot_mock, update_mock): - tweet = PublishedTweet(id_='1', tweet='tweet1', entity=None) update = MagicMock() update.message.text = '/tracks' update.message.chat.id = '123'