Files
LangBot/pkg/command/operators/func.py

29 lines
825 B
Python
Raw Normal View History

2024-01-28 00:16:42 +08:00
from __future__ import annotations
from typing import AsyncGenerator
from .. import operator, entities
2024-01-28 00:16:42 +08:00
@operator.operator_class(name='func', help='查看所有已注册的内容函数', usage='!func')
2024-01-28 00:16:42 +08:00
class FuncOperator(operator.CommandOperator):
async def execute(
2024-01-28 18:21:43 +08:00
self, context: entities.ExecuteContext
2024-01-28 00:16:42 +08:00
) -> AsyncGenerator[entities.CommandReturn, None]:
reply_str = '当前已启用的内容函数: \n\n'
2024-01-28 00:16:42 +08:00
index = 1
2024-01-29 21:22:27 +08:00
all_functions = await self.ap.tool_mgr.get_all_functions(
plugin_enabled=True,
)
2024-01-29 21:22:27 +08:00
for func in all_functions:
reply_str += '{}. {}:\n{}\n\n'.format(
2024-01-28 18:21:43 +08:00
index,
func.name,
func.description,
)
2024-01-28 00:16:42 +08:00
index += 1
2024-01-28 18:21:43 +08:00
yield entities.CommandReturn(text=reply_str)