Twitter Clean-up
Tiny script to clean-up your Twitter account:
- Removing users that have not been tweeting for a while
- Soft-blocking bots (blocks and immediately unblocks the account, so it stops following you)
Requirements
- Python 3.6
- Twitter API keys specified in
.env.sample
- Botometer API key named
MASHAPE_KEY
in.env.sample
Running
Inside a Python virtualenv:
- Copy
.env.sample
as.env
and insert your credentials accordingly - Install the dependencies with
pip install -r requirements.txt
- Start the interactive console with
python -i cleanup.py
Removing idle accounts
Call the method cleanup.unfollow_inactive_for(**kwargs)
.
It accepts any keyword argument compatible with Python's
timedelta
. It will prompt you before unfollowing anyone.
For example, to unfollow users inactive for the last 30 days:
>>> cleanup.unfollow_inactive_for(days=30)
Soft-blocking bots
Call the function soft_block_bots(threshold=None)
.
The
threshold
value is afloat
between0
and1
. Every public account is analyzed using Botometer and all acounts with a higher probability than thethreshold
would be considered a bot. It will prompt you before soft-blocking anyone.
For example, to run with the default threshold (0.75
):
>>> cleanup.soft_block_bots()
Or to run with a custom threshold:
>>> cleanup.soft_block_bots(threshold=0.68)
Contributing
Please, format your code with Black.