mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 03:56:45 +00:00
Improve session
This commit is contained in:
@ -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))
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user