From 8b324c4becd6e42352de30d74dc931f50263bb4c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 5 Jul 2022 10:35:53 -0400 Subject: 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 --- twitter-bot | 10 ++++++++-- 1 file 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) -- cgit v1.2.3