diff --git a/src/catchup.py b/src/catchup.py index 29ffc80..77c2c5b 100644 --- a/src/catchup.py +++ b/src/catchup.py @@ -144,7 +144,7 @@ async def run(PROGRAM_ARGS): print(f"Invalid tweet {id}!") continue - posted = await TwAPI.instance.post_ttweet_by_id(i) + posted = await TwAPI.instance.post_ttweet_by_id(i, PROGRAM_ARGS.dry_run) if posted: queue.add_finished_tweet(i) print("Successfully posted tweet. Sleeping for 5 minutes") diff --git a/src/main.py b/src/main.py index 0fde8ef..076a844 100644 --- a/src/main.py +++ b/src/main.py @@ -40,6 +40,11 @@ def init_argparse(): action="store_true", help="Go through queue first before attempting to pull tweets.", ) + p.add_argument( + "--dry-run", + action="store_true", + help="Don't actually post anything to Twitter; use to check outputs from console.", + ) p.add_argument( "--post-id", action="append", diff --git a/src/talenttweet.py b/src/talenttweet.py index e76863a..88812a2 100644 --- a/src/talenttweet.py +++ b/src/talenttweet.py @@ -278,7 +278,7 @@ class TalentTweet: rt_username = ( util.get_username_with_company(self.rt_author_id) if self.rt_author_id != -1 - else None + else "someone" ) if rt_username == author_username: rt_username = "themselves" @@ -291,7 +291,7 @@ class TalentTweet: reply_username = ( util.get_username_with_company(self.reply_to) if self.reply_to != -1 - else None + else "someone" ) if reply_username == author_username: reply_username = "themselves" @@ -303,7 +303,7 @@ class TalentTweet: quoted_username = ( util.get_username_with_company(self.quote_tweeted) if self.quote_tweeted != -1 - else None + else "someone" ) if quoted_username == author_username: quoted_username = "themselves" diff --git a/src/twapi.py b/src/twapi.py index 368c328..a7adb6a 100644 --- a/src/twapi.py +++ b/src/twapi.py @@ -136,6 +136,8 @@ class TwAPI: # return True = successfully posted a single ttweet # return False = did not post ttweet (duplicate) async def post_ttweet(self, ttweet: tt.TalentTweet, dry_run=False): + import main + print( f"------{ttweet.tweet_id} ({util.get_username_local(ttweet.author_id)})------" ) @@ -145,11 +147,9 @@ class TwAPI: if dry_run: print("-------------------- DRY RUN --------------------") - print(ttweet) - if dry_run: + print(ttweet) return False - # NO DRY-RUN: actually post tweet # main tweet: text + screenshot try: print("creating main QRT w/ screenshot...") @@ -188,7 +188,7 @@ class TwAPI: raise e return True - async def post_ttweet_by_id(self, id: int): + async def post_ttweet_by_id(self, id: int, dry_run=False): from scraper import Scraper print(f"Manually posting tweet {id}") @@ -204,4 +204,4 @@ class TwAPI: return False print(f"Posting {ttweet.username}/{ttweet.tweet_id}...") - return await self.post_ttweet(ttweet) + return await self.post_ttweet(ttweet, dry_run)