Skip to content

A simple Discord bot that listens to messages in specific channels and responds using the openweb-ui API.

License

Notifications You must be signed in to change notification settings

ajarmoszuk/openweb-ui-discord-chat-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Discord Bot with OpenWeb-UI Integration

This repository contains a Discord bot script that listens to messages in specific channels or threads within Discord and processes these messages using the OpenWeb API for AI-driven responses.

Features

  • Listens to messages in a designated channel or threads within that channel.
  • Sends user messages to the OpenWeb API for processing.
  • Replies with AI-generated responses based on the user's input.
  • Ignores messages from bot users to prevent loops or spam.

Prerequisites

To run this bot, ensure you have the following:

  1. Python 3.8 or higher installed.
  2. Required Python packages installed (see Installation).
  3. A Discord bot token.
  4. Access to the OpenWeb API, including your API key and endpoint URL.

Setup

  1. Clone the repository:

    git clone https:/github.com/ajarmoszuk/openweb-ui-discord-chat-bot
    cd openweb-ui-discord-chat-bot
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure your environment:

    • Replace the placeholders in the script with your actual values:
      • DISCORD_TOKEN: Your Discord bot token.
      • OPENWEB_API_URL: The OpenWeb API endpoint.
      • MODEL_NAME: The name of the model to use in the OpenWeb API.
      • MONITORED_CHANNEL_ID: The ID of the channel to monitor.
      • OPENWEB_API_KEY: Your OpenWeb API key.

Usage

  1. Run the bot:

    python bot.py
  2. Add the bot to your Discord server with appropriate permissions, ensuring it has access to the monitored channel.

  3. The bot will now listen to messages in the specified channel and threads, send them to the OpenWeb API, and reply with the generated response.

File Details

bot.py

The main script for the bot. It includes:

  • Initialization of the bot client.
  • Listener for new messages (on_message_create).
  • Integration with the OpenWeb API (process_message).

Environment Variables

You can use environment variables for configuration:

export DISCORD_TOKEN="your-discord-bot-token"
export OPENWEB_API_URL="http://your-openweb-api-endpoint/api/chat/completions"
export MODEL_NAME="your-model-name"
export MONITORED_CHANNEL_ID=123456789012345678
export OPENWEB_API_KEY="your-openweb-user-jwt-api-key"

Dependencies

  • interactions: For Discord bot interactions.
  • requests: For making HTTP requests to the OpenWeb API.

Install these packages via:

pip install interactions requests

License

This project is licensed under the MIT License.

Troubleshooting

  • Bot not responding:

    • Check that the bot is added to the server and has permissions to read and send messages in the monitored channel.
    • Verify the MONITORED_CHANNEL_ID is correctly set.
  • Error with OpenWeb API:

    • Confirm that your API URL, key, and model name are correctly configured.
    • Check the OpenWeb API documentation for additional troubleshooting steps.
  • Timeouts or delays:

    • The OpenWeb API request includes a 30-second timeout. Ensure the API is responsive and capable of handling the request load.

Feel free to contribute by submitting issues or pull requests!

About

A simple Discord bot that listens to messages in specific channels and responds using the openweb-ui API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages