Skip to content

Cannot create an instance of the abstract class 'FriendRequest'. #94

@lijiarui

Description

@lijiarui

Run npm run doctor or wechaty run doctor(for docker user), paste output here

Wechaty Doctor

  1. Wechaty version: 0.5.9
  2. Linux x64 version 3.16.0-4-amd64 memory 272/1000 MB
  3. Docker: true
  4. Node version: v7.1.0

Actual behavior

When I create a FriendRequest class as API gave, occurred error :"Cannot create an instance of the abstract class 'FriendRequest'."

Code as follows

import { 
Wechaty
,FriendRequest
} from 'wechaty'

const bot = Wechaty.instance({profile:'test'})


bot
.on('scan' ,(url,code)=>{console.log(url)})

.on('login',username=>{
  console.log(username.name())
  
})
.on('message', m=> {
  const room = m.room()
  const from = m.from()
  if(room){
    if(from.stranger()){
      const request = new FriendRequest()
      request.send(from, 'hello~')
    }  
    
  }
})
.init()

Paste the full output logs here with WECHATY_LOG=silly set

/wechaty/node_modules/ts-node/dist/index.js:160
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset));
^
TSError: ⨯ Unable to compile TypeScript
a.ts (21,21): Cannot create an instance of the abstract class 'FriendRequest'. (2511)


| __ )| | | |/ | | _ | | _ \ / _ | _ _ |
| _ | | | | | _ | |
) | | | |) | | | | |
) || |
| |
) | |
| | |
| | | _ <| |
| /| || | _ < | |
|
___/ _
/ _| || __|| ___/|| _|_|

Press ENTER to continue ...

1. source code of a.ts

import {
Wechaty
,FriendRequest
} from 'wechaty'

const bot = Wechaty.instance({profile:'test'})

bot
.on('scan' ,(url,code)=>{console.log(url)})

.on('login',username=>{
console.log(username.name())

})

.on('message', m=> {
const room = m.room()
const from = m.from()
if(room){
if(from.stranger()){
const request = new FriendRequest()
request.send(from, 'hello~')
}
}

})
.init()

2. directory structor of /bot

total 6504
-rw-r--r-- 1 root root 410 Nov 14 14:58 a.ts
-rw------- 1 root root 9564160 Nov 14 13:18 core
drwxr-xr-x 3 root root 4096 Nov 14 05:39 git
drwxr-xr-x 5 root root 4096 Nov 14 14:59 node_modules
-rw-r--r-- 1 root root 848 Nov 14 14:52 test.ts
-rw-r--r-- 1 root root 1540 Nov 14 14:18 test.wechaty.json
-rw-r--r-- 1 root root 1371 Nov 6 11:28 wechatyshow.ts

3. package.json

cat: /bot/package.json: No such file or directory
No package.json

4. directory structor inside /bot/node_modules

@types qrcode-terminal wechaty

5. wechaty doctor

Wechaty Doctor

  1. Wechaty version: 0.5.9
  2. Linux x64 version 3.16.0-4-amd64 memory 457/1000 MB
  3. Docker: true
  4. Node version: v7.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions