wechaty / python-wechaty

Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
https://wechaty.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.55k stars 229 forks source link

⁉ ⁉How to send a filebox using python-wechaty with wechaty-puppet-xp successfully? #361

Closed lixin396 closed 1 year ago

lixin396 commented 1 year ago

requirements

Gateway part version: wechaty@1.20.2, wechaty-puppet-xp@1.11.1

Bot part , version of python-wechaty: wechaty==0.8.66 wechaty-grpc==0.20.19 wechaty-puppet==0.4.21 wechaty-puppet-service==0.8.9

Describe your problem

Failed to send a filebox.

Reproduce your problem

    file_box = FileBox.from_url('https://alifei03.cfp.cn/creative/vcg/800/new/VCG211177178924.jpg', name='ding-dong.jpg')
    await msg.say(file_box)

Error info

14:26:25 VERB PuppetServiceImpl messagePayload()
14:26:25 VERB PuppetMessageMixin messagePayload(cl78nw7ly0001eg18bma8btpo)
14:26:26 VERB PuppetServiceImpl messageSendFile()
14:26:26 ERR PuppetServiceImpl grpcError() messageSendFile() rejection: no url
Error: no url
    at new FileBox (file:///C:/software/wechat-bot-test/node_modules/file-box/dist/esm/src/file-box.js:363:27)
    at new FileBox (file:///C:/software/wechat-bot-test/node_modules/clone-class/dist/esm/src/clone-class.js:20:13)
    at Function.fromUrl (file:///C:/software/wechat-bot-test/node_modules/file-box/dist/esm/src/file-box.js:84:16)
    at Function.fromJSON (file:///C:/software/wechat-bot-test/node_modules/file-box/dist/esm/src/file-box.js:227:32)
    at messageSendFile (file:///C:/software/wechat-bot-test/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/server/puppet-implementation.js:613:45)
    at Object.messageSendFile (file:///C:/software/wechat-bot-test/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/esm/src/auth/auth-impl-token.js:26:28)
    at handleUnary (C:\software\wechat-bot-test\node_modules\@grpc\grpc-js\build\src\server.js:688:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
14:26:31 SILL Io start() setInterval() ws.ping()

Your experiments

I tested ts scripts with wechat-puppet-xp, send filebox successfully. For exapmle, ts scripts: if (msg.text() === "filebox") { const fileBox = FileBox.fromUrl('https://alifei03.cfp.cn/creative/vcg/800/new/VCG211177178924.jpg') await msg.say(fileBox); }

log:

15:07:43 VERB MiniProgram constructor() 15:07:43 VERB Message say(FileBox#Url) 15:07:43 SILL PuppetLoginMixin get currentUserId() 15:07:43 VERB Contact say(FileBox#Url)

lixin396 commented 1 year ago

Solved.

I added "self.url = options.url" in the file "wechaty_puppet\file_box\file_box.py" .

    elif isinstance(options, FileBoxOptionsUrl):
        self.remoteUrl = options.url
        self.url = options.url
duanghuang commented 1 year ago

朋友,你的Friendship.search功能可以正常使用吗