A tool to automatically detect and block spam accounts on Bluesky by analyzing follower patterns and content.
- Automatically detects spam accounts using configurable patterns
- Checks for suspicious follower/following ratios
- Adds detected accounts to a list
- Maintains a local database of checked followers
- Debug mode for detailed pattern matching information
-
Install Bun (sorry for the extra tool, but i used it for the sqlite):
- Visit https://bun.sh/ for installation instructions
- Or run this command (macOS, Linux, WSL):
curl -fsSL https://bun.sh/install | bash - Verify installation:
bun --version
-
Clone the repository:
git clone https://github.com/keith/bsky-blocker.git
cd bsky-blocker- Install dependencies:
bun install- Create a
.envfile in the project root (copy from.env.example):
cp .env.example .env- Set up your Bluesky credentials in
.env:
BLUESKY_EMAIL=[email protected]
BLUESKY_APP_PASSWORD=your-app-passwordNote: Use an App Password, not your main account password. You can create one in your Bluesky account settings.
-
Create a moderation list on Bluesky:
- Go to https://bsky.app/moderation/modlists
- Click "+ New"
- Give it a name (e.g., "Spam Accounts")
- After creating the list, copy the list ID from the URL
- For example, if your list URL is
https://bsky.app/profile/username.bsky.social/lists/3jd92h5kw9s, the ID is3jd92h5kw9s
-
Add your list ID to
.env:
BLOCKLIST_ID=3jd92h5kw9sTo check your recent followers for spam accounts:
bun run index.tsThis will:
- Check your most recent followers
- Apply spam detection patterns
- Add matching accounts to your block list
- Save results to a local database
To test your spam detection patterns against a specific account:
bun run test-patterns.ts username.bsky.socialThis will show:
- Account information
- Pattern matching results
- Follow ratio analysis
- Detailed debug information
To enable debug mode for detailed pattern matching information:
const blocker = new BlueskyBlocker(DEFAULT_PATTERNS, true);The tool does some basic checks to help spot potential spam accounts:
-
Simple text matching:
- Looks for promotional content in display names
- Checks for certain types of links in descriptions
- Spots common promotional phrases
-
Basic behavior checks:
- Looks at the ratio of following vs followers
- Checks for combinations of promo links and certain emojis
You can customize these checks in patterns.ts. They're pretty basic but help catch some of the more obvious spam accounts.
The tool maintains a SQLite database (db.sqlite) to track which followers have been checked. This prevents re-checking the same accounts multiple times.
Feel free to submit issues and pull requests for:
- New spam detection patterns
- Bug fixes
- Feature improvements
MIT