39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Bot-vs-bot conversation commands."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from discord.ext import commands
|
|
|
|
from vibe_bot.commands._state import require_app, set_app
|
|
|
|
if TYPE_CHECKING:
|
|
from discord.ext.commands import Bot
|
|
from discord.ext.commands import Context as CommandsContext
|
|
|
|
from vibe_bot.app import App
|
|
|
|
MIN_TALKFORME_PARTS = 4
|
|
|
|
|
|
def register(bot: commands.Bot, app: App) -> None:
|
|
"""Register the conversation commands."""
|
|
set_app(app)
|
|
bot.command(name="talkforme")(talkforme)
|
|
|
|
|
|
@commands.cooldown(rate=1, per=30, type=commands.BucketType.user)
|
|
async def talkforme(ctx: CommandsContext[Bot], *, message: str) -> None:
|
|
"""Have two bots talk to each other about a topic.
|
|
|
|
Usage: !talkforme bot1 bot2 4 some conversation topic
|
|
"""
|
|
app = require_app()
|
|
parts = message.split(" ", maxsplit=MIN_TALKFORME_PARTS - 1)
|
|
if len(parts) < MIN_TALKFORME_PARTS:
|
|
await ctx.send("Usage: !talkforme bot1 bot2 <number> <topic>")
|
|
return
|
|
|
|
await app.conversation.run(ctx, parts[0], parts[1], parts[2], " ".join(parts[3:]))
|