lgc-NB2Dev / nonebot-plugin-multincm

网易云多选点歌,使用自定义卡片,可以登录账号听 VIP 歌曲
MIT License
57 stars 1 forks source link

[Bug]KeyError: 'code' #1

Closed bywhite0 closed 1 year ago

bywhite0 commented 1 year ago

log:

nonebot-plugin-logpile 自动生成,已对隐私信息进行匿名化处理

2023-05-15 13:41:18.413 | ERROR    | nonebot_plugin_multincm:get_page:67 - 搜索歌曲失败
Traceback (most recent call last):

  File "<string>", line 1, in <module>
  File "/usr/local/python3/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               │     │   └ 3
               │     └ 6
               └ <function _main at 0x7f488fff7760>
  File "/usr/local/python3/lib/python3.10/multiprocessing/spawn.py", line 129, in _main
    return self._bootstrap(parent_sentinel)
           │    │          └ 3
           │    └ <function BaseProcess._bootstrap at 0x7f4890b9a3b0>
           └ <SpawnProcess name='SpawnProcess-1' parent=26466 started>
  File "/usr/local/python3/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
    │    └ <function BaseProcess.run at 0x7f4890b99a20>
    └ <SpawnProcess name='SpawnProcess-1' parent=26466 started>
  File "/usr/local/python3/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {'app': '__mp_main__:app'}
    │    │        │    │        └ <SpawnProcess name='SpawnProcess-1' parent=26466 started>
    │    │        │    └ (<multiprocessing.synchronize.Event object at 0x7f489000ed10>,)
    │    │        └ <SpawnProcess name='SpawnProcess-1' parent=26466 started>
    │    └ <function _run at 0x7f486aa1e170>
    └ <SpawnProcess name='SpawnProcess-1' parent=26466 started>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot_plugin_reboot/reloader.py", line 27, in _run
    _nb_run(*args, **kwargs)
    │        │       └ {'app': '__mp_main__:app'}
    │        └ ()
    └ <function run at 0x7f488c642050>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
    │                 │       └ {'app': '__mp_main__:app'}
    │                 └ ()
    └ <function get_driver at 0x7f488c6424d0>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 198, in run
    uvicorn.run(
    │       └ <function run at 0x7f488b6bb250>
    └ <module 'uvicorn' from '/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/uvicorn/__init_...
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 578, in run
    server.run()
    │      └ <function Server.run at 0x7f488b6bb400>
    └ <uvicorn.server.Server object at 0x7f4863896350>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
           │       │   │    │             └ None
           │       │   │    └ <function Server.serve at 0x7f488b6bb490>
           │       │   └ <uvicorn.server.Server object at 0x7f4863896350>
           │       └ <function run at 0x7f488dc4e8c0>
           └ <module 'asyncio' from '/usr/local/python3/lib/python3.10/asyncio/__init__.py'>
  File "/usr/local/python3/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
           │    │                  └ <coroutine object Server.serve at 0x7f488aaf8270>
           │    └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
           └ <uvloop.Loop running=True closed=False debug=False>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 141, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
          │            │        │    │      │      │      └ {<function _command at 0x7f488c1520e0>: <Task finished name='Task-16346' coro=<_command() done, defined at /root/.cache/pypoe...
          │            │        │    │      │      └ <contextlib.AsyncExitStack object at 0x7f4862cc6ec0>
          │            │        │    │      └ {'_prefix': {'command': ('点歌',), 'raw_command': '点歌', 'command_arg': [MessageSegment(type='text', data={'text': 'メタもリボン'})], ...
          │            │        │    └ GroupMessageEvent(time=1684129275, self_id=<bot.self_id>, post_type='message', sub_type='normal', user_id=<user_id>, message_ty...
          │            │        └ Bot(type='OneBot V11', self_id='<bot.self_id>')
          │            └ Matcher(type='message', module=nonebot_plugin_multincm.__main__)
          └ <function _run_matcher at 0x7f488c227880>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 187, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
          │       │   │    │      │      │      └ {<function _command at 0x7f488c1520e0>: <Task finished name='Task-16346' coro=<_command() done, defined at /root/.cache/pypoe...
          │       │   │    │      │      └ <contextlib.AsyncExitStack object at 0x7f4862cc6ec0>
          │       │   │    │      └ {'_prefix': {'command': ('点歌',), 'raw_command': '点歌', 'command_arg': [MessageSegment(type='text', data={'text': 'メタもリボン'})], ...
          │       │   │    └ GroupMessageEvent(time=1684129275, self_id=<bot.self_id>, post_type='message', sub_type='normal', user_id=<user_id>, message_ty...
          │       │   └ Bot(type='OneBot V11', self_id='<bot.self_id>')
          │       └ <function Matcher.run at 0x7f488c151d80>
          └ Matcher(type='message', module=nonebot_plugin_multincm.__main__)
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 753, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
          │    │          │    │      │      │      └ {<function _command at 0x7f488c1520e0>: <Task finished name='Task-16346' coro=<_command() done, defined at /root/.cache/pypoe...
          │    │          │    │      │      └ <contextlib.AsyncExitStack object at 0x7f4862cc6ec0>
          │    │          │    │      └ {'_prefix': {'command': ('点歌',), 'raw_command': '点歌', 'command_arg': [MessageSegment(type='text', data={'text': 'メタもリボン'})], ...
          │    │          │    └ GroupMessageEvent(time=1684129275, self_id=<bot.self_id>, post_type='message', sub_type='normal', user_id=<user_id>, message_ty...
          │    │          └ Bot(type='OneBot V11', self_id='<bot.self_id>')
          │    └ <function Matcher.simple_run at 0x7f488c151cf0>
          └ Matcher(type='message', module=nonebot_plugin_multincm.__main__)
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 728, in simple_run
    await handler(
          └ Dependent(call=_, parameterless=(Depends(Dependent(call=_key_getter)),))
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
                 │    │             │         │    │    │       └ {'matcher': Matcher(type='message', module=nonebot_plugin_multincm.__main__), 'state': {'_prefix': {'command': ('点歌',), 'raw_...
                 │    │             │         │    │    └ <function _ at 0x7f486a966b00>
                 │    │             │         │    └ Dependent(call=_, parameterless=(Depends(Dependent(call=_key_getter)),))
                 │    │             │         └ ~R
                 │    │             └ typing.Awaitable
                 │    └ typing.Callable
                 └ <function cast at 0x7f488df61c60>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot_plugin_multincm/__main__.py", line 106, in _
    await matcher.pause(await get_page(matcher, state))
          │       │           │        │        └ {'_prefix': {'command': ('点歌',), 'raw_command': '点歌', 'command_arg': [MessageSegment(type='text', data={'text': 'メタもリボン'})], ...
          │       │           │        └ Matcher(type='message', module=nonebot_plugin_multincm.__main__)
          │       │           └ <function get_page at 0x7f486a9343a0>
          │       └ <classmethod(<function Matcher.pause at 0x7f488c1512d0>)>
          └ Matcher(type='message', module=nonebot_plugin_multincm.__main__)
> File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot_plugin_multincm/__main__.py", line 65, in get_page
    res = await search_song(param, page=page)
                │           │           └ 1
                │           └ 'メタもリボン'
                └ <function search_song at 0x7f486a9340d0>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot_plugin_multincm/data_source.py", line 44, in search_song
    res = await ncm_request(
                └ <function ncm_request at 0x7f486aa8fd00>
  File "/root/.cache/pypoetry/virtualenvs/kohane-oWw4prHg-py3.10/lib/python3.10/site-packages/nonebot_plugin_multincm/data_source.py", line 35, in ncm_request
    if ret["code"] != 200:
       └ {'result': {'searchQcReminder': None, 'songs': [{'name': 'メタモリボン', 'id': 2010289108, 'pst': 0, 't': 0, 'ar': [{'id': 162173, ...

KeyError: 'code'

另外,与nonebot-plugin-ncm同时使用时,点歌命令会与该插件冲突,bot将返回如下图所示的两条消息: 52d1369e48bb0ae5.png

lgc2333 commented 1 year ago

关于ncm点歌冲突问题,使用 ncm search f 关掉ncm点歌即可 keyerror 问题我会排查一下的

lgc2333 commented 1 year ago

https://github.com/lgc-NB2Dev/nonebot-plugin-multincm/releases/tag/v0.2.2