bun-twit is a lightweight, developer-friendly Twitter interfacing unit built with Bun, designed to automate tweet scheduling and interaction. The instance leverages the ElizaOS agent-twitter-client
library for Twitter scraping and supports cookie-based authentication, proxy configuration, and tweet scheduling from a JSON file.
- Tweet Scheduling: Configure delays and tweet counts for automated posting.
- Proxy Support: Use proxies for safer and more private interactions.
- Cookie Management: Reuse cookies for authentication to reduce login overhead.
- JSON Configuration: Define tweets in a structured JSON file.
- Developer-Friendly: Built with TypeScript, using Bun's fast runtime.
Ensure you have the following set up:
- Bun: Install via:
curl https://bun.sh/install | bash
- Node.js, npm, or Yarn is not required as Bun serves as an all-in-one runtime.
- Twitter account credentials for login.
- Data to send composed as
tweets.json
- clone repository
git clone hhttps://github.com/cipher-rc5/bun-twit.git
cd bun-twit
- install dependencies
bun install
the only dependency for this instance is agent-twitter-client
which can be installed using:
bun add agent-twitter-client
- Create a
.env
file based on.env.example
:
cp .env.example .env
- Update
.env
with your Twitter credentials and configuration:
TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password
TWITTER_EMAIL=your_email
TWITTER_2FA_SECRET=your_2fa_secret
Running the Bot To execute the bot and post all tweets with a two minute(default delay):
bun run src/cli.ts
CLI Options The bot supports the following CLI flags:
- --delay [time]: Set delay between tweets in minutes (default: 2min).
- --count [number]: Specify the number of tweets to send (default: all).
- --proxy [url]: Use a proxy for Twitter requests.
Example:
bun run src/cli.ts --delay 5 --count 3 --proxy http://proxy.example.com
Advanced Options Customize tweet scheduling with command-line arguments:
bun run src/cli.ts --count 5 --delay 3min
bun run src/cli.ts --proxy http://your-proxy-url:port
Tweets are stored in tweets.json. Each tweet includes the following fields:
username (optional): The bot's username for context. content (required): The tweet text. hashtags (optional): An array of hashtags.
Example:
[{
"username": "MortLovesFeet",
"content": "Good morning, everyone! Mort is here to remind you to smile. 👣✨",
"hashtags": ["#LemurLife", "#MortKnowsBest"]
}]
bun-twit/
├── .env.example # Environment variable template
├── tweets.json # Pre-configured tweets
├── src/
│ ├── cli.ts # CLI entry point
│ ├── twitter-client.ts # Twitter client logic
│ ├── services/ # Modular service files
│ │ ├── cookie-manager.ts
│ │ ├── proxy-manager.ts
│ │ ├── tweet-config-loader.ts
│ ├── utils/ # Utility functions
│ │ ├── mime-types.ts
│ │ ├── time-parser.ts
│ ├── types/ # Type definitions
│ ├── types.ts
The client automatically manages Twitter authentication cookies:
- Cookies are stored in twitter_cookies.json
- Default cookie expiration is 24 hours
- Failed cookie authentication falls back to credential login
Supported media formats:
- Images: .jpg, .jpeg, .png
- Animated: .gif
- Video: .mp4
The client includes robust error handling for:
- Authentication failures
- Network issues
- Invalid media types
- Configuration errors