wechaty / wechaty-puppet-padpro

Apache License 2.0
238 stars 64 forks source link

使用Contact.say(MiniProgramPayload) 报错:this.puppet.messageSendMiniProgram is not a function #194

Open juneyang opened 5 years ago

juneyang commented 5 years ago
  1. 请运行下面的命令,看问题是否可以被解决:

    rm -rf package-lock.json
    rm -rf node_modules
    npm install

    没有解决

  2. 请在 FAQ 清单 看是否已有解决办法。 否

  3. 请先在issue 中搜关键信息,确认你要发的内容和之前的issue 不重复。

1. 提供你的包版本信息

2. Bug 描述

请用精简的语言描述你遇到的bug 使用机器人可以发送小程序的时候,使用 Contact.say( miniPayload ) 提示 UnhandledPromiseRejectionWarning: TypeError: this.puppet.messageSendMiniProgram is not a function

3. 复现的步骤 (或者解决的步骤)

这一部分非常重要,如果你无法给出复现步骤,我们也很难提供相应的解决办法:

复现步骤中一定要给出复现代码

例子:

const contact = message.from()
const text = message.text()
if( text === '小程序'){
const miniProgramPayload = new MiniProgram ({
        username           : 'gh_xxxxxx',       //get from mp.weixin.qq.com
        appid              : 'wxxxxxxxxxxxxx',    //optional, get from mp.weixin.qq.com
         title              : '小程序title',       //optional
         pagepath           : '/pages/event/events',   //optional
         description        : '小程序名',               //optional
         thumbnailurl       : '',               //optional
})
await contact.say(miniProgramPayload)
}

之后使用微信发送 '小程序' 给机器人

4. 期待程序运行的结果

期待可以正常发送小程序

5. 程序实际运行的结果

报错:(node:24910) UnhandledPromiseRejectionWarning: TypeError: this.puppet.messageSendMiniProgram is not a function

6. 完整的日志信息:

通过WECHATY_LOG=silly设定环境变量,将设置log 等级为 silly,获取最详细的日志信息(默认log 等级为 info) 请提供完整的日志信息(不要只提供部分的日志截图,请复制粘贴日志内容!)

