Compare commits
2 commits
b1bcb44dac
...
5faf0b9487
Author | SHA1 | Date | |
---|---|---|---|
5faf0b9487 | |||
5e75dd73a8 |
3 changed files with 52 additions and 2 deletions
22
Dockerfile
Normal file
22
Dockerfile
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV UV_LINK_MODE=copy
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||||
|
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||||
|
uv sync --frozen --no-install-project --no-dev
|
||||||
|
|
||||||
|
ADD . /app
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv sync --frozen --no-dev
|
||||||
|
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
ENTRYPOINT []
|
||||||
|
|
||||||
|
CMD ["uv", "run", "python", "-m", "botbotbot"]
|
|
@ -42,6 +42,14 @@ class VoiceBot:
|
||||||
guild_ids=self.guild_ids,
|
guild_ids=self.guild_ids,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self.bot.add_application_command(
|
||||||
|
discord.SlashCommand(
|
||||||
|
self.unjoin_voice,
|
||||||
|
name="unjoin",
|
||||||
|
description="Déconnecter du channel vocal",
|
||||||
|
guild_ids=self.guild_ids,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
async def random_connect(self) -> None:
|
async def random_connect(self) -> None:
|
||||||
while True:
|
while True:
|
||||||
|
@ -131,11 +139,16 @@ class VoiceBot:
|
||||||
await self.disconnect_voice(channel.guild)
|
await self.disconnect_voice(channel.guild)
|
||||||
if vo is None or vo.channel != channel:
|
if vo is None or vo.channel != channel:
|
||||||
vo = await channel.connect()
|
vo = await channel.connect()
|
||||||
self.vo[channel.guild.id] = vo
|
self.vo[channel.guild.id] = vo
|
||||||
return vo
|
return vo
|
||||||
|
|
||||||
async def disconnect_voice(self, guild: discord.Guild) -> None:
|
async def disconnect_voice(self, guild: discord.Guild) -> None:
|
||||||
if vo := self.vo.pop(guild.id, None):
|
if vo := self.vo.pop(guild.id, None):
|
||||||
|
if self.cambai is not None:
|
||||||
|
source = await discord.FFmpegOpusAudio.from_probe(
|
||||||
|
self.cambai.tts("À plus les jeunes !")
|
||||||
|
)
|
||||||
|
await vo.play(source, wait_finish=True)
|
||||||
await vo.disconnect()
|
await vo.disconnect()
|
||||||
|
|
||||||
async def join_voice(self, ctx: discord.ApplicationContext) -> None:
|
async def join_voice(self, ctx: discord.ApplicationContext) -> None:
|
||||||
|
@ -153,6 +166,21 @@ class VoiceBot:
|
||||||
delete_after=30,
|
delete_after=30,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def unjoin_voice(self, ctx: discord.ApplicationContext) -> None:
|
||||||
|
if ctx.user.voice:
|
||||||
|
await ctx.respond(
|
||||||
|
f"Disconnecting from voice channel {ctx.user.voice.channel}.",
|
||||||
|
ephemeral=True,
|
||||||
|
delete_after=30,
|
||||||
|
)
|
||||||
|
await self.disconnect_voice(ctx.user.voice.channel.guild)
|
||||||
|
else:
|
||||||
|
await ctx.respond(
|
||||||
|
"You are not connected to a voice channel.",
|
||||||
|
ephemeral=True,
|
||||||
|
delete_after=30,
|
||||||
|
)
|
||||||
|
|
||||||
async def on_voice_state_update(
|
async def on_voice_state_update(
|
||||||
self,
|
self,
|
||||||
member: discord.Member,
|
member: discord.Member,
|
||||||
|
|
|
@ -14,7 +14,7 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
hasspy = "botbotbot:main"
|
botbotbot = "botbotbot:main"
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue