Update ponderations, add reaction to reactions, add random voice channel connection

This commit is contained in:
Edgar P. Burkhart 2024-06-11 19:18:46 +02:00
parent 50f32a620f
commit 27138120a7
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 31 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
/env
/assets
/config.toml
/wordlist.pickle
__pycache__

View file

@ -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"