diff --git a/demo/plugins/groupadmin.py b/demo/plugins/groupadmin.py index cfd42f11..b596f0a2 100644 --- a/demo/plugins/groupadmin.py +++ b/demo/plugins/groupadmin.py @@ -1,6 +1,7 @@ from aiocqhttp import Error as CQHttpError from none import on_notice, NoticeSession, on_request, RequestSession +from none.helpers import render_expression as __ GROUP_GREETING = ( '欢迎新同学 {name}[]![CQ:face,id=63][CQ:face,id=63][CQ:face,id=63]', @@ -18,7 +19,7 @@ async def _(session: NoticeSession): info = await session.bot.get_group_member_info(**session.ctx, no_cache=True) name = info['card'] or info['nickname'] or '新成员' - await session.send_expr(GROUP_GREETING, name=name, **session.ctx) + await session.send(__(GROUP_GREETING, name=name, **session.ctx)) except CQHttpError: pass diff --git a/demo/plugins/tuling.py b/demo/plugins/tuling.py index bc6fc8d0..3fe3cc56 100644 --- a/demo/plugins/tuling.py +++ b/demo/plugins/tuling.py @@ -1,5 +1,3 @@ -import asyncio - from none import ( on_command, CommandSession, on_natural_language, NLPSession, NLPResult @@ -12,7 +10,7 @@ async def tuling(session: CommandSession): finish = message in ('结束', '拜拜', '再见') if finish: - asyncio.ensure_future(session.send('拜拜啦,你忙吧,下次想聊天随时找我哦~')) + session.finish('拜拜啦,你忙吧,下次想聊天随时找我哦~') return # call tuling api @@ -20,10 +18,9 @@ async def tuling(session: CommandSession): one_time = session.get_optional('one_time', False) if one_time: - asyncio.ensure_future(session.send(reply)) + session.finish(reply) else: - del session.args['message'] - session.get('message', prompt=reply) + session.pause(reply) @tuling.args_parser diff --git a/demo/plugins/weather/__init__.py b/demo/plugins/weather/__init__.py index 4696ff10..01392289 100644 --- a/demo/plugins/weather/__init__.py +++ b/demo/plugins/weather/__init__.py @@ -2,16 +2,17 @@ from none import ( CommandSession, CommandGroup, on_natural_language, NLPSession, NLPResult ) +from none.helpers import render_expression as __ -from . import expressions as expr +from . import expressions as e w = CommandGroup('weather') @w.command('weather', aliases=('天气', '天气预报')) async def weather(session: CommandSession): - city = session.get('city', prompt_expr=expr.WHICH_CITY) - await session.send_expr(expr.REPORT, city=city) + city = session.get('city', prompt=__(e.WHICH_CITY)) + await session.send(__(e.REPORT, city=city)) @weather.args_parser