Hello! I have been trying to automate my account for quite a long time now. All my attempts have failed. I am aware that it is possible as I have seen several other bots. Perhaps G’Day bot. How could it have been created without a replit API key? I am very confused. Here is the code I wanted to use yet couldn’t as I couldn’t get an API key
If it can help you solve this, you may look at the code that did not work
Click to view code
import openai
import requests
import time
openai.api_key = "YOUR_OPENAI_API_KEY"
def generate_response(text):
response = openai.Completion.create(
engine="text-davinci-002",
prompt=text,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
return response["choices"][0]["text"]
def reply_to_comment(comment_id, response):
headers = {
"Authorization": "Bearer YOUR_REPLIT_SECRET_KEY",
}
data = {
"content": response,
}
url = f"https://replit.com/api/v0/repls/{comment_id}/comments"
requests.post(url, headers=headers, json=data)
def monitor_comments():
headers = {
"Authorization": "Bearer YOUR_REPLIT_SECRET_KEY",
}
url = "https://replit.com/api/v0/comments"
while True:
comments = requests.get(url, headers=headers).json()
for comment in comments:
if comment["repl_id"] in specified_repls:
response = generate_response(comment["content"])
if response:
reply_to_comment(comment["id"], response)
elif "@your_bot_name" in comment["content"].lower():
response = generate_response(comment["content"])
if response:
reply_to_comment(comment["id"], response)
else:
response = comment["content"].lower()
if response in dictionary:
reply_to_comment(comment["id"], dictionary[response])
time.sleep(5)
specified_repls = [
"repl1_id",
"repl2_id",
"repl3_id",
]
dictionary = {
"hello": "Hi there!",
"how are you?": "I'm doing well, thank you for asking!",
}
monitor_comments()