2024-01-28 00:16:42 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
from typing import AsyncGenerator
|
|
|
|
|
|
2025-04-29 17:24:07 +08:00
|
|
|
from .. import operator, entities
|
2024-01-28 00:16:42 +08:00
|
|
|
|
|
|
|
|
|
2025-04-29 17:24:07 +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]:
|
2025-04-29 17:24:07 +08:00
|
|
|
reply_str = '当前已启用的内容函数: \n\n'
|
2024-01-28 00:16:42 +08:00
|
|
|
|
|
|
|
|
index = 1
|
2024-01-29 21:22:27 +08:00
|
|
|
|
2024-11-16 16:13:02 +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:
|
2025-04-29 17:24:07 +08:00
|
|
|
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)
|