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

42 lines
1.4 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 Any, 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 Plugin(Command):
async def initialize(self):
await super().initialize()
@self.subcommand(
name="",
help="List all loaded plugins",
usage="plugin",
)
async def _(self: Plugin, context: ExecuteContext) -> AsyncGenerator[CommandReturn, None]:
language = self.plugin.get_language()
plugins = await self.plugin.list_plugins_manifest()
plugin_list_str = ''
for plugin in plugins:
plugin_manifest = plugin['manifest']
name = plugin_manifest['metadata']['name']
description = plugin_manifest['metadata']['description'][language]
plugin_list_str += get_text(language, "plugin.item", name=name, description=description) + "\n\n"
title = get_text(language, "plugin.title")
output = f"{title}\n\n{plugin_list_str}"
yield CommandReturn(
text=output
)