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.
Tag @bot to respond to any message:
Responds with the server's emotes:
Use /chat
to get a "Hello, World!" message.
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.
Trained using: https://www.youtube.com/watch?v=E-SNQo9STps
Reference: https://github.com/elevenlabs/discord-bot
sudo apt install ffmpeg
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
.
- Setup a Pi, or any other internet connected python enviroment
- Create a discord bot https://discord.com/developers/applications
- A suggested permissions integer:
466004442176
- Enable MESSAGE CONTENT INTENT
- A suggested permissions integer:
- Obtain an Openai API key, https://beta.openai.com/account/api-keys
-
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", }
tmux attach
python bot.py
exit using Ctrl+B, D
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
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