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

added support for arguments skip following and ignore list #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tweepy import Client, Paginator
from os import getenv
from dotenv import load_dotenv
import argparse

load_dotenv()

Expand All @@ -11,6 +12,11 @@
my_user_id = getenv('MY_USER_ID')
tweet_id = getenv('TWEET_ID')

parser = argparse.ArgumentParser()
parser.add_argument("-s", "--skip_following", help="Skip accounts that you have followed")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using Argparse's BooleanOptionalAction with a True (?) default for better usability.

parser.add_argument("-i", "--ignore", nargs='+', type=str, help="ignore and skip block this usernames")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency and better grammar, I suggest "Skip blocking this username" as the help text.

args = parser.parse_args()

if None in [api_key, api_secret, access_token, access_token_secret, tweet_id]:
raise Exception('You have to provide all of the following env vars: API_KEY, API_SECRET, ACCESS_TOKEN, '
'ACCESS_TOKEN_SECRET, MY_USER_ID, and TWEET_ID.')
Expand Down Expand Up @@ -39,7 +45,7 @@
print(f'in get_liking_users, response: {response}')
continue
for user in users:
if user.id in followings:
if (user.username in args.ignore) or (args.skip_following and user.id in followings):
print(f'{user.username} liked but not blocked')
continue
client.block(user.id)
Expand Down