jay-aye-see-kay / mcchatbot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A minecraft chatbot

What and why

Have you ever wanted a chatbot to say hi when you join or insult you when you die? I did, and it was surprisingly nice to have around so I've made it a container others can use.

swappy-20231003-210656

Available on docker hub: https://hub.docker.com/r/jayayeseekay/mcchatbot

It's pretty hacky, if you find bugs or have improvements let me know.

Requirements

  • requires a minecraft running in a docker container with rcon-cli installed
  • doesn't requires any minecraft plugins, works by listening to server logs and responding via rcon-cli

Example setup

# file: ./docker-compose.yaml
version: "3"
services:
  minecraft_server:
    container_name: your_minecraft_server # important so you have a stable container name
    image: itzg/minecraft-server:java17
    volumes:
      - ./game-data:/data
    environment:
      EULA: "TRUE"
      VERSION: "1.20.1"

  mcchatbot:
    image: jayayeseekay/mcchatbot:0.3.2
    env_file: ".env" # important to read OPENAI_API_KEY
    environment:
      MCC_CONTAINER_NAME: your_minecraft_server # must match container_name above
      MCC_BOT_NAME: "Wheatly"
      MCC_SYSTEM_MESSAGE: |
        You are the chacter Wheatley from Portal 2.
        Do not offer assistance or try to be helpful.
        Keep your responses short, about 1 line.
    volumes:
      - ./mcchatbot-data:/var/lib/mcchatbot
      # required: read-only access to docker to get logs
      - /var/run/docker.sock:/var/run/docker.sock:ro
# file: ./.env
OPENAI_API_KEY="your api key"

Configuration options

All config is done by environment variables. Documentation is best effort, see ./lib/config.py for source of truth.

Roadmap / todo / ideas

  • update github action to push a "latest" tag image
  • arm64 version of image
  • add "personas" and more customisation of the system prompt
  • support for multiple personas (still one response per event, but pick a persona at random each time)
  • rotate logs from database (currently keeps logs forever)
  • log api use by token in database (to approximate cost)
  • support other models/providers

About


Languages

Language:Python 89.8%Language:Nix 7.5%Language:Just 2.8%