go-matrix-openai-wiki-bot

command module
v0.0.0-...-9d18ce4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-matrix-openai-wiki-bot

A Matrix bot that searches Wikipedia for articles based on user commands, summarises them using OpenAI's GPT model, caches the summaries, and replies in Matrix rooms.

Features

  • Wikipedia Search: Searches for articles on Wikipedia based on user input.
  • Article Summarisation: Uses OpenAI's GPT model to summarise articles.
  • Caching Mechanism: Caches summaries to avoid redundant API calls.
  • Configurable: All settings are configurable via a YAML file.
  • Concurrent Requests: Handles multiple requests concurrently using Goroutines.

Prerequisites

  • Go (version 1.22 or higher)
  • Docker (if you prefer running the bot in a container)
  • Git (for cloning the repository)
  • An OpenAI API key
  • A Matrix account and access token

Setup Instructions

1. Clone the Repository
git clone https://github.com/tcpipuk/go-matrix-openai-wiki-bot.git
cd go-matrix-openai-wiki-bot
2. Update Configuration
  • Copy the sample configuration file:

    cp config.example.yaml config.yaml
    
  • Edit config.yaml and update the following fields:

    • Matrix Configuration:

      • homeserver: Your Matrix homeserver URL.
      • user_id: The Matrix user ID of your bot.
      • access_token: The access token for your bot.
    • OpenAI Configuration:

      • api_key: Your OpenAI API key.
      • model: The OpenAI model you wish to use (e.g., gpt-4o-mini).
      • system_prompt: The prompt provided to the model.
    • Bot Configuration:

      • output_dir: Directory where summaries will be cached.
      • command: The command prefix to trigger the bot (e.g., !wiki).
3. Build and Run the Bot
Option 1: Run Directly

Ensure you have Go installed.

  • Install dependencies:

    go mod download
    
  • Build the application:

    go build -o go-matrix-openai-wiki-bot .
    
  • Run the application:

    ./go-matrix-openai-wiki-bot
    
Option 2: Run with Docker
  • Build the Docker image:

    docker build -t go-matrix-openai-wiki-bot .
    
  • Run the Docker container:

    docker run -d \
      -v $(pwd)/config.yaml:/app/config.yaml \
      -v $(pwd)/output:/app/output \
      --name go-matrix-openai-wiki-bot \
      go-matrix-openai-wiki-bot
    

Note: The -v flags mount your local config.yaml and output directory into the container.

4. Test the Bot
  • Invite your bot to a Matrix room.

  • Send a message using the configured command, e.g.:

    !wiki Computer
    
  • The bot should reply with a summarised version of the Wikipedia article.

Docker Image from GitHub Container Registry

Alternatively, you can pull the pre-built Docker image from GHCR:

docker pull ghcr.io/tcpipuk/go-matrix-openai-wiki-bot:latest

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Licence

This project is licensed under the MIT Licence. See the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址