python-wechaty icon indicating copy to clipboard operation
python-wechaty copied to clipboard

๐Ÿ›๐Ÿ› Bug Report: FileBox.from_url()๏ผŒๆ— ๆณ•ๅ‘้€็ฝ‘็ปœๅ›พ็‰‡

Open xinxinyihao opened this issue 3 years ago โ€ข 2 comments

requirements

  • token type(web protocol, padlocal) [required]
  • version of python-wechaty [0.8.66]
  • version of wechaty docker image [latest]

Describe your problem

ไน‹ๅ‰ไธ€็›ด้ƒฝๆ˜ฏๅฅฝๅฅฝ็š„๏ผŒๅคงๆฆ‚ไปŽๆ˜จๅคฉๅผ€ๅง‹๏ผŒๅ‘็Žฐ๏ผŒไฝฟ็”จFileBox.from_url()๏ผŒไธ่ƒฝๅ‘้€็ฝ‘็ปœๅ›พ็‰‡ไบ†ใ€‚from_file่ฟ˜่ƒฝ็”จใ€‚

Reproduce your problem

    @logger.catch()
    async def on_message(self, msg: Message) -> None:
        if msg.is_self():
            return
        text = msg.text()
        if text == 'ๆˆ‘็š„ๆต‹่ฏ•ๅ›พ็‰‡':
            file_box = FileBox.from_url(url='https://img2.woyaogexing.com/2022/07/21/03e08cd0ad72c979.jpg', name='test.jpg')
            await msg.ready()
            await msg.say(file_box)

Error info

2022-08-12 09:26:03.756 | ERROR    | wechaty.plugin:emit_events:743 - An error has been caught in function 'emit_events', process 'MainProcess' (4729), thread 'MainThread' (139784813381376):
Traceback (most recent call last):

  File "/opt/wechat/bot.py", line 38, in <module>
    asyncio.run(main())
    โ”‚       โ”‚   โ”” <function main at 0x7f2229c86040>
    โ”‚       โ”” <function run at 0x7f2229a82d30>
    โ”” <module 'asyncio' from '/usr/local/lib/python3.9/asyncio/__init__.py'>

  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
           โ”‚    โ”‚                  โ”” <coroutine object main at 0x7f222469a2c0>
           โ”‚    โ”” <function BaseEventLoop.run_until_complete at 0x7f2227c78700>
           โ”” <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
    self.run_forever()
    โ”‚    โ”” <function BaseEventLoop.run_forever at 0x7f2227c78670>
    โ”” <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
    โ”‚    โ”” <function BaseEventLoop._run_once at 0x7f2227c7a1f0>
    โ”” <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1890, in _run_once
    handle._run()
    โ”‚      โ”” <function Handle._run at 0x7f2227cade50>
    โ”” <Handle <TaskWakeupMethWrapper object at 0x7f222431c340>(<Future finished result=True>)>
  File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
    โ”‚    โ”‚            โ”‚    โ”‚           โ”‚    โ”” <member '_args' of 'Handle' objects>
    โ”‚    โ”‚            โ”‚    โ”‚           โ”” <Handle <TaskWakeupMethWrapper object at 0x7f222431c340>(<Future finished result=True>)>
    โ”‚    โ”‚            โ”‚    โ”” <member '_callback' of 'Handle' objects>
    โ”‚    โ”‚            โ”” <Handle <TaskWakeupMethWrapper object at 0x7f222431c340>(<Future finished result=True>)>
    โ”‚    โ”” <member '_context' of 'Handle' objects>
    โ”” <Handle <TaskWakeupMethWrapper object at 0x7f222431c340>(<Future finished result=True>)>
  File "/usr/local/lib/python3.9/site-packages/wechaty/wechaty.py", line 564, in message_listener
    await self._plugin_manager.emit_events('message', msg)
          โ”‚    โ”‚               โ”‚                      โ”” <wechaty.wechaty.Message object at 0x7f22243743a0>
          โ”‚    โ”‚               โ”” <function WechatyPluginManager.emit_events at 0x7f2225668310>
          โ”‚    โ”” <wechaty.plugin.WechatyPluginManager object at 0x7f2224629d90>
          โ”” <wechaty.wechaty.Wechaty object at 0x7f2224629a90>
