A basic bot which posts tweets generated from ChatGPT prompts utilizing revChatGPT, a third party ChatGPT API. OpenAI is actively trying to circumvent bot activity on ChatGPT which is resulting in a lot of instability with this API. This bot may break or cease to function often. Once an official API is available for ChatGPT this repository will be updated to utilize it.
This project is utilzing a third party ChatGPT API which requires workarounds for OpenAI's Cloudflare protections. You will need Firefox/Chrome intalled.When executing this application a browser will open and you will need to login to OpenAI with your account information.
If you do not have an OpenAI account already, you will need to register one here OpenAI
You can access your Twitter API keys through the Twitter Developer Dashboard. If you haven't used this platform before you will need to create a project once you've registered an account.
Once you've registered a project, navigate to the Twitter Developers dashboard homepage
Look for your project under the Apps section and click the key icon on your project
Generate your Consumer(API) key and secret
Copy these values and use them to populate the TWITTER_API_KEY and TWITTER_API_KEY_SECRET entries in your .env file
Under the Authentication Tokens section, generate an Access Token and Secret
Copy these values and use them to populate the TWITTER_ACCESS_TOKEN and TWITTER_ACCESS_TOKEN_SECRET entires in your .env file.
This script will use prompts generated in prompts.py to generate tweets which will be posted to your twitter account in random intervals between 2-6 hours of length. Prompts are composed of a prompt template, a topic, a list of attributes, a wildcard, and a list of constraints. Example values can be found in prompts.json and additional properties can be added here.
Without values
Describe {topic} from a unique perspective or angle. {attributes}. {wildcard}. {constraints}.
With values
Describe chatgpt from a unique perspective or angle. Use an informal tone, use relaxed punctuation. Mention a specific company. Write your response as a tweet with at most 280 characters.
Add as many prompts or additional input fields as you like to this file and execute the program. An output log will be kept in tweets.txt
python3 twitterbot.py
NOTE: Cloudflare protections have made the Dockerfile unusable at the moment, I will need to do some testing with the new revChatGPT workarounds to get this to work.
A docker file is provided if you wish to run your bot in a docker container. To create a docker image from the directory which contains this twitter bot
docker build -t chatgpt-twitter-bot .
This will create a docker image which can then be used to instantiate a docker container.
docker run -t --name=chatgpt-twitter-bot-container -p replace-with-your-local-ip:8080:80 chatgpt-twitter-bot