/twitter-cleanup

🛁 Clean-up stale accounts and bots from your Twitter

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Twitter Clean-up

🇧🇷 Versão em português do Brasil

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

Running

Inside a Python virtualenv:

  1. Copy .env.sample as .env and insert your credentials accordingly
  2. Install the dependencies with pip install -r requirements.txt
  3. 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 a float between 0 and 1. Every public account is analyzed using Botometer and all acounts with a higher probability than the threshold 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.