summaryrefslogtreecommitdiff
path: root/AyaBot/plugins/weather.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-04-28 00:30:40 +0800
committerKyomotoi <[email protected]>2020-04-28 00:30:40 +0800
commitb33aba098aae9feafd77b56746b4ff5946c843cf (patch)
tree3bab5ebd949c0fc201711de3528555fc54bb5a52 /AyaBot/plugins/weather.py
downloadATRI-b33aba098aae9feafd77b56746b4ff5946c843cf.tar.gz
ATRI-b33aba098aae9feafd77b56746b4ff5946c843cf.tar.bz2
ATRI-b33aba098aae9feafd77b56746b4ff5946c843cf.zip
Initial commit
Diffstat (limited to 'AyaBot/plugins/weather.py')
-rw-r--r--AyaBot/plugins/weather.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/AyaBot/plugins/weather.py b/AyaBot/plugins/weather.py
new file mode 100644
index 0000000..f02198d
--- /dev/null
+++ b/AyaBot/plugins/weather.py
@@ -0,0 +1,22 @@
+import re
+from nonebot import on_command, CommandSession
+
+
+@on_command('weather', aliases=['天气', '查天气', '天气查询'])
+async def weather(session: CommandSession):
+ city = session.get('city', prompt='你想查哪个城市呢?')
+ date = session.get('date', prompt='你想查哪一天呢?(格式:20200427)')
+ await session.send('你查询的情况如下' + city)
+ await session.send('你想查询的日期' + date)
+
+
+async def _(session: CommandSession):
+ if session.is_first_run:
+ return
+
+ if session.current_key == 'date':
+ if not re.fullmatch(r'\d{8}', session.current_arg_text):
+ session.pause('日期格式有误,请重新输入')
+ session.args[session.current_key] = session.current_arg_text
+