From c14661af976dd3d3f492e575aa98313827151ce0 Mon Sep 17 00:00:00 2001 From: muskit <15199219+muskit@users.noreply.github.com> Date: Sat, 14 Jan 2023 02:20:21 -0800 Subject: [PATCH] minor reformatting --- src/listen.py | 11 ++++++++--- src/twapi.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/listen.py b/src/listen.py index 3734f13..83bab82 100644 --- a/src/listen.py +++ b/src/listen.py @@ -10,18 +10,23 @@ from twapi import TwAPI import ttweetqueue as ttq import api_secrets import talent_lists as tl +import util errors_encountered = 0 def on_response(resp): ttweet = TalentTweet.create_from_v2api_response(resp) + tweet_username = util.get_username(ttweet.author_id) if ttweet.is_cross_company(): print(f'Tweet {ttweet.tweet_id} is cross-company! Creating post...') - asyncio.run(TwAPI.instance.post_ttweet(ttweet)) - ttq.TalentTweetQueue.instance.add_finished_tweet(ttweet.tweet_id) + is_successful = asyncio.run(TwAPI.instance.post_ttweet(ttweet)) + if is_successful: + ttq.TalentTweetQueue.instance.add_finished_tweet(ttweet.tweet_id) + else: + print(f'[WARNING] Failed to post ttweet for {tweet_username}/{ttweet.tweet_id}!') else: - print(f'Tweet {ttweet.tweet_id} is not cross-company.') + print(f'Tweet {tweet_username}/{ttweet.tweet_id} is not cross-company.') def run(): global errors_encountered diff --git a/src/twapi.py b/src/twapi.py index 6a7ebb9..b03334c 100644 --- a/src/twapi.py +++ b/src/twapi.py @@ -237,7 +237,7 @@ class TwAPI: if dry_run: print('-------------------- DRY RUN --------------------') print(text) - if dry_run: return + if dry_run: return False # NO DRY-RUN: actually post tweet # main tweet: text + screenshot