> File "/usr/local/lib/python3.9/site-packages/wechaty/plugin.py", line 743, in emit_events
    await plugin.on_message(message)
          โ”‚      โ”‚          โ”” <wechaty.wechaty.Message object at 0x7f22243743a0>
          โ”‚      โ”” <function TestPlugin.on_message at 0x7f22246324c0>
          โ”” <plugin.TestPlugin object at 0x7f22245a6790>

  File "/opt/wechat/plugin.py", line 19, in on_message
    await msg.say(file_box)
          โ”‚   โ”‚   โ”” <wechaty_puppet.file_box.file_box.FileBox object at 0x7f2224374340>
          โ”‚   โ”” <function Message.say at 0x7f22246dc550>
          โ”” <wechaty.wechaty.Message object at 0x7f22243743a0>

  File "/usr/local/lib/python3.9/site-packages/wechaty/user/message.py", line 172, in say
    message_id = await self.puppet.message_send_file(
                       โ”‚    โ”” <property object at 0x7f2226e08bd0>
                       โ”” <wechaty.wechaty.Message object at 0x7f22243743a0>
  File "/usr/local/lib/python3.9/site-packages/wechaty_puppet_service/puppet.py", line 373, in message_send_file
    response = await self.puppet_stub.message_send_file(
                     โ”‚    โ”” <property object at 0x7f22245ab630>
                     โ”” <wechaty_puppet_service.puppet.PuppetService object at 0x7f2224629b80>
  File "/usr/local/lib/python3.9/site-packages/wechaty_grpc/wechaty/__init__.py", line 312, in message_send_file
    return await self._unary_unary(
                 โ”‚    โ”” <function ServiceStub._unary_unary at 0x7f2227b2b5e0>
                 โ”” <wechaty_grpc.wechaty.PuppetStub object at 0x7f222439a3a0>
  File "/usr/local/lib/python3.9/site-packages/betterproto/__init__.py", line 1125, in _unary_unary
    assert response is not None
           โ”” None

AssertionError: assert response is not None

docker log

01:36:47 ERR PuppetServiceImpl grpcError() messageSendFile() rejection: no url
Error: no url
    at new FileBox (file:///wechaty/node_modules/file-box/src/file-box.ts:548:17)
    at new FileBox (file:///wechaty/node_modules/clone-class/src/clone-class.ts:31:7)
    at Function.fromUrl (file:///wechaty/node_modules/file-box/src/file-box.ts:164:12)
    at Function.fromJSON (file:///wechaty/node_modules/file-box/src/file-box.ts:385:24)
    at messageSendFile (file:///wechaty/node_modules/wechaty-puppet-service/src/server/puppet-implementation.ts:793:37)
    at Object.messageSendFile (file:///wechaty/node_modules/wechaty-puppet-service/src/auth/auth-impl-token.ts:49:18)
    at handleUnary (/wechaty/node_modules/@grpc/grpc-js/src/server.ts:925:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Your experiments

please tell us your experiments and ideas about this issue. It's valuable for us to help you find the solution.

xinxinyihao avatar Aug 12 '22 01:08 xinxinyihao

Try to add "self.url = options.url" in the file "wechaty_puppet\file_box\file_box.py" . For example:

elif isinstance(options, FileBoxOptionsUrl):
    self.remoteUrl = options.url
    self.url = options.url 

#361

lixin396 avatar Aug 26 '22 03:08 lixin396

ๅŒๆ ท็š„้—ฎ้ข˜๏ผŒๆœ‰ไบบ่ทŸ่ฟ›ๅ—๏ผŸ https://github.com/wechaty/puppet-supports/issues/179

zhegexiaohuozi avatar Mar 06 '23 03:03 zhegexiaohuozi