nonebot2/plugins/weather.py

16 lines
508 B
Python
Raw Normal View History

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