Update demo

This commit is contained in:
Richard Chien 2018-12-22 12:45:15 +08:00
parent 6fff0985ae
commit fb5716c6e4
3 changed files with 9 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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