nonebot-plugin-gocqhttp icon indicating copy to clipboard operation
nonebot-plugin-gocqhttp copied to clipboard

使用命令gocqhttp时报错

Open yokinanya opened this issue 1 year ago • 1 comments

python版本:3.9.5 nonebot版本:2.0.0b4

08-11 12:25:34 [ERROR] nonebot | Running matcher <Matcher from nonebot_plugin_gocqhttp.plugin, type=message, priority=1, temp=False> failed.
Traceback (most recent call last):

  File "/home/ubuntu/nonebot/StarHina/./bot.py", line 36, in <module>
    nonebot.run(app="__mp_main__:app")
    │       └ <function run at 0x7f021e52a280>
    └ <module 'nonebot' from '/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/__init__.py'>

  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/__init__.py", line 261, in run
    get_driver().run(*args, **kwargs)
    │                 │       └ {'app': '__mp_main__:app'}
    │                 └ ()
    └ <function get_driver at 0x7f021fc40d30>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 170, in run
    uvicorn.run(
    │       └ <function run at 0x7f021dc1c3a0>
    └ <module 'uvicorn' from '/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/uvicorn/__init__.py'>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/uvicorn/main.py", line 463, in run
    server.run()
    │      └ <function Server.run at 0x7f021dc14e50>
    └ <uvicorn.server.Server object at 0x7f021d8a2580>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
           │       │   │    │             └ None
           │       │   │    └ <function Server.serve at 0x7f021dc14ee0>
           │       │   └ <uvicorn.server.Server object at 0x7f021d8a2580>
           │       └ <function run at 0x7f021f5f5820>
           └ <module 'asyncio' from '/usr/lib/python3.9/asyncio/__init__.py'>
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
           │    │                  └ <coroutine object Server.serve at 0x7f0216972340>
           │    └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
           └ <uvloop.Loop running=True closed=False debug=False>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
          │            │        │    │      │      │      └ {<function _command at 0x7f021e4ce430>: <Task finished name='Task-275' coro=<_command() done, defined at /home/ubuntu/.enviro...
          │            │        │    │      │      └ <contextlib.AsyncExitStack object at 0x7f02145c0b20>
          │            │        │    │      └ {'_prefix': {'command': ('gocq',), 'raw_command': '.gocq', 'command_arg': [], 'command_start': '.'}}
          │            │        │    └ PrivateMessageEvent(time=1660191934, self_id=2594737819, post_type='message', sub_type='friend', user_id=1099332511, message_...
          │            │        └ <nonebot.adapters.onebot.v11.bot.Bot object at 0x7f021463ea60>
          │            └ <Matcher from nonebot_plugin_gocqhttp.plugin, type=message, priority=1, temp=False>
          └ <function _run_matcher at 0x7f021e347f70>
> File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
          │       │   │    │      │      │      └ {<function _command at 0x7f021e4ce430>: <Task finished name='Task-275' coro=<_command() done, defined at /home/ubuntu/.enviro...
          │       │   │    │      │      └ <contextlib.AsyncExitStack object at 0x7f02145c0b20>
          │       │   │    │      └ {'_prefix': {'command': ('gocq',), 'raw_command': '.gocq', 'command_arg': [], 'command_start': '.'}}
          │       │   │    └ PrivateMessageEvent(time=1660191934, self_id=2594737819, post_type='message', sub_type='friend', user_id=1099332511, message_...
          │       │   └ <nonebot.adapters.onebot.v11.bot.Bot object at 0x7f021463ea60>
          │       └ <function Matcher.run at 0x7f021e4c7dc0>
          └ <Matcher from nonebot_plugin_gocqhttp.plugin, type=message, priority=1, temp=False>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 668, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
          │    │          │    │      │      │      └ {<function _command at 0x7f021e4ce430>: <Task finished name='Task-275' coro=<_command() done, defined at /home/ubuntu/.enviro...
          │    │          │    │      │      └ <contextlib.AsyncExitStack object at 0x7f02145c0b20>
          │    │          │    │      └ {'_prefix': {'command': ('gocq',), 'raw_command': '.gocq', 'command_arg': [], 'command_start': '.'}}
          │    │          │    └ PrivateMessageEvent(time=1660191934, self_id=2594737819, post_type='message', sub_type='friend', user_id=1099332511, message_...
          │    │          └ <nonebot.adapters.onebot.v11.bot.Bot object at 0x7f021463ea60>
          │    └ <function Matcher.simple_run at 0x7f021e4c7d30>
          └ <Matcher from nonebot_plugin_gocqhttp.plugin, type=message, priority=1, temp=False>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 635, in simple_run
    await handler(
          └ <Dependent call=<function _ at 0x7f021d472a60>, params=[ModelField(name='bot', type=Bot, required=True), ModelField(name='eve...
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/dependencies/__init__.py", line 92, in __call__
    return await self.call(**values)
                 │    │      └ {'bot': <nonebot.adapters.onebot.v11.bot.Bot object at 0x7f021463ea60>, 'event': PrivateMessageEvent(time=1660191934, self_id...
                 │    └ <function _ at 0x7f021d472a60>
                 └ <Dependent call=<function _ at 0x7f021d472a60>, params=[ModelField(name='bot', type=Bot, required=True), ModelField(name='eve...
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot_plugin_gocqhttp/plugin.py", line 38, in _
    messages += STATUS_MESSAGE_TEMPLATE.format(
    │           │                       └ <function MessageTemplate.format at 0x7f021e84a310>
    │           └ <nonebot.internal.adapter.template.MessageTemplate object at 0x7f021d4b7760>
    └ []
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/template.py", line 70, in format
    return self._format(args, kwargs)
           │    │       │     └ {'account': 2594737819, 'total_logs': 22, 'restarts': 0}
           │    │       └ ()
           │    └ <function MessageTemplate._format at 0x7f021e84a430>
           └ <nonebot.internal.adapter.template.MessageTemplate object at 0x7f021d4b7760>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/template.py", line 81, in _format
    msg, arg_index = self._vformat(
                     │    └ <function MessageTemplate._vformat at 0x7f021e84a550>
                     └ <nonebot.internal.adapter.template.MessageTemplate object at 0x7f021d4b7760>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/template.py", line 165, in _vformat
    return functools.reduce(self._add, results), auto_arg_index
           │         │      │    │     │         └ 0
           │         │      │    │     └ [[], '帐号', 2594737819, '统计数据:\n日志条数: ', 22, '\n重启次数: ', 0, '\n']
           │         │      │    └ <function MessageTemplate._add at 0x7f021e84a670>
           │         │      └ <nonebot.internal.adapter.template.MessageTemplate object at 0x7f021d4b7760>
           │         └ <built-in function reduce>
           └ <module 'functools' from '/usr/lib/python3.9/functools.py'>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/template.py", line 182, in _add
    return a + b
           │   └ 2594737819
           └ [MessageSegment(type='text', data={'text': '帐号'})]
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/message.py", line 276, in __add__
    return super(Message, self).__add__(
                 │        └ [MessageSegment(type='text', data={'text': '帐号'})]
                 └ <class 'nonebot.adapters.onebot.v11.message.Message'>
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/message.py", line 174, in __add__
    result += other
    │         └ 2594737819
    └ [MessageSegment(type='text', data={'text': '帐号'})]
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/message.py", line 292, in __iadd__
    return super().__iadd__(
  File "/home/ubuntu/.environments/StarHina39/lib/python3.9/site-packages/nonebot/internal/adapter/message.py", line 189, in __iadd__
    raise ValueError(f"Unsupported type: {type(other)}")  # pragma: no cover

ValueError: Unsupported type: <class 'int'>

yokinanya avatar Aug 11 '22 04:08 yokinanya

这是NoneBot2上游的bug,已经提交issue https://github.com/nonebot/nonebot2/issues/1138 来处理

虽然但是这个Bug也是我写的……无语

mnixry avatar Aug 11 '22 06:08 mnixry

此问题已经在上游修复 请等待该修复发布新版本

mnixry avatar Sep 14 '22 02:09 mnixry