diff options
author | Ben Sima <ben@bsima.me> | 2022-07-05 10:35:53 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-07-05 10:40:39 -0400 |
commit | 8b324c4becd6e42352de30d74dc931f50263bb4c (patch) | |
tree | cc6c8c6cd45a18542f3b7d949d0fd8c64df79391 /twitter-bot | |
parent | c5f9267c04b65beb3169180c74b7ddba56172833 (diff) |
Post full text, created_at, and url
I think this *should* work, but sometimes it still returns the truncated
tweet text.
- https://github.com/bear/python-twitter/issues/647
- https://github.com/bear/python-twitter/issues/705
Diffstat (limited to 'twitter-bot')
-rwxr-xr-x | twitter-bot | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/twitter-bot b/twitter-bot index 6e98576..3513488 100755 --- a/twitter-bot +++ b/twitter-bot @@ -154,6 +154,7 @@ api = twitter.Api( consumer_secret=consumer_secret, access_token_key=access_token_key, access_token_secret=access_token_secret, + tweet_mode="extended", ) user = api.VerifyCredentials() @@ -207,7 +208,7 @@ for status in statuses[::-1][: opts.limit_tweets]: composed = f"{status.user.name} ({status.user.screen_name})" url = f"https://twitter.com/{status.user.screen_name}/status/{status.id}" # This contains all strings that could have caused the tweet to match our query. - text_to_check = [status.text, status.user.screen_name] + text_to_check = [status.full_text, status.user.screen_name] text_to_check.extend(url.expanded_url for url in status.urls) text_to_check = [text.lower() for text in text_to_check] @@ -240,7 +241,12 @@ for status in statuses[::-1][: opts.limit_tweets]: elif opts.twitter_name: subject = composed - message = {"type": "stream", "to": [opts.stream], "subject": subject, "content": url} + message = { + "type": "stream", + "to": [opts.stream], + "subject": subject, + "content": f"{status.full_text}\n{status.created_at}\n{url}", + } if opts.dry_run: print(message) |