Created
December 5, 2022 21:02
-
-
Save bplunkert/568979c0f54ee8ed82273c31f349bce6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from revChatGPT.revChatGPT import Chatbot | |
import json | |
import os | |
# Get your config in JSON | |
config = { | |
"Authorization": "<API-KEY>", | |
"session_token": os.environ["CHATGPT_SESSION_TOKEN"] | |
} | |
ai = Chatbot(config, conversation_id=None) | |
ai.refresh_session() | |
import discord | |
class ChatBot(discord.Client): | |
async def on_ready(self): | |
print('Logged on as', self.user) | |
async def on_message(self, message): | |
# don't respond to ourselves | |
if message.author == self.user: | |
return | |
if message.content == 'reset': | |
ai.reset_chat() | |
await message.channel.send("Reset AI conversation.") | |
else: | |
resp = ai.get_chat_response(message.content, output="text") # Sends a request to the API and returns the response by OpenAI | |
await message.channel.send(resp['message']) | |
intents = discord.Intents.default() | |
intents.message_content = True | |
client = ChatBot(intents=intents) | |
token = os.environ['DISCORD_TOKEN'] | |
client.run(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment