wechaty / wechaty-puppet-padplus

DEPRECATED: One puppet based on iPad protocal for Wechaty
https://wechaty.js.org/docs/puppet-services/
315 stars 65 forks source link

依赖包wechaty-puppet 版本号冲突 #271

Open pest1999 opened 4 years ago

pest1999 commented 4 years ago

系统环境:win server 2012 r2 standard 按照文档安装,提示版本号冲突,报错如下

npm WARN wechaty-puppet-hostie@0.8.5 requires a peer of wechaty-puppet@^0.26.1 but none is installed. You must install p
eer dependencies yourself.
npm WARN wechaty-puppet-padplus@0.7.27 requires a peer of wechaty-puppet@^0.25.2 but none is installed. You must install
 peer dependencies yourself.
npm WARN my-padplus-bot2@1.0.0 No description
npm WARN my-padplus-bot2@1.0.0 No repository field.

package.json如下:

{
  "name": "my-padplus-bot2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bufferutil": "^4.0.1",
    "qrcode-terminal": "^0.12.0",
    "utf-8-validate": "^5.0.2",
    "wechaty": "^0.41.24",
    "wechaty-puppet-padplus": "^0.7.27"
  }
}

执行启动命令ts-node bot.ts后,报错如下:

    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
bot.ts:34:7 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '"logout"' is not assignable to parameter of type 'never'.

34   .on('logout', (user: Contact, reason: string) => {
         ~~~~~~~~

  node_modules/wechaty/dist/src/wechaty.d.ts:224:5
    224     on(event: never, listener: never): never;
            ~~
    The last overload is declared here.
bot.ts:37:4 - error TS2339: Property 'start' does not exist on type 'never'.

37   .start()
      ~~~~~

    at createTSError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:434:12)
    at reportTSError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:438:19)
    at getOutput (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:578:36)
    at Object.compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:775:32)
    at Module.m._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:858:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\Administrator\AppData\Roaming\npm\node_modules\
ts-node\src\index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
pest1999 commented 4 years ago

node 版本和示例一致 10.16.0 npm 版本 6.4.1

pest1999 commented 4 years ago

改写bot.ts后能够正常运行 该动后的bot.ts文件如下

// bot.ts
import { Contact, Message, Wechaty } from 'wechaty'
import { ScanStatus } from 'wechaty-puppet'
import { PuppetPadplus } from 'wechaty-puppet-padplus'
import QrcodeTerminal from 'qrcode-terminal'

const token = 'puppet_padplus_*****'   //自行申请token

const puppet = new PuppetPadplus({
  token,
})

const name  = 'my-padplus-bot2'

const bot = new Wechaty({
  name: 'mybot',
  puppet, // generate xxxx.memory-card.json and save login data for the next login
})

bot.on('scan', (qrcode, status) => {
    if (status === ScanStatus.Waiting) {
      QrcodeTerminal.generate(qrcode, {
        small: true
      })
    }
  })
bot.on('login', (user: Contact) => {
    console.log(`login success, user: ${user}`)
  })
bot.on('message', (msg: Message) => {
    console.log(`msg : ${msg}`)
  })
bot.start()