Files
LangBot/plugins/misc/EssentialCommands/components/commands/help.py
T

37 lines
1.2 KiB
Python

# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import AsyncGenerator
from langbot_plugin.api.definition.components.command.command import Command, Subcommand
from langbot_plugin.api.entities.builtin.command.context import ExecuteContext, CommandReturn
from i18n import get_text
class Help(Command):
async def initialize(self):
await super().initialize()
@self.subcommand(
name="",
help="Show the help of a command",
usage="help <command>",
)
async def _(self: Help, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
assume_command_prefix = context.full_command_text[0]
language = self.plugin.get_language()
title = get_text(language, "help.title")
website = get_text(language, "help.website")
tip = get_text(language, "help.command_tip", command_prefix=assume_command_prefix)
help_message = f"{title}\n\n- {website}\n\n{tip}"
yield CommandReturn(
text=help_message
)