mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 09:38:23 +08:00
Add "usage" command demo
This commit is contained in:
parent
0a3d07b70e
commit
04219275d0
@ -3,6 +3,13 @@ from nonebot import (
|
|||||||
on_natural_language, NLPSession, NLPResult
|
on_natural_language, NLPSession, NLPResult
|
||||||
)
|
)
|
||||||
|
|
||||||
|
__plugin_name__ = '智能聊天'
|
||||||
|
__plugin_usage__ = r"""
|
||||||
|
智能聊天功能使用帮助
|
||||||
|
|
||||||
|
直接跟我聊天即可~
|
||||||
|
""".strip()
|
||||||
|
|
||||||
|
|
||||||
@on_command('tuling', aliases=('聊天', '对话'))
|
@on_command('tuling', aliases=('聊天', '对话'))
|
||||||
async def tuling(session: CommandSession):
|
async def tuling(session: CommandSession):
|
||||||
|
14
demo/plugins/usage.py
Normal file
14
demo/plugins/usage.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import nonebot
|
||||||
|
from nonebot import on_command, CommandSession
|
||||||
|
|
||||||
|
|
||||||
|
@on_command('usage', aliases=['使用帮助', '帮助', '使用方法'])
|
||||||
|
async def _(session: CommandSession):
|
||||||
|
plugins = list(filter(lambda p: p.name, nonebot.get_loaded_plugins()))
|
||||||
|
arg = session.current_arg_text.strip().lower()
|
||||||
|
if not arg:
|
||||||
|
session.finish(
|
||||||
|
'我现在支持的功能有:\n\n' + '\n'.join(p.name for p in plugins))
|
||||||
|
for p in plugins:
|
||||||
|
if p.name.lower() == arg:
|
||||||
|
await session.send(p.usage)
|
@ -6,6 +6,13 @@ from nonebot.helpers import render_expression as __
|
|||||||
|
|
||||||
from . import expressions as e
|
from . import expressions as e
|
||||||
|
|
||||||
|
__plugin_name__ = '天气'
|
||||||
|
__plugin_usage__ = r"""
|
||||||
|
天气功能使用帮助
|
||||||
|
|
||||||
|
天气 [城市名称]
|
||||||
|
""".strip()
|
||||||
|
|
||||||
w = CommandGroup('weather')
|
w = CommandGroup('weather')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user