8000 FileBox instance type checking problem · Issue #2035 · wechaty/wechaty · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
FileBox instance type checking problem #2035
Closed
@archywillhe

Description

@archywillhe

1.Versions

What is your wechaty version?

Answer:0.43.10

Which puppet are you using for wechaty? (hostie/puppeteer/padchat/...)

Answer: hostie (donut token)

What is your wechaty-puppet-XXX(padchat/puppeteer/) version?

Answer: "wechaty-puppet-hostie": "^0.9.1"

What is your node version? (run node --version)

Answer: v14.6.0

What os are you using

Answer: macOS 10.14.6

2. Describe the bug

This is an error that is only thrown when I'm using my plugin inside my wechaty.

I have created a wechaty plugin that makes use of Filebox.

Inside my plugin, when I do

const qrCodeImage = FileBox.fromUrl(qrCodeToLogin,'qr.png')
contact.say(qrCodeImage)

it gives the following error:

Error: unsupported arg: FileBox#Url<qr.png>
0|donut-desu-oooo  |     at AnotherOriginalClass.<anonymous> (/Users/arch/donut-test-ground/node_modules/wechaty/src/user/contact.ts:449:13)

apperantly in wechaty/src/user/contact.ts when it was checking if qrCodeImage's type is FileBox in line 428, false was returned.

 else if (something instanceof FileBox) {

so line 425's error is thrown.

 throw new Error('unsupported arg: ' + something)

However if I do the messageSendFile explicitly inside my plugin, it works!

const qrCodeImage = FileBox.fromUrl(qrCodeToLogin,'qr.png')
if(qrCodeImage instanceof FileBox){
      bot.wechaty.puppet.messageSendFile(
        contact.id,
        qrCodeImage,
      )

So qrCodeImage instanceof FileBox returns true inside my plugin, but it returns false inside wechaty/src/user/contact.ts.

It's either a werid type error or maybe I'm using the wrong FileBox dependencies?'

3. To Reproduce

just clone my wechaty-log-monitor plugin https://github.com/archywillhe/wechaty-log-monitor

and in util.ts change

    if(something instanceof FileBox){
      bot.wechaty.puppet.messageSendFile(
        contact.id,
        something,
      )

to contact.say(something)

and it will fail when it's a filebox.

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

      0