From 27138120a708ffb60b41195683e2825ac93c3fdb Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Tue, 11 Jun 2024 19:18:46 +0200 Subject: [PATCH] Update ponderations, add reaction to reactions, add random voice channel connection --- .gitignore | 1 + botbotbot/__main__.py | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cda296d..7a7b50c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /env +/assets /config.toml /wordlist.pickle __pycache__ diff --git a/botbotbot/__main__.py b/botbotbot/__main__.py index 2ebe7c1..73b87ae 100644 --- a/botbotbot/__main__.py +++ b/botbotbot/__main__.py @@ -1,3 +1,4 @@ +import asyncio import pickle import random import tomllib @@ -18,7 +19,8 @@ delay = config.get("delay", 60) system_prompt = """Tu es une intelligence artificelle qui répond en français. Ta réponse doit être très courte. -Ta réponse doit être longue d'une phrase.""" +Ta réponse doit être une seule phrase. +TA RÉPONSE DOIT ÊTRE EN FRANÇAIS !!!""" aibot = AIBot( config.get("mistral_api_key"), model="open-mixtral-8x7b", @@ -28,6 +30,7 @@ aibot = AIBot( intents = discord.Intents.default() intents.members = True intents.message_content = True +intents.reactions = True intents.voice_states = True bot = discord.Bot(description=description, intents=intents) @@ -73,9 +76,9 @@ async def on_message(message): if message.flags.ephemeral: return - if random.random() < 1 / 12: + if random.random() < 1 / 6: await reply(message) - elif random.random() < 1 / 48: + elif random.random() < 1 / 24: await ai_reply(message) if random.random() < 1 / 6: @@ -88,6 +91,17 @@ async def on_message(message): await react(message) +@bot.listen("on_reaction_add") +async def add_more_reaction(reaction, user): + if random.random() < 1 / 2: + await reaction.message.add_reaction(reaction.emoji) + + +@bot.listen("on_message_edit") +async def react_message_edit(before, after): + await after.add_reaction("👀") + + @bot.listen("on_message") async def rando_shuffle(message): if not message.flags.ephemeral and random.random() < 1 / 24 and message.guild: @@ -174,6 +188,19 @@ async def voice_random_nicks(member, before, after): if before.channel is None and random.random() < 1 / 24: await try_shuffle(member.guild) + if ( + before.channel is None + and after.channel is not None + and random.random() < 1 / 96 + and bot not in after.channel.members + ): + await asyncio.sleep(random.randrange(60)) + vo = await after.channel.connect() + source = await discord.FFmpegOpusAudio.from_probe("assets/allo.ogg") + vo.play(source) + await asyncio.sleep(random.randrange(60)) + await vo.disconnect() + @bot.slash_command( name="indu", guild_ids=guild_ids, description="Poser une question à MistralAI"