Improve session

This commit is contained in:
Richard Chien
2018-06-25 16:50:34 +08:00
parent 77db6bfc84
commit 7da2043f94
6 changed files with 67 additions and 88 deletions

View File

@ -3,14 +3,13 @@ from aiocqhttp.message import unescape
import none
from none import permissions as perm
from none.command import Session
from none.helpers import send
@none.on_command('echo')
async def echo(bot, session: Session):
await send(bot, session.ctx, session.current_arg)
async def echo(session: Session):
await session.send(session.current_arg)
@none.on_command('say', permission=perm.SUPERUSER)
async def _(bot, session: Session):
await send(bot, session.ctx, unescape(session.current_arg))
async def _(session: Session):
await session.send(unescape(session.current_arg))

View File

@ -1,16 +1,15 @@
import none
from none.command import Session
from none.helpers import send
@none.on_command('weather', aliases=('天气',))
async def weather(bot, session: Session):
async def weather(session: Session):
city = session.require_arg('city', prompt='你想知道哪个城市的天气呢?')
other = session.require_arg('other')
await send(bot, session.ctx, f'你查询了{city}的天气,{other}')
other = session.require_arg('other', prompt='其他信息?')
await session.send(f'你查询了{city}的天气,{other}')
@weather.args_parser
def _(session: Session):
async def _(session: Session):
if session.current_key:
session.args[session.current_key] = session.current_arg.strip()