Skip to content

ethanocurtis/wiki-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WikiBot

Discord OpenAI Docker License

WikiBot is a lightweight Discord bot that fetches concise answers from Wikipedia, and optionally uses OpenAI GPT-3.5 as a fallback when:

  • A topic isn’t found on Wikipedia.
  • You want to ask general questions directly via /ask.

It’s simple to set up and runs via Docker or directly with Python.


Features

  • /wiki <query> – Searches Wikipedia for the topic and returns:
    • Title
    • Short summary (AI-generated if OpenAI is configured, otherwise truncated)
    • Link to the full page
    • Falls back to GPT-3.5 if no Wikipedia page exists.
  • /ask <question> – Asks GPT-3.5 directly for concise, factual answers.
  • Works with or without OpenAI (GPT-3.5 used only if API key is provided).
  • Docker-ready for easy deployment.

Requirements

  • Python 3.9+
  • Discord bot token
  • (Optional) OpenAI API key (for enhanced summaries and AI Q&A)
  • docker & docker-compose (if running via container)

Setup (Manual)

  1. Clone the repository

    git clone https://github.com/ethanocurtis/wiki-bot.git
    cd wiki-bot
  2. Install dependencies

    pip install -r requirements.txt
  3. Set environment variables

    Create a .env file in the project root:

    DISCORD_TOKEN=your_discord_bot_token_here
    OPENAI_API_KEY=your_openai_api_key_here  # Optional
  4. Run the bot

    python bot.py

Setup (Docker)

  1. Build and run with Docker Compose

    docker-compose up -d --build
  2. Environment variables can be set in your .env file (Docker will load it automatically).


Usage

Invite your bot to a server (with applications.commands scope) and use:

  • /wiki python programming → Wikipedia summary + link
  • /wiki obscure topic → Falls back to GPT-3.5 if not found
  • /ask What is the capital of France? → GPT-3.5 answer directly

The bot will display “thinking…” while fetching/summarizing results.


Permissions

When inviting your bot, make sure it has:

  • applications.commands
  • Send Messages
  • Read Messages
  • Use Slash Commands

Notes

  • Without OpenAI API key:

    • Summaries are truncated to 50 words (no GPT).
    • /ask will return a message saying AI isn’t configured.
  • With OpenAI API key:

    • GPT-3.5 is used for concise summaries and direct Q&A.
    • Each summary uses ~50–150 tokens; Q&A may use up to ~300 tokens (see OpenAI pricing).

License

This project is licensed under the MIT License.

Support

For issues, questions, or suggestions, feel free to open an issue here on GitHub or contact me:
Discord

About

first push for testing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages