Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve erroring for login issues #11

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/instawebhooks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,6 @@ def closure_check_regex(arg_value):
# Log the start of the program
logger.info("Starting InstaWebhooks...")

# Check if we need to sign in to access the Instagram profile
try:
Profile.from_username(Instaloader().context, args.instagram_username).get_posts()
except KeyboardInterrupt:
print("\nInterrupted by user.")
sys.exit(0)
except LoginRequiredException as exc:
logger.critical("instaloader: error: %s", exc)
raise SystemExit(
"Not logged into Instaloader.\n instaloader --login YOUR-USERNAME"
) from exc

# Ensure that a message content is provided if no embed is enabled
if args.no_embed and args.message_content == "":
logger.critical("error: Cannot send an empty message. No message content provided.")
Expand Down Expand Up @@ -255,6 +243,11 @@ def main():
while True:
asyncio.run(check_for_new_posts())
sleep(args.refresh_interval)
except LoginRequiredException as login_exc:
logger.critical("instaloader: error: %s", login_exc)
raise SystemExit(
"Not logged into Instaloader.\n instaloader --login YOUR-USERNAME"
) from login_exc
except KeyboardInterrupt:
print("\nInterrupted by user.")
sys.exit(0)