- Pick a subreddit to scan
- Set your bot's reply with keywords
- Set the response of GPT–3 and define the invitation to go to Starton.
Clone the repository to your local machine:
git clone https://github.com/snyzeroff/Redditbot.git
> Add your information in the .env file
> Pick a subreddit to scan
> Set your bot's reply with keywords in the file seleted_keywords.txt
> Define the response of GPT–3 and set the invitation to go to *Starton*.
> run main.py
- Navigate to the Apps page
- Click create an app
- name: Set a name for your app
- type: Script
- description: Optional
- about url: Optional
- redirect uri: http://localhost:8080
- Note the outputted client id and secret
- Set the subreddit to search (default = "r/web3"):
r.subreddit('web3')
- Set the response of GPT–3 + set invitation to go to the Starton (in hypertext) website and adds 2 other decoys
reply_text = response.choices[0].text.format("[starton.io](https://starton.io/)")
reply_text += " Je t'invite à essayer un des templates de [Starton]({}).".format("[starton.io](https://starton.io/)")
comment.reply(reply_text)
- Prints that he has found a message to which he has replied and waits 10 seconds
print("Réponse envoyée pour le commentaire {}.".format(comment.id))
time.sleep(10)
- username: your Reddit username
- password: your Reddit password
- client_id: the outputted client id
- client_secret: the outputted secret
- OPENAI_API_KEY: your OpenAI API key
- add the keywords you want in the selected_keywords.txt file so that the bot only responds to comments containing these keywords (default keywords : "how to deploy smartcontract?" ; "listen to activity on the blockchain")
"how to deploy smartcontract?"
"listen to activity on the blockchain"
The script is designed to automate the process of replying to Reddit comments for which there are specific keywords on the topic of Web 3.0, using the OpenAI API to generate a reply that is published as a response to the original comment. The script also takes steps to avoid duplicate responses and API request saturation.
The script stores the IDs of comments it has already responded to in a list called "comments_replied_to". This is done to avoid replying to the same comment multiple times.
The comment identifiers are also written to a text file called "comments_replied_to.txt" to save the list between runs of the script.
Finally, the script waits 10 seconds between each iteration of the loop to avoid overloading the Reddit API with requests.
In your command prompt or terminal, navigate to the project directory.
Run the bot.py script by typing python bot.py.
The script will continuously check for new comments in the specified subreddit, and if a comment containing any of the selected keywords is found, the bot will generate a response using the OpenAI API and post it as a reply to the comment.
To stop the script, press CTRL + C in your command prompt or terminal.
To avoid replying to the same comment multiple times, the script stores the IDs of the comments it has already replied to in a text file called comments_replied_to.txt in the data directory. If you want to reset the list, simply delete the file.
The script waits for 10 seconds between each loop iteration to prevent the bot from overwhelming the Reddit API with requests.
v0.0.4 ⋮ 03-03-2023
+ Rename .env to .env.example
v0.0.3 ⋮ 27-02-2023
+ Updated the Readme
+ Added the ChangLog
v0.0.2 ⋮ 26-02-2023
+ Updated the Readme
+ Updated the Main.py file
+ Added the comments_replied_to.txt file
+ Cleaner code
v0.0.1 ⋮ 25-02-2023
+ Added Main Script
+ Cleaned up Code