$ WECHATY_LOG=silly ts-node index.ts 19:41:44 SILL Config WECHATY_LOG set level to silly 19:41:44 INFO Config registering process.on("unhandledRejection") for development/debug 19:41:44 VERB Config constructor() 19:41:45 VERB Puppet constructor({"timeout":240,"token":"puppet_padpro_s26wojwn96ubo13h"}) #0 19:41:45 VERB StateSwitch constructor(name=PuppetPadpro) 19:41:45 VERB MemoryCard constructor(undefined) 19:41:45 VERB MemoryCard getStorage() for storage type: N/A 19:41:45 VERB MemoryCard load() from storage: N/A 19:41:45 VERB MemoryCard load() no storage 19:41:45 VERB Puppet constructor() watchdog timeout set to 240 seconds 19:41:45 VERB HotImport callerResolve(., /Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty-puppet/dist/src/puppet.js) 19:41:45 SILL HotImport callerResolve() callsites() file=/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/hot-import/dist/src/hot-import.js, type=Object 19:41:45 SILL HotImport callerResolve() callsites() file=/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty-puppet/dist/src/puppet.js, type=null 19:41:45 SILL HotImport callerResolve() callsites() file=/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty-puppet-padpro/dist/src/puppet-padpro.js, type=null 19:41:45 SILL HotImport callerResolve() callerFile=/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty-puppet-padpro/dist/src/puppet-padpro.js 19:41:45 VERB Puppet constructor() childClassPath=/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty-puppet-padpro/dist/src 19:41:45 SILL Accessory #0 constructor() 19:41:45 VERB Wechaty contructor() 19:41:45 VERB StateSwitch constructor(name=Wechaty) 19:41:45 VERB StateSwitch constructor(name=WechatyReady) 19:41:45 VERB Wechaty on(scan, function) registered 19:41:45 VERB Wechaty onFunction(scan) 19:41:45 VERB Wechaty on(login, function) registered 19:41:45 VERB Wechaty onFunction(login) 19:41:45 VERB Wechaty on(message, function) registered 19:41:45 VERB Wechaty onFunction(message) 19:41:45 VERB Wechaty on(friendship, function) registered 19:41:45 VERB Wechaty onFunction(friendship) 19:41:45 VERB Wechaty on(room-join, function) registered 19:41:45 VERB Wechaty onFunction(room-join) 19:41:45 VERB Wechaty on(room-topic, function) registered 19:41:45 VERB Wechaty onFunction(room-topic) 19:41:45 SILL Wechaty version() form development environment is not availble: ENOENT: no such file or directory, stat '/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty/dist/.git' 19:41:45 INFO Wechaty ()/PuppetPadpro#0>() start() v0.27.60 is starting... 19:41:45 VERB Wechaty puppet: Puppet#0()/PuppetPadpro#0 19:41:45 VERB Wechaty name: undefined 19:41:45 VERB Wechaty id: cjzibwzn30000xxfy027k32t8 19:41:45 SILL StateSwitch on() is false 19:41:45 SILL StateSwitch off() is true 19:41:45 VERB StateSwitch off(true) <- (true) 19:41:45 SILL StateSwitch on() is false 19:41:45 VERB StateSwitch on(pending) <- (false) 19:41:45 VERB MemoryCard constructor(undefined) 19:41:45 VERB MemoryCard getStorage() for storage type: N/A 19:41:45 VERB MemoryCard load() from storage: N/A 19:41:45 VERB MemoryCard load() no storage 19:41:45 VERB Puppet constructor() memory.load() done 19:41:45 VERB Wechaty initPuppet() Puppet#0()/PuppetPadpro#0 19:41:45 VERB MemoryCard multiplex(puppet) 19:41:45 VERB MemoryCard static multiplex(MemoryCard<>, puppet) 19:41:45 VERB MemoryCard constructor({"multiplex":{"name":"puppet","parent":{"payload":{},"multiplexNameList":[]}}}) 19:41:45 VERB PuppetManager resolve({puppet: Puppet#0()/PuppetPadpro#0, puppetOptions: undefined}) 19:41:45 VERB PuppetManager resolveInstance(Puppet#0()/PuppetPadpro#0) 19:41:45 VERB Puppet setMemory() 19:41:45 VERB Wechaty initPuppetEventBridge(Puppet#0()/PuppetPadpro#0) 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(login) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(logout) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(message) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(scan) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(dong) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(error) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(ready) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(reset) registered 19:41:45 VERB Wechaty initPuppetEventBridge() puppet.on(watchdog) registered 19:41:45 VERB Wechaty initAccessory(Puppet#0()/PuppetPadpro#0) 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set wechaty = "Wechaty#cjzibwzn30000xxfy027k32t8()/PuppetPadpro#0>()" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory static set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL Accessory set puppet = "Puppet#0()/PuppetPadpro#0" 19:41:45 SILL StateSwitch on() is false 19:41:45 SILL StateSwitch on() is false 19:41:45 VERB StateSwitch on(pending) <- (false) 19:41:45 INFO WechatGateway init(puppet_padpro_s26wojwn96ubo13h, padpro.botorange.com:6666, undefined) 19:41:45 SILL StateSwitch off() is false 19:41:46 INFO CacheManager init() 19:41:46 SILL StateSwitch on() is pending 19:41:46 VERB StateSwitch on(true) <- (pending) 19:41:46 VERB Wechaty on(heartbeat, function) registered 19:41:46 VERB Wechaty onFunction(heartbeat) 19:41:46 SILL StateSwitch on() is pending 19:41:46 VERB StateSwitch on(true) <- (pending) 19:41:47 VERB Puppet login(wxid_9nn6nccionrs22) 19:41:47 VERB Contact load(wxid_9nn6nccionrs22) init pool 19:41:47 SILL Accessory #1 constructor() 19:41:47 SILL Contact constructor(wxid_9nn6nccionrs22) 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Puppet contactPayload(wxid_9nn6nccionrs22) cache MISS 19:41:47 SILL Puppet contactPayload(wxid_9nn6nccionrs22) cache SET 19:41:47 VERB Room findAll({"topic":{}}) 19:41:47 VERB Puppet roomSearch({"topic":{}}) 19:41:47 SILL Puppet roomSearch() allRoomIdList.length=5 19:41:47 VERB Puppet roomPayload(10739031372@chatroom) 19:41:47 SILL Puppet roomPayloadCache(10739031372@chatroom) cache MISS 19:41:47 VERB Puppet roomPayload(21586147375@chatroom) 19:41:47 SILL Puppet roomPayloadCache(21586147375@chatroom) cache MISS 19:41:47 VERB Puppet roomPayload(22053447177@chatroom) 19:41:47 SILL Puppet roomPayloadCache(22053447177@chatroom) cache MISS 19:41:47 VERB Puppet roomPayload(22542847197@chatroom) 19:41:47 SILL Puppet roomPayloadCache(22542847197@chatroom) cache MISS 19:41:47 VERB Puppet roomPayload(22563847274@chatroom) 19:41:47 SILL Puppet roomPayloadCache(22563847274@chatroom) cache MISS 19:41:47 SILL Puppet roomPayload(10739031372@chatroom) cache SET 19:41:47 SILL Puppet roomPayload(21586147375@chatroom) cache SET 19:41:47 SILL Puppet roomPayload(22053447177@chatroom) cache SET 19:41:47 SILL Puppet roomPayload(22542847197@chatroom) cache SET 19:41:47 SILL Puppet roomPayload(22563847274@chatroom) cache SET 19:41:47 VERB Puppet roomQueryFilterFactory({"topic":{}}) 19:41:47 SILL Puppet roomSearch() roomIdList filtered. result length=3 19:41:47 SILL Accessory #2 constructor() 19:41:47 SILL Room constructor(21586147375@chatroom) 19:41:47 SILL Accessory #3 constructor() 19:41:47 SILL Room constructor(22542847197@chatroom) 19:41:47 SILL Accessory #4 constructor() 19:41:47 SILL Room constructor(22563847274@chatroom) 19:41:47 VERB Room ready() 19:41:47 VERB Puppet roomPayload(21586147375@chatroom) 19:41:47 VERB Room ready() 19:41:47 VERB Puppet roomPayload(22542847197@chatroom) 19:41:47 VERB Room ready() 19:41:47 VERB Puppet roomPayload(22563847274@chatroom) 19:41:47 VERB Contact load(wxid_9nn6nccionrs22) init pool 19:41:47 SILL Accessory #5 constructor() 19:41:47 SILL Contact constructor(wxid_9nn6nccionrs22) 19:41:47 SILL Accessory #6 constructor() 19:41:47 SILL Contact constructor(yangjun) 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Puppet contactPayload(yangjun) cache MISS 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Puppet contactPayload(yangjun) cache MISS 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Puppet contactPayload(yangjun) cache MISS 19:41:47 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:47 SILL Puppet contactPayload(yangjun) cache SET 19:41:47 SILL Puppet contactPayload(yangjun) cache SET 19:41:47 SILL Puppet contactPayload(yangjun) cache SET 19:41:48 VERB Message static load(1002050576) 19:41:48 SILL Accessory #7 constructor() 19:41:48 VERB Message constructor(1002050576) for class Message 19:41:48 VERB Message ready() 19:41:48 VERB Puppet messagePayload(1002050576) 19:41:48 SILL Puppet messagePayloadCache(1002050576) cache MISS 19:41:48 SILL Puppet messagePayload(1002050576) cache SET 19:41:48 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:48 SILL Contact ready() isReady() true 19:41:48 SILL Contact ready() @ Puppet#0()/PuppetPadpro#0 19:41:48 SILL Contact ready() isReady() true 19:41:48 VERB Puppet selfId() 19:41:48 VERB Message mention() 19:41:48 VERB Puppet selfId() 19:41:48 VERB Message mention() 19:41:48 VERB MiniProgram constructor() 19:41:48 VERB Contact say([object Object]) 19:41:48 ERR Config ########################### 19:41:48 ERR Config unhandledRejection: TypeError: this.puppet.messageSendMiniProgram is not a function [object Promise] 19:41:48 ERR Config ########################### 19:41:48 ERR Config process.on(unhandledRejection) promise.catch(this.puppet.messageSendMiniProgram is not a function) Config TypeError: this.puppet.messageSendMiniProgram is not a function at AnotherOriginalClass. (/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty/src/user/contact.ts:400:25) at Generator.next () at /Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty/dist/src/user/contact.js:7:71 at new Promise () at __awaiter (/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty/dist/src/user/contact.js:3:12) at AnotherOriginalClass.say (/Users/yang/Desktop/MovieStaff/wechaty-ipad/node_modules/wechaty/dist/src/user/contact.js:282:16) at Object. (/Users/yang/Desktop/MovieStaff/wechaty-ipad/index.ts:112:32) at step (/Users/yang/Desktop/MovieStaff/wechaty-ipad/index.ts:32:23) at Object.next (/Users/yang/Desktop/MovieStaff/wechaty-ipad/index.ts:13:53) at fulfilled (/Users/yang/Desktop/MovieStaff/wechaty-ipad/index.ts:4:58) (node:25845) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2) ```shell $ WECHATY_LOG=silly node yourbot.js ```

7. 其他信息

有相关bug 的背景信息,可以在这里说明

[bug]

windmemory commented 5 years ago

麻烦更新wechaty-puppet-padpro版本到0.3.16再试一下