Closed youlingforever0328 closed 3 years ago
请给出你的日志截图和代码,不按格式来的我怎么回答你啊(
自定义插件代码: esp32cam.py:
from nonebot import on_command from nonebot.rule import to_me from nonebot.typing import T_State from nonebot.adapters import Bot, Event
weather = on_command("天气", rule=to_me(), priority=1)
@weather.handle() async def handle_first_receive(bot: Bot, event: Event, state: T_State): args = str(event.get_message()).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海 print(f"==={args}===") if args: state["city"] = args # 如果用户发送了参数则直接赋值
@weather.got("city", prompt="你想查询哪个城市的天气呢?") async def handle_city(bot: Bot, state: T_State): city = state["city"] if city not in ["上海", "北京"]: await weather.reject("你想查询的城市暂不支持,请重新输入!") # weather = await get_weather_from_xxx(city) city_weather = "晴天" # await bot.send(city_weather) await weather.finish(city_weather)
bot.py:
import nonebot from nonebot.adapters.cqhttp import Bot as CQHTTPBot
nonebot.init()
driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot)
nonebot.load_builtin_plugins() nonebot.load_from_toml("pyproject.toml") nonebot.load_plugins("src/plugins") # 自定义的插件esp32cam在src/plugins下
app = nonebot.get_asgi()
if name == "main":
nonebot.logger.warning("Always use nb run
to start the bot instead of manually running!")
nonebot.run(app="__mp_main__:app")
------------------ 原始邮件 ------------------ 发件人: "nonebot/nonebot2" @.>; 发送时间: 2021年4月6日(星期二) 晚上6:41 @.>; @.**@.>; 主题: Re: [nonebot/nonebot2] windows下,创建插件和注册事件之后测试一直没反应 Checking for matchers in priority 1... (#315)
请给出你的日志截图和代码,不按格式来的我怎么回答你啊(
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
能否截图或者使用markdown代码块格式发送,我这看到的全是乱码,还有提供你的完整日志
------------------ 原始邮件 ------------------ 发件人: "nonebot/nonebot2" @.>; 发送时间: 2021年4月6日(星期二) 晚上7:00 @.>; @.**@.>; 主题: Re: [nonebot/nonebot2] windows下,创建插件和注册事件之后测试一直没反应 Checking for matchers in priority 1... (#315)
能否截图或者使用markdown代码块格式发送,我这看到的全是乱码
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
请你使用github网页版或官方客户端进行回复,你这邮件回复全是乱码
你的配置使用的是 command_start=["/"]
请你使用 /天气
触发命令
好的,感谢
**windows下,创建插件和注册事件之后测试一直没反应 Checking for matchers in priority 1...