Giter VIP home page Giter VIP logo

maury-bot's Introduction

Python Discord Bot with GPT-3 Integration

I am currently working on many more features! Current README documentation is slightly outdated with latest release

Join this discord: https://discord.gg/KtEpyEUX I'll help you set up the bot on your own server and help you maintain it. :)


This discord bot will intelligently respond to you on discord, with a chance to be triggered on when users emote react to messages.

Reactions on your server's custom emotes.

image

Tag @bot to respond to any message:

image

Responds with the server's emotes:

image

Use /chat to get a "Hello, World!" message.

image

Use command /speak to get a voice message into the voice channel. To speak a message exactly as you type use "", otherwise will translate into the voice of your bot.

image

Trained using: https://www.youtube.com/watch?v=E-SNQo9STps

Reference: https://github.com/elevenlabs/discord-bot

sudo apt install ffmpeg

Setup

Python 3.9

Created using this template: https://github.com/kkrypt0nn/Python-Discord-Bot-Template

I use Raspberry Pi OS Lite with this application running in the background using tmux.

1. Preliminaries

2. Setup repository

  • Clone repo, and start python virtual enviroment

    git clone https://github.com/evmckinney9/maury-bot.git
    cd maury-bot
    python3.9 -m venv maury_venv
    source maury_venv/bin/activate
    python -m pip install -r requirements.txt
    pip install -e .
    touch config.json
  • Put API keys into config.json

    {
        "token": "YOUR_BOT_TOKEN_HERE",
        "permissions": "466004442176",
        "application_id": "YOUR_APPLICATION_ID_HERE",
        "sync_commands_globally": false,
        "owners": [
            "YOUR_DISCORD_USER_ID",
            502280530520440862
        ],
        "openai_api_key": "YOUR_OPENAI_KEY_HERE",
        "elevenlabs_key": "YOUR_ELEVENLABS_KEY_HERE",
    }

3. Start Application

tmux attach
python bot.py

exit using Ctrl+B, D


Usage

To define a bot persona, extend AbstractBot in botPopulation.py Example:

class MauryBot(AbstractBotPersonality, AbstractBot):
    def __init__(self):
        AbstractBotPersonality.__init__(self)
        self.name = "Captain Maury"
        self.description = "The Desolate of Foggy Dock"
        self.adjectives = ["desolate", "grungy", "seafaring ghost captain"]
        self.verb = "haunting the docks"
        self.location = "fisherman's wharf"
        self.statuses = [
                "the lapping of the waves against the pier",
                "the snapping of a flag in the breeze",
                "the scuffle of feet from dock workers",
                "the clang of a boat's bell",
                "the rattle of the mooring chains",
                "the chatter of fishermen",
                "the low hum of boat engines",
                "the distant rumble of thunder",
                "the gentle clinking of fishing lines",
                "the thrum of heavy cargo machinery",
            ]
        AbstractBot.__init__(self)
        self.handler = PersonalityHandler(self)
        self.avatar_file = "maury_bot/avatars/maury.png"
        # load file into bytes
        with open(self.avatar_file, "rb") as f:
            self.avatar = f.read()

To modify the emote triggers, edit code in bot.py. Template:

# EMOTION
if any([kwarg == emoji.name for kwarg in ["emoji_name1", "emoji_name2"]):
    prompt += "Respond with EMOTION to the message from the author, on behalf of yourself and the reactor."

Example:

# condemn, tread lightly
if any([kwarg == emoji.name for kwarg in ["judgement", "flip_off", "banned"]]):
    prompt += "Respond with a condemnation of the message from the author, on behalf of yourself and the reactor."

#say congratulations
elif any([kwarg == emoji.name for kwarg in ["sheeee", "flawless_victory", "ole", "pog"]]):
    prompt += "Respond with congratulations to the message from the author, on behalf of yourself and the reactor."

To modify the probability that any given emote reaction triggers the bot, change react_probability in bot.py default:

react_probability = 0.05

Debugging

When debugging persona keywords/GPT queries, it is useful to have a mode that always responds so you can test the changes more rapidly. The simplest way is to change the react_probability=1 and test in a private discord channel to avoid spamming other members. In addition, here are some other settings I find useful: If you want to set high activity mode (react_probability=1 for 30 minutes), modify bot.py with your own emote ids here.

@bot.event
async def on_message(message: discord.Message) -> None:
    ...
    if "<trigger:emote>" in message.content:
        bot.high_activity = 2
        bot_activity_level.start()
        await message.add_reaction("<acknowledge:emote>")
    ...

Also, note that I have added my "banned" emoji to always take precendence over the variable chance.

# probability of reacting, banned has 1, otherwise .05
    react_probability = 1 #0.05
    if not bot.high_activity and np.random.random() > react_probability and reaction.emoji.name != "banned":
        return

maury-bot's People

Contributors

evmckinney9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.