Here’s the updated project documentation, including the latest changes to the Cobie Bot
code for Discord and Twitter integration.
This project is a combined Discord and Twitter bot inspired by Cobie's style. The bot periodically posts tweets on Twitter with a Cobie-style perspective and responds to commands on Discord, offering humorous and skeptical responses about the crypto market.
The Cobie Bot project includes:
- A script to generate Cobie-style responses for both Twitter posts and Discord messages.
- A knowledge base created from scraped tweets using the
eliza
repository.
cobie-bot/
├── cobie_bot.py # Main Python script for combined Discord + Twitter bot
├── finetune_cobie.jsonl # JSONL file with Cobie fine-tuning data
├── cobie_character.json # JSON file with Cobie character details
├── cobie_prompts.txt # Text file with example Cobie prompts
├── .env.example # Example .env file (without sensitive info)
├── requirements.txt # Dependencies for the project
├── README.md # Documentation for the project
├── .gitignore # File to exclude sensitive files from being uploaded
To give Cobie Bot a unique, Cobie-like tone, you’ll need to create a knowledge base of tweets. This is done using the eliza Twitter Scraper repository, which allows you to scrape tweets and save them in JSON format.
-
Clone the
eliza
Repository:git clone https://github.com/ai16z/twitter-scraper-finetune cd twitter-scraper-finetune
-
Set Up Twitter API Credentials:
-
Register for a Twitter Developer account if you haven’t done so.
-
Create a new Twitter app to get your API keys.
-
Create a
.env
file in theeliza
repository and add your Twitter API credentials as follows:TWITTER_CONSUMER_KEY=your_consumer_key TWITTER_CONSUMER_SECRET=your_consumer_secret TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
-
-
Run the Scraper:
- Customize the
eliza
script to scrape tweets from a specific account, such as Cobie’s account. - Run the script:
python scrape_tweets.py --username cobie --output cobie_tweets.jsonl
- This will create a JSONL file (
cobie_tweets.jsonl
) containing the tweets, which you can use as input for the Cobie Bot project.
- Customize the
Once you have the scraped tweets:
- Clean and process the tweets if necessary, removing non-relevant data.
- Split the data into two files:
finetune_cobie.jsonl
: Contains Cobie tweets for generating responses.cobie_character.json
: Provides character details for Cobie (personality traits, style) for contextual use.
Example content for finetune_cobie.jsonl
:
{"text": "Crypto markets are like a rollercoaster, but without any of the fun."}
{"text": "Just when you think you've seen it all, someone buys the top again."}
{"text": "The only guarantee in crypto is that nothing's guaranteed."}
Example content for cobie_character.json
:
{
"message examples": [
{"prompt": "What do you think about meme coins?", "response": "They're like lotto tickets for people who hate money."}
],
"post examples": [
{"prompt": "Market is down; what's new?", "response": "Another day, another crypto panic."}
]
}
Create a .env
file in the project directory to store API keys and tokens for the bot. Here’s the required format:
API_KEY=your_twitter_api_key
API_SECRET_KEY=your_twitter_api_secret_key
ACCESS_TOKEN=your_twitter_access_token
ACCESS_TOKEN_SECRET=your_twitter_access_token_secret
OPENROUTER_API_KEY=your_openrouter_api_key
DISCORD_TOKEN=your_discord_bot_token
Install the necessary dependencies by running:
pip install -r requirements.txt
The requirements.txt
file should contain:
discord.py
tweepy
requests
python-dotenv
aiohttp
The cobie_bot.py
file combines both Discord and Twitter functionalities. Here’s the content for cobie_bot.py
:
-
Make sure your
.env
file is correctly configured with all necessary API keys. -
Run the bot:
python cobie_bot.py
- The bot will post tweets on Twitter at regular intervals.
- The bot will respond to commands on Discord with a Cobie-style response.
Let me know if there’s anything more you’d like!