A-kirami / nonebot-plugin-chatgpt

MIT License
319 stars 37 forks source link

报错:'NoneType' object has no attribute 'new_page' #126

Open Forgerly-OR-Henry opened 1 year ago

Forgerly-OR-Henry commented 1 year ago

报告清单

影响版本

0.7.4

问题描述

触发指令后报错'NoneType' object has no attribute 'new_page'。

复现步骤

1.按要求完成配置 2.QQ群发送指令

预期行为

正常回复结果或群中报告错误

实际行为

群未回复,终端报错'NoneType' object has no attribute 'new_page'。

日志信息

02-22 00:41:27 [SUCCESS] nonebot | ONEBOT V11 | [message.group.normal]: Message -853087146 from @[群:] "C-自我介绍" 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from plugins.mute, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from plugins.black_word, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from extensive_plugin.zhenxun_plugin_intercept_withdraw, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from extensive_plugin.nonebot_plugin_admin.word_analyze, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from plugins.mute, type=message, priority=1, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from plugins.black_word, type=message, priority=1, temp=False> running complete {'time': 1676997687, 'self_id': , 'post_type': 'message', 'sub_type': 'normal', 'user_id': , 'message_type': 'group', 'message_id': -853087146, 'message': [{'type': 'text', 'data': {'text': 'C-自我介绍'}}], 'original_message': [{'type': 'text', 'data': {'text': 'C-自我介绍'}}], 'raw_message': 'C-自我介绍', 'font': 0, 'sender': {'user_id': , 'nickname': 'Forgerly·OR·Henry', 'sex': 'unknown', 'age': 0, 'card': '', 'area': '', 'level': '', 'role': 'admin', 'title': ''}, 'to_me': False, 'reply': None, 'group_id': , 'anonymous': None, 'message_seq': 43635} 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from extensive_plugin.zhenxun_plugin_intercept_withdraw, type=message, priority=1, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from extensive_plugin.nonebot_plugin_admin.word_analyze, type=message, priority=1, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from basic_plugins.chat_history.chat_message, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from plugins.parse_bilibili_json, type=message, priority=1, temp=False> 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from plugins.parse_bilibili_json, type=message, priority=1, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from basic_plugins.chat_history.chat_message, type=message, priority=1, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from extensive_plugin.nonebot_plugin_admin.auto_ban, type=message, priority=2, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from extensive_plugin.nonebot_plugin_admin.img_check, type=message, priority=2, temp=False> 02-22 00:41:27 [INFO] extensive_plugin | 收到的消息: "C-自我介绍" 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from extensive_plugin.nonebot_plugin_admin.auto_ban, type=message, priority=2, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from extensive_plugin.nonebot_plugin_admin.img_check, type=message, priority=2, temp=False> running complete 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from plugins.fudu, type=message, priority=999, temp=False> 02-22 00:41:27 [INFO] nonebot | Event will be handled by <Matcher from extensive_plugin.nonebot_plugin_chatgpt.utils, type=message, priority=999, temp=False> 02-22 00:41:27 [INFO] nonebot | Matcher <Matcher from plugins.fudu, type=message, priority=999, temp=False> running complete 02-22 00:41:28 [ERROR] extensive_plugin | playwright未安装,请先在shell中运行playwright install Traceback (most recent call last): File "/home/zhenxun_bot/bot.py", line 21, in nonebot.run() File "/usr/local/lib/python3.9/site-packages/nonebot/init.py", line 261, in run get_driver().run(*args, kwargs) File "/usr/local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 170, in run uvicorn.run( File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 463, in run server.run() File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 668, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 635, in simple_run await handler( File "/usr/local/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 92, in call return await self.call(values) File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt/init.py", line 60, in ai_chat await chat_bot.playwright_start()

File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt/chatgpt.py", line 54, in playwright_start self.browser = await playwright.firefox.launch( File "/usr/local/lib/python3.9/site-packages/playwright/async_api/_generated.py", line 11793, in launch await self._async( File "/usr/local/lib/python3.9/site-packages/playwright/_impl/_browser_type.py", line 90, in launch Browser, from_channel(await self._channel.send("launch", params)) File "/usr/local/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 39, in send return await self.inner_send(method, params, False) File "/usr/local/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 63, in inner_send result = next(iter(done)).result() playwright._impl._api_types.Error: Protocol error (Browser.enable): Browser closed. ==================== Browser output: ====================

/root/.cache/ms-playwright/firefox-1323/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-UB7ecl -juggler-pipe -silent pid=12381 [pid=12381][err] /root/.cache/ms-playwright/firefox-1323/firefox/firefox: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /root/.cache/ms-playwright/firefox-1323/firefox/libstdc++.so.6) [pid=12381] [pid=12381] starting temporary directories cleanup =========================== logs =========================== /root/.cache/ms-playwright/firefox-1323/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-UB7ecl -juggler-pipe -silent pid=12381 [pid=12381][err] /root/.cache/ms-playwright/firefox-1323/firefox/firefox: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /root/.cache/ms-playwright/firefox-1323/firefox/libstdc++.so.6) [pid=12381] [pid=12381] starting temporary directories cleanup ============================================================ 02-22 00:41:28 [INFO] nonebot | Matcher running complete 02-22 00:41:28 [ERROR] nonebot | Running matcher failed. Traceback (most recent call last): File "/home/zhenxun_bot/bot.py", line 21, in nonebot.run() File "/usr/local/lib/python3.9/site-packages/nonebot/__init__.py", line 261, in run get_driver().run(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 170, in run uvicorn.run( File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 463, in run server.run() File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 668, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 635, in simple_run await handler( File "/usr/local/lib/python3.9/site-packages/nonebot/dependencies/__init__.py", line 92, in __call__ return await self.call(**values) File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt/__init__.py", line 66, in ai_chat msg = await chat_bot(**session[event]).get_chat_response(text) File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt/chatgpt.py", line 123, in get_chat_response async with self.get_page() as page: File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__ return await self.gen.__anext__() File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt/chatgpt.py", line 115, in get_page page = await self.content.new_page() AttributeError: 'NoneType' object has no attribute 'new_page'

额外补充

机器人使用的是HibiKier开发的真寻,插件正常载入。 以上日志中QQ群id和个人QQid已删除,并不是没有。 其他issues中的方法已经尝试过,并没有用。

YouYouLip commented 1 year ago

和你一样的错误代码 只不过我貌似是apscheduler引起的 [ERROR] apscheduler | Job "refresh_session (trigger: interval[0:30:00], next run at: 2023-02-28 12:42:58 CST)" raised an exception 看错误代码好像是自动token刷新的问题?

glzat commented 1 year ago

我也是

renvys commented 11 months ago

同样的问题 playwright._impl._api_types.Error: Executable doesn't exist at C:\Users\admin\AppData\Local\ms-playwright\firefox-1424\firefox\firefox.exe 但是这个路径下是有firefox.exe的