add dry run, handling of None names (#7)
This commit is contained in:
+1
-1
@@ -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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
+3
-3
@@ -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"
|
||||
|
||||
+4
-4
@@ -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)})------"
|
||||
)
|
||||
@@ -146,10 +148,8 @@ class TwAPI:
|
||||
if dry_run:
|
||||
print("-------------------- DRY RUN --------------------")
|
||||
print(ttweet)
|
||||
if dry_run:
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user