Skip to content

quillan86/kautos-bot

 
 

Repository files navigation

Kautos Discord Bot

Discord Bot built with ChatGPT to query information about Kautos


Warning

Features

  • /chat [message] Chat with ChatGPT!

  • /summary Summary that ChatGPT uses to have long term memory.

  • /qa [message] Answer a question from ground truth from World Anvil. Question and Answer are part of the ChatGPT conversation.

  • /agent [message] Agent-based question answering using multiple tools. (World Anvil, Wikipedia, Google Search, Wolfram Alpha) Question and Answer are part of the ChatGPT conversation.

  • /draw [prompt] Generate an image with the Dalle2 model

  • /private ChatGPT switch to private mode

  • /public ChatGPT switch to public mode

  • /replyall ChatGPT switch between replyAll mode and default mode

  • /reset Clear ChatGPT conversation history

  • /chat-model Switch different chat model

    • OFFICIAL-GPT-3.5: GPT-3.5 model
    • OFFICIAL-GPT-4.0: GPT-4.0 model (make sure your account can access gpt-4 model)

Chat

image

Mode

  • public mode (default) the bot directly reply on the channel

    image

  • private mode the bot's reply can only be seen by the person who used the command

    image

  • replyall mode the bot will reply to all messages in the channel without using slash commands (/chat will also be unavailable)

    Warning The bot will easily be triggered in replyall mode, which could cause program failures

Setup

Critical prerequisites to install

  • run pip3 install -r requirements.txt

  • Rename the file .env.dev to .env

  • Recommended python version 3.10

Step 1: Create a Discord bot

  1. Go to https://discord.com/developers/applications create an application

  2. Build a Discord bot under the application

  3. Get the token from bot setting

    image

  4. Store the token to .env under the DISCORD_BOT_TOKEN

    image
  5. Turn MESSAGE CONTENT INTENT ON

    image

  6. Invite your bot to your server via OAuth2 URL Generator

    image

Step 2: Official API authentication

Geanerate an OpenAI API key

  1. Go to https://beta.openai.com/account/api-keys

  2. Click Create new secret key

    image

  3. Store the SECRET KEY to .env under the OPENAI_API_KEY

  4. You're all set for Step 3

Step 2: Website ChatGPT authentication - 2 approaches

  • 2023-04-01: Only Support Plus Account now

Email/Password authentication (Not supported for Google/Microsoft accounts)

  1. Create an account on https://chat.openai.com/chat and open it

  2. Open console with F12

  3. Open Application tab > Cookies

image

  1. Copy the value for _puid from cookies and paste it into .env under PUID

  2. Save your email into .env under OPENAI_EMAIL

  3. Save your password into .env under OPENAI_PASSWORD

  4. You're all set for Step 3

ACCESS token authentication

  1. Open https://chat.openai.com/api/auth/session

  2. Open console with F12

  3. Open Application tab > Cookies

    image

  4. Copy the value for _puid from cookies and paste it into .env under PUID

  5. Copy the value for accessToken from cookies and paste it into .env under ACCESS_TOKEN

  6. You're all set for Step 3

Step 2: Google Bard authentication

  1. Go to https://bard.google.com/

  2. Open console with F12

  3. Open Application tab > Cookies

  4. Copy the value for __Secure-1PSID from cookies and paste it into .env under BARD_SESSION_ID

  5. You're all set for Step 3

Step 2: Microsoft Bing authentication

  1. Rename the file cookies.dev.json to cookies.json

  2. Go to https://bing.com/chat and log in your Microsoft account

  3. Use Cookie Editor or similar extensions to export the cookies

  4. Paste it into cookies.json

  5. You're all set for Step 3

Step 3: Run the bot on the desktop

  1. Open a terminal or command prompt

  2. Navigate to the directory where you installed the ChatGPT Discord bot

  3. Run python3 main.py or python main.py to start the bot

Step 3: Run the bot with Docker

  1. Build the Docker image & Run the Docker container docker compose up -d

  2. Inspect whether the bot works well docker logs -t chatgpt-discord-bot

    Stop the bot:

    • docker ps to see the list of running services
    • docker stop <BOT CONTAINER ID> to stop the running bot

Have a good chat!

Optional: Disable logging

  • Set the value of LOGGING in the .env to False

Optional: Setup system prompt

  • A system prompt would be invoked when the bot is first started or reset

  • You can set it up by modifying the content in system_prompt.txt

  • All the text in the file will be fired as a prompt to the bot

  • Get the first message from ChatGPT in your discord channel!

    1. Right-click the channel you want to recieve the message, Copy ID

      channel-id

    2. paste it into .env under DISCORD_CHANNEL_ID


中文說明

About

Integrate ChatGPT into your own discord bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.1%
  • Dockerfile 0.